[Libav-user] blackdetect using libavfilter C API
Venkateswaran.S
venketeswaran2015 at gmail.com
Sat Mar 9 00:55:21 EET 2019
Hi Philippe,
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.
below function created promblem in my code,
av_opt_set_int_list(buffersink_ctx, "pix_fmts",
pix_fmts,AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
I removed it and both the outpts matching now.
Thanks for your support,really appreciable.
Thanks & Regards,
Venkateswaran.S
On Sat, Mar 9, 2019 at 3:39 AM Venkateswaran.S <venketeswaran2015 at gmail.com>
wrote:
> 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/b562a59f/attachment.html>
More information about the Libav-user
mailing list