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