[FFmpeg-user] Duplicated frames when streaming to decklink

Valentin Schweitzer vs at nativewaves.com
Wed Oct 23 19:38:31 EEST 2019

On 17/10/2019 22:32, Marton Balint wrote:
> On Thu, 17 Oct 2019, Valentin Schweitzer wrote:
>> Hi,
>> I am trying to stream audio and video in an endless loop from a file to
>> a DeckLink Duo 2 on Windows 10. When streaming in this loop,
>> ffmpeg reports duplicated frames approximately at the time
>> the loop starts anew. The command I'm using is the following:
>> .\ffmpeg.exe -loglevel verbose -re -stream_loop -1 -i trailer_stereo.mp4
>> -pix_fmt uyvy422 -f decklink "81:4108a8c0:00000000"  2>stereo.log
>> where trailer_stereo.mp4 is a file containing a h264 stream at 25fps
>> and a resolution of 1920x1080 and an aac stream at 48000Hz.
>> The trailer_stereo.mp4 file was created by converting the
>> original (see 1.) from 5.1 audio to stereo with
>> .\ffmpeg.exe -i .\trailer_1080p.mov -vcodec copy -acodec aac -ac 2
>> trailer_stereo.mp4
>> After approximately every loop there seems to be a buffer underrun
>> for both video and audio and a few frames are duplicated.
>> When running this for a longer time period
>> the decklink stream becomes unusable.
>> As the audio and video streams do not appear to be equal in length,
>> I then tried to cut the file down to the length of the shortest stream.
>> The file was truncated using -shortest (again, starting from the
>> file linked below (see 1.)) with this command:
>> .\ffmpeg.exe -i .\trailer_1080p.mov -vcodec copy -acodec aac -ac 2
>> -shortest trailer_stereo_shortest.mp4
>> Now, duplicate frames still appear, but no buffer underrun is reported
>> (at least not this early on), when streaming it with:
>> .\ffmpeg.exe -loglevel verbose -re -stream_loop -1 -i
>> trailer_stereo_shortest.mp4 -pix_fmt uyvy422 -f decklink
>> "81:4108a8c0:00000000" 2> shortest.log 
> -re should not be used here. Also you should try this with uncompressed audio. AAC has priming at the start and at the end which is usually not discarded properly by ffmpeg causing audio/video length differences.

Thanks for the advice; sadly it does not seem to fix the
duplicate issue. I tried with PCM audio, converting the
original file with:
.\ffmpeg.exe -i .\trailer_1080p.mov -ac 2 -acodec pcm_s16le -vcodec copy trailer_uncompressed.mov
I chose pcm_s16le purely because it is the default when
transcoding to uncompressed audio. The mov container
is used because I had some issues muxing the audio to mp4.

The converted file was streamed using this command:
.\ffmpeg.exe -loglevel verbose -stream_loop -1 -i .\trailer_uncompressed.mov -pix_fmt uyvy422 -f decklink "81:4108a8c0:00000000" 2> uncompressed_short.log

The log still shows a few duplicated frames each time
the stream loop restarts. I have attached an (uncut)
short log that goes on for about ten minutes. There is also
a log that lasts for a little under five hours linked via [1].

The issue seems to be connected to the audio stream, as no
frames are duplicated if the audio stream is removed, either
by adding -an to the command above or removing it from the
file. The "[h264 @ 037b0ac0] Reinit context to 1920x1088, pix_fmt: yuv420p"
messages still appear without audio, but don't appear to
have any unusual effects.

Log of a longer stream. The error starting at line 2 is related to Powershell
and shouldn't affect ffmpeg.
1. https://gist.github.com/vschweitzer/d029d7be128f0755f8f33e6cd3c1f03d
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: uncompressed_short.log
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20191023/8a255ff6/attachment.ksh>

More information about the ffmpeg-user mailing list