[FFmpeg-devel] [PATCH] avfilter/f_cue: add cue and acue filters

Marton Balint cus at passwd.hu
Fri Sep 7 00:10:35 EEST 2018



On Thu, 6 Sep 2018, Bodecs Bela wrote:

> Hi Balint,
>
>
> 2018.09.06. 22:20 keltezéssel, Marton Balint írta:
>>
>> On Sat, 1 Sep 2018, Bodecs Bela wrote:
>>
>>> Hi Balint,
>>>
>>>
>>> 2018.08.25. 20:35 keltezéssel, Marton Balint írta:
>>>> To delay filtering until a given wallclock timestamp.
>>>>
>>>> Signed-off-by: Marton Balint <cus at passwd.hu>
>>>> ---
>>>>   doc/filters.texi         |  36 ++++++++++
>>>>   libavfilter/Makefile     |   2 +
>>>>   libavfilter/allfilters.c |   2 +
>>>>   libavfilter/f_cue.c      | 182 
>>>> +++++++++++++++++++++++++++++++++++++++++++++++
>>>>   libavfilter/version.h    |   2 +-
>>>>   5 files changed, 223 insertions(+), 1 deletion(-)
>>>>   create mode 100644 libavfilter/f_cue.c
>>>>
>>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>>> index 32c95b591c..79eec0c808 100644
>>>> --- a/doc/filters.texi
>>>> +++ b/doc/filters.texi
>>>> @@ -551,6 +551,11 @@ Set LFO range.
>>>>   Set LFO rate.
>>>>   @end table
>>>>
>>>> + at section acue
>>>> +
>>>> +Delay audio filtering until a given wallclock timestamp. See the 
>>>> @ref{cue}
>>>> +filter.
>>>> +
>>>>   @section adeclick
>>>>   Remove impulsive noise from input audio.
>>>>
>>>> @@ -6987,6 +6992,37 @@ indicates 'never reset', and returns the 
>>>> largest area encountered during
>>>>   playback.
>>>>   @end table
>>>>
>>>> + at anchor{cue}
>>>> + at section cue
>>>> +
>>>> +Delay video filtering until a given wallclock timestamp. The filter 
>>>> first
>>>> +passes on @option{preroll} amount of frames, then it buffers at most
>>>> + at option{buffer} amount of frames and waits for the cue. After 
>>>> reaching the cue
>>>> +it forwards the buffered frames and also any subsequent frames 
>>>> coming in its
>>>> +input.
>>>> +
>>>> +The filter can be used synchronize the output of multiple ffmpeg 
>>>> processes for
>>>> +realtime output devices like decklink. By putting the delay in the 
>>>> filtering
>>>> +chain and pre-buffering frames the process can pass on data to 
>>>> output almost
>>>> +immediately after the target wallclock timestamp is reached.
>>>> +
>>>> +Perfect frame accuracy cannot be guaranteed, but the result is good 
>>>> enough for
>>>> +some use cases.
>>
>>> just for my curiousity, will you please give an example/use_case how 
>>> to use these filters?
>>
>> Here is a shell script:
>>
>> #!/bin/bash
>> UNIX_TIMESTAMP=`date +%s`
>> TS=$((UNIX_TIMESTAMP*1000000 + 2500000))
>> ffmpeg -nostdin -nostats -stream_loop -1 -i input1.mp4 \
>>  -vf "format=uyvy422,cue=$TS:preroll=0.5:buffer=0.5" \
>>  -af "acue=$TS:preroll=0.5:buffer=0.5" -f decklink "DeckLink Duo (1)" &
>> ffmpeg -nostdin -nostats -stream_loop -1 -i input2.mp4 \
>>  -vf "format=uyvy422,cue=$TS:preroll=0.5:buffer=0.5" \
>>  -af "acue=$TS:preroll=0.5:buffer=0.5" -f decklink "DeckLink Duo (2)" &
>> ffmpeg -nostdin -nostats -stream_loop -1 -i input3.mp4 \
>>  -vf "format=uyvy422,cue=$TS:preroll=0.5:buffer=0.5" \
>>  -af "acue=$TS:preroll=0.5:buffer=0.5" -f decklink "DeckLink Duo (3)" &
>> ffmpeg -nostdin -nostats -stream_loop -1 -i input4.mp4 \
>>  -vf "format=uyvy422,cue=$TS:preroll=0.5:buffer=0.5" \
>>  -af "acue=$TS:preroll=0.5:buffer=0.5" -f decklink "DeckLink Duo (4)" &
>>
> Thank you.
>
> what about to create a new parameter for the filters: relcue/arelcue ?
>
> relcue would be a relative value to current timestamp. This way the 
> shell variable will be unneeded.

The shell variable is needed to be able to provide a common start 
timestamp to all the processes. If relative timestamp is used, that kind 
of defeats the purpose of synchronization, because different processes 
will have different delays in opening their inputs, which means variable 
delay in initalizing their filters, so the start time for passing data 
will not be common among processes.

>
> usage of cue and relcue would be mutally esclusive parameters.

Obviously it is possible, can be added later if somebody finds a valid use 
case for it :)

Regards,
Marton


More information about the ffmpeg-devel mailing list