[Libav-user] blackdetect using libavfilter C API
Venkateswaran.S
venketeswaran2015 at gmail.com
Sat Mar 9 00:09:57 EET 2019
Hi Philippe,
I have changed it to "lavfi.black_start" and "lavfi.black_end", but still
getting different output compare to ffmpeg cmd tool.
if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_start", tag,
AV_DICT_IGNORE_SUFFIX)))
printf("%s = %s\n", tag->key, tag->value);
if ((tag = av_dict_get(filt_frame->metadata, "lavfi.black_end", tag,
AV_DICT_IGNORE_SUFFIX)))
printf("%s = %s\n", tag->key, tag->value);
please find my code in the attachment.
On Sat, Mar 9, 2019 at 2:53 AM Philippe Gorley <
philippe.gorley at savoirfairelinux.com> wrote:
> On 2019-03-08 2:47 p.m., Venkateswaran.S wrote:
> > 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).
>
> I could not find "lavfi.black_duration" anywhere in the file
> libavfilter/vf_blackdetect.c (or the source code at all), so I doubt
> it's being set.
>
> If the key doesn't exist in the AVDictionary, av_dict_get returns NULL
> (0). You want to check until it returns an actual AVDictionaryEntry,
> then check AVDictionaryEntry.value for the time string.
>
> >
> > 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).
>
> The black duration log you see is the result of the filter subtracting
> black_start from black_end in the check_black_end function.
>
> >
> > Testing Video: https://www.youtube.com/watch?v=-Hsl5UG9O_c&t=6s
> >
> >
> > _______________________________________________
> > 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".
> >
>
> You want to get lavfi.black_end and lavfi.black_start, parse the time
> strings and find the difference.
>
> --
> 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/705ce537/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filter.c
Type: text/x-csrc
Size: 10159 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190309/705ce537/attachment.c>
More information about the Libav-user
mailing list