<div dir="ltr"><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">Hi Philippe,</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">I compared "AV_LOG_DEBUG" output of both my code and ffmpeg cmd tool and came to know that I'm converting every frames to grayscale in my code. So it detects more blackframes than ffmpeg cmd tool.  </pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">below function created promblem in my code,</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">av_opt_set_int_list(buffersink_ctx, "pix_fmts", pix_fmts,AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">I removed it and both the outpts matching now. </pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">Thanks for your support,really appreciable.</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">Thanks & Regards,</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">Venkateswaran.S</pre></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2019 at 3:39 AM Venkateswaran.S <<a href="mailto:venketeswaran2015@gmail.com">venketeswaran2015@gmail.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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"> Hi <span style="color:rgb(80,0,80)">Philippe,</span><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">I have changed it to </span><font color="#500050">"lavfi.black_start"  and "lavfi.black_end", </font><span style="color:rgb(80,0,80)">but still getting different output </span>compare<span style="color:rgb(80,0,80)"> to </span>ffmpeg<span style="color:rgb(80,0,80)"> cmd tool.</span></div><div><font color="#500050"><br></font></div><div><font color="#500050"><div>if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_start", tag, AV_DICT_IGNORE_SUFFIX)))</div><div>    printf("%s = %s\n", tag->key, tag->value);</div><div>if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_end", tag, AV_DICT_IGNORE_SUFFIX)))</div><div>    printf("%s = %s\n", tag->key, tag->value);</div><div><br></div><div>please find my code in the attachment. </div></font></div><div><font color="#500050"><br></font></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2019 at 2:53 AM Philippe Gorley <<a href="mailto:philippe.gorley@savoirfairelinux.com" target="_blank">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 2:47 p.m., Venkateswaran.S wrote:<br>
> Hi Philippe,<br>
> <br>
> Thanks for your reply. I have got the required output by adding below <br>
> function call in my code,<br>
> if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_duration", <br>
> tag, AV_DICT_IGNORE_SUFFIX)))<br>
>      printf("%s=%s\n", tag->key);<br>
> <br>
> and it prints below output,<br>
> <br>
> [blackdetect @ 0x5566fef000c0] black_start:5.46379 black_end:7.29896 <br>
> black_duration:1.83517<br>
> [blackdetect @ 0x5566fef000c0] black_start:82.8328 black_end:84.4594 <br>
> black_duration:1.62662<br>
> [blackdetect @ 0x5566fef000c0] black_start:142.768 black_end:144.019 <br>
> black_duration:1.25125<br>
> <br>
> I'm using "lavfi.black_duration" because if I use "lavfi.black_start" it <br>
> print black_start at 0 second (false detection).<br>
<br>
I could not find "lavfi.black_duration" anywhere in the file <br>
libavfilter/vf_blackdetect.c (or the source code at all), so I doubt <br>
it's being set.<br>
<br>
If the key doesn't exist in the AVDictionary, av_dict_get returns NULL <br>
(0). You want to check until it returns an actual AVDictionaryEntry, <br>
then check AVDictionaryEntry.value for the time string.<br>
<br>
> <br>
> Now, I tried to run the same filter through command line using below <br>
> command,<br>
> ffmpeg -i SonOfGod.mp4 -vf "blackdetect=d=1:pix_th=0.00" -an -f null -<br>
> <br>
> and it prints below output,<br>
> <br>
> [blackdetect @ 0x5601cbc54c60] black_start:5.46379 black_end:7.007 <br>
> black_duration:1.54321<br>
> [blackdetect @ 0x5601cbc54c60] black_start:82.8745 black_end:84.1674 <br>
> black_duration:1.29296<br>
> <br>
> above command line tool produces perfect output and exactly matches with <br>
> actual video content timing (black start & back end).<br>
> <br>
> How does both the C API and FFmpeg cmd tool give different output? is <br>
> there anything I'm missing in C API code <br>
> <a href="https://ffmpeg.org/doxygen/3.4/filtering__video_8c_source.html" rel="noreferrer" target="_blank">https://ffmpeg.org/doxygen/3.4/filtering__video_8c_source.html</a> (removed <br>
> display_frame function).<br>
<br>
The black duration log you see is the result of the filter subtracting <br>
black_start from black_end in the check_black_end function.<br>
<br>
> <br>
> Testing Video: <a href="https://www.youtube.com/watch?v=-Hsl5UG9O_c&t=6s" rel="noreferrer" target="_blank">https://www.youtube.com/watch?v=-Hsl5UG9O_c&t=6s</a><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>
You want to get lavfi.black_end and lavfi.black_start, parse the time <br>
strings and find the difference.<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>
</blockquote></div>