<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Philippe,</div><div dir="ltr"><br></div><div>Thanks for your reply. I have got the required output by adding below function call in my code,</div><div><div>if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_duration", tag, AV_DICT_IGNORE_SUFFIX)))</div><div>    printf("%s=%s\n", tag->key);</div></div><div><br></div><div>and it prints below output,</div><div><br></div><div><div>[blackdetect @ 0x5566fef000c0] black_start:5.46379 black_end:7.29896 black_duration:1.83517</div><div>[blackdetect @ 0x5566fef000c0] black_start:82.8328 black_end:84.4594 black_duration:1.62662</div><div>[blackdetect @ 0x5566fef000c0] black_start:142.768 black_end:144.019 black_duration:1.25125</div></div><div><br></div><div>I'm using "lavfi.black_duration" because if I use "lavfi.black_start" it print black_start at 0 second (false detection).</div><div><br></div><div>Now, I tried to run the same filter through command line using below command,</div><div>ffmpeg -i SonOfGod.mp4 -vf "blackdetect=d=1:pix_th=0.00" -an -f null -<br></div><div><br></div><div>and it prints below output,<br></div><div><br></div><div><div>[blackdetect @ 0x5601cbc54c60] black_start:5.46379 black_end:7.007 black_duration:1.54321</div><div>[blackdetect @ 0x5601cbc54c60] black_start:82.8745 black_end:84.1674 black_duration:1.29296</div></div><div><br></div><div>above command line tool produces perfect output and exactly matches with actual video content timing (black start & back end).</div><div><br></div><div>How does both the C API and FFmpeg cmd tool give different output? is there anything I'm missing in C API code <a href="https://ffmpeg.org/doxygen/3.4/filtering__video_8c_source.html">https://ffmpeg.org/doxygen/3.4/filtering__video_8c_source.html</a> (removed display_frame function).</div><div><br></div><div>Testing Video: <a href="https://www.youtube.com/watch?v=-Hsl5UG9O_c&t=6s">https://www.youtube.com/watch?v=-Hsl5UG9O_c&t=6s</a></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 8, 2019 at 9:02 PM Philippe Gorley <<a href="mailto:philippe.gorley@savoirfairelinux.com">philippe.gorley@savoirfairelinux.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2019-03-08 10:05 a.m., Venkateswaran.S wrote:<br>
> Hi,<br>
> <br>
> I'm using libavfilter to detect black frame in my video. I followed this <br>
> example <a href="https://ffmpeg.org/doxygen/3.4/filtering_video_8c-example.html" rel="noreferrer" target="_blank">https://ffmpeg.org/doxygen/3.4/filtering_video_8c-example.html</a> , <br>
> but this example doesn't shows how to print black frame detected <br>
> duration, instead it prints out video frames.<br>
<br>
The blackdetect filter sets "lavfi.black_start" in your AVFrame.metadata <br>
to a time string using AVFrame.pts and the time base (when it detects <br>
the start of a black sequence). When the black frames end, it sets <br>
"lavfi.black_end" in AVFrame.metadata, again using pts and time base.<br>
<br>
You'll have to check each frame's metadata (AVDictionary*) and compute <br>
the duration yourself.<br>
<br>
> As of now, I have replaced<br>
> constchar*filter_descr <br>
> <<a href="https://ffmpeg.org/doxygen/3.4/filtering__video_8c.html#a84b31b94c024a45c4bcebd875a54e73d" rel="noreferrer" target="_blank">https://ffmpeg.org/doxygen/3.4/filtering__video_8c.html#a84b31b94c024a45c4bcebd875a54e73d</a>>= <br>
> "scale=78:24,transpose=cclock"; to constchar*filter_descr <br>
> <<a href="https://ffmpeg.org/doxygen/3.4/filtering__video_8c.html#a84b31b94c024a45c4bcebd875a54e73d" rel="noreferrer" target="_blank">https://ffmpeg.org/doxygen/3.4/filtering__video_8c.html#a84b31b94c024a45c4bcebd875a54e73d</a>>= <br>
> "blackdetect=d=2:pix_th=0.00";<br>
> in the code.<br>
> <br>
> Thanks & regards,<br>
> S.Venkateswaran<br>
> <br>
> <br>
> _______________________________________________<br>
> Libav-user mailing list<br>
> <a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
> <a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
> <br>
> To unsubscribe, visit link above, or email<br>
> <a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
> <br>
<br>
-- <br>
Philippe Gorley<br>
Free Software Consultant | Montréal, Qc<br>
Savoir-faire Linux<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote></div>