Page 1 of 1

Buffer overrun Blackmagic Intensity 4K as input to FFmpeg

PostPosted: Wed May 18, 2016 11:56 am
by Tristan Slaney
I am trying to take direct video output from a 4k Sony Handycam, via HDMI directly into a Blackmagic Intensity Pro 4K. I can verify that the camera, Hdmi and blackmagic card are working as I can capture and view video using the provided "Media Express" program. When use ffmpeg I do get video output but I also get a buffer overrun.

Here is the command:

Code: Select all
time ffmpeg -f decklink -i "Intensity Pro 4K@20" -c:v nvenc -b:v 100M -vf "yadif=0:-1:0" -pix_fmt yuv420p -crf 29.97 -strict -2 output.mp4


And I get the following output:

Code: Select all
ffmpeg version N-76538-gb83c849 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --enable-nonfree --enable-nvenc --enable-nvresize --extra-cflags=-I../cudautils --extra-ldflags=-L../cudautils --enable-gpl --enable-libx264 --enable-libx265 --enable-decklink --extra-cflags=-I/home/tristan/Downloads/BlackmagicDeckLinkSDK10.6.5/Linux/include --extra-ldflags=-L/home/tristan/Downloads/BlackmagicDeckLinkSDK10.6.5/Linux/include
  libavutil      55.  5.100 / 55.  5.100
  libavcodec     57. 15.100 / 57. 15.100
  libavformat    57. 14.100 / 57. 14.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[decklink @ 0x1ccd6e0] Found Decklink mode 3840 x 2160 with rate 29.97
[decklink @ 0x1ccd6e0] Stream #1: not enough frames to estimate rate; consider increasing probesize
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, decklink, from 'Intensity Pro 4K@20':
  Duration: N/A, start: 0.000000, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422, 3840x2160, -5 kb/s, 29.97 tbr, 1000k tbn, 29.97 tbc
Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
File 'output.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf57.14.100
    Stream #0:0: Video: h264 (nvenc) ([33][0][0][0] / 0x0021), yuv420p, 3840x2160, q=-1--1, 100000 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc57.15.100 nvenc
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.15.100 aac
Stream mapping:
  Stream #0:1 -> #0:0 (rawvideo (native) -> h264 (nvenc))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[decklink @ 0x1ccd6e0] Decklink input buffer overrun!:03.15 bitrate=70411.7kbits/s   
    Last message repeated 1 times
[decklink @ 0x1ccd6e0] Decklink input buffer overrun!:03.54 bitrate=73110.9kbits/s   
    Last message repeated 20 times
[decklink @ 0x1ccd6e0] Decklink input buffer overrun!:03.92 bitrate=76270.2kbits/s   
    Last message repeated 15 times
[decklink @ 0x1ccd6e0] Decklink input buffer overrun!:04.28 bitrate=78367.6kbits/s   
    Last message repeated 61 times
frame=  140 fps= 22 q=-0.0 Lsize=   57266kB time=00:00:04.67 bitrate=100425.2kbits/s   
video:57187kB audio:72kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.009844%
[decklink @ 0x1ccd6e0] Decklink input buffer overrun!
    Last message repeated 7 times
[aac @ 0x1cd7020] Qavg: 215.556

real   0m8.808s
user   0m5.785s
sys   0m1.749s


Some sort of insight into this, be that just some commands that may fix it the issue, or otherwise.

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Wed May 25, 2016 5:48 am
by patrick_felt
It's likely that your machine isn't able to keep up with the transcoding that you are trying to do. This error happens when the decklink card is receiving data faster than it is processing it. the code is hard set to only buffer 1gig worth of data.

you may need to pull the data off and then transcode it after the fact.

do you get a similar error if you try something like the following command (be aware it'll take *a lot* of space)?

ffmpeg -f decklink -i "Intensity Pro 4K@20" -c:v copy output.raw

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Sat May 28, 2016 4:45 am
by Reuben
Your computer can't keep up, so your input buffer overflows. Also, the "crf" option has nothing to do with framerate.

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Sun Jul 24, 2016 1:08 am
by MichaelRichardson
patrick_felt wrote:It's likely that your machine isn't able to keep up with the transcoding that you are trying to do.


This made some sense to me even though I was using an i7-5930K (6-core) overclocked to 4.2Ghz, but then I clocked back down and saw the same behavior. The longer I let it run, the closer I get to 1x (like .998x), but never quite 1x.

To further test this idea, I've now rented a dual-xeon, 2699v3 (that's 38 cores), with 256GB of ram and I'm seeing the EXACT same behavior though to be fair, I'm pulling UHD59.94, cropping it, then sending it to h264_nvenc. The crop seems to be pretty heavy.

If if I -c copy output.avi instead of cropping or encoding, it hits 1x and stays pretty much, but again, I can get SO close on very different machines so there's something else going on and in my case, I suspect it's related to nvenc despite being on SDK 7 and having a BEAST of a machine to work with.

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Mon Jul 25, 2016 10:55 pm
by Dave Johnstone
Have you tried the threads option for ffmpeg? You can assign more threads to the input and/or output processing for example:
Code: Select all
ffmpeg -f decklink -i "Intensity Pro 4K@20" -threads 48 -c:v nvenc -b:v 100M -vf "yadif=0:-1:0" -pix_fmt yuv420p -crf 29.97 -strict -2 output.mp4
Also, is your storage fast enough to keep up with the data rate?

Regards,

Dave.

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Fri Jul 17, 2020 3:07 am
by TobyEggitt
Did you ever work this out? I have a similar issue with ffmpeg, I'm grabbing multiple channels. The capture rate shows greater than 1x (not by much), and the CPU is using less than 1/3 of it's available threads, and yet, it's still generating the buffer overflows.

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Mon Aug 17, 2020 12:17 pm
by kevleyski
(also seeing this w/ latest FFmpeg, debugging clues always welcome)

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Tue Aug 25, 2020 1:49 pm
by deadsound
Queue Size sorted it for me.. for example

ffmpeg -raw_format uyvy422 -queue_size 1150000000 -f decklink

Re: Buffer overrun Blackmagic Intensity 4K as input to FFmpe

PostPosted: Tue Sep 01, 2020 9:21 am
by kevleyski
deadsound wrote:Queue Size sorted it for me.. for example

ffmpeg -raw_format uyvy422 -queue_size 1150000000 -f decklink
Yeah for me it prolongs the issue unfortunately- I see the issue propagate as latency that grows up to a point
I’ll keep debugging
Something I also see is format_codes wondering if these can throttle the input frame rate maybe


Sent from my iPhone using Tapatalk