Hi all,
This could have gone in the "Capturing" forum but ultimately it's more of an encoding/FFmpeg related problem so I'll post here. I am trying to capture 4K HDR 5.1 audio input over HDMI using a Blackmagic Decklink Mini Recorder 4K PCI card. I was able to do this successfully using OBS, but OBS will only do AAC audio and not AC3 which I want unless you use the advanced/FFmpeg mode, which after weeks of trial and error apparently does not support 10-bit color spaces through OBS, or at least is not working.
I am now trying to capture directly from the Blackmagic card with FFmpeg as it is capable of doing this given the right commands. Right now I am using this:
ffmpeg -f dshow -video_size 3840x2160 -pixel_format uyvy422 -rtbufsize 300k -i video="Decklink Video Capture" -codec:v hevc_nvenc -codec:a ac3 -b:v 70k -b:a 4096 -pix_fmt p010 -framerate 23.976 output.mp4
Which results in no audio, choppy macroblocking playback, and no HDR metadata recognized in the output file. Admittedly I am a novice when it comes to FFmpeg, and if anyone could help me sort out the command line to get it to work that would be very much appreciated.
Thanks!
+ Reply to Thread
Results 1 to 19 of 19
-
-
Thanks I had looked through that as well as the full list of commands https://ffmpeg.org/ffmpeg.html and what I have above is the best I can come up with, but it's still not working 100% and I can't figure out why. There appears to be a buffer issue (getting buffer full error) and a compression problem, no sound, and no HDR metadata. I can't figure out what's missing or incorrect, but it at least will record.
-
try adding thread_queue_size 5096 to each input - https://stackoverflow.com/questions/48320119/real-time-buffer-too-full-ffmpeg
-
Didn't work. I tried:
Code:ffmpeg -thread_queue_size 128000 -f dshow -video_size 3840x2160 -pixel_format uyvy422 -rtbufsize 300k -i video="Decklink Video Capture" -codec:v hevc_nvenc -codec:a ac3 -b:v 70k -b:a 4096 -pix_fmt p010 -framerate 23.976 output313901.mp4
Code:Input #0, dshow, from 'video=Decklink Video Capture': Duration: N/A, start: 179135927.778968, bitrate: N/A Stream #0:0: Video: rawvideo (HDYC / 0x43594448), uyvy422, 3840x2160, 23.98 fps, 23.98 tbr, 10000k tbn File 'output313901.mp4' already exists. Overwrite? [y/N] [dshow @ 000001ab9093b800] real-time buffer [Decklink Video Capture] [video input] too full or near too full (5529% of size: 300000 [rtbufsize parameter])! frame dropped! Last message repeated 149 timess Last message repeated 149 times Not overwriting - exiting [dshow @ 000001ab9093b800] real-time buffer [Decklink Video Capture] [video input] too full or near too full (5529% of size: 300000 [rtbufsize parameter])! frame dropped!
Code:ffmpeg -thread_queue_size 128000 -f dshow -video_size 3840x2160 -pixel_format uyvy422 -rtbufsize 200000 -i video="Decklink Video Capture" -codec:v hevc_nvenc -codec:a ac3 -b:v 70000 -b:a 4096 -pix_fmt p010 -framerate 23.976 output3139031.mp4
-
A few suggestions.
It would seem like you need to add the audio capture device as one of your inputs:
Code:-i audio="Decklink Audio Capture"
Code:-b:a 448k
Code:p010le
PB -
Thanks it seems like I'm getting somewhere now. Since I last posted I fixed the "-rtbufsize" issue by just entering the max buf size it allows. I then made the changes you mentioned and am now entering:
Code:ffmpeg -thread_queue_size 2500000 -f dshow -video_size 3840x2160 -rtbufsize 2147480000 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -maxrate:v 100M -minrate:v 100M -bufsize:v 100M -pixel_format p010 -pix_fmt p010le -framerate 23.976 -codec:a ac3 -b:a 10M output222.mp4
General
Complete name : output222.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/dby1/iso2/avc1/mp41)
File size : 14.1 MiB
Duration : 14 s 807 ms
Overall bit rate : 7 991 kb/s
Writing application : Lavf59.36.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High 10@L5.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 14 s 807 ms
Bit rate : 7 348 kb/s
Maximum bit rate : 100.0 Mb/s
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.037
Stream size : 13.0 MiB (92%)
Writing library : x264 core 164 r3106 eaa68fa
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=24 / lookahead_threads=4 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=81 / qpstep=4 / vbv_maxrate=100000 / vbv_bufsize=100000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Commercial name : Dolby Digital
Codec ID : ac-3
Duration : 14 s 668 ms
Source duration : 14 s 673 ms
Bit rate mode : Constant
Bit rate : 643 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 SPF)
Compression mode : Lossy
Stream size : 1.13 MiB (8%)
Source stream size : 1.13 MiB (8%)
Service kind : Complete Main
Default : Yes
Alternate group : 1
The input is 5.1 audio I want to record as AC3 and it's only recording 2 channels. I also want to get the audio and video bitrate up and lastly get HDR working.
Thanks again for all the help! I've been working on this for weeks and it feels like I'm nearly there.Last edited by Boxcart; 19th Feb 2023 at 18:17.
-
Code:
[dshow @ 000001ab9093b800] real-time buffer [Decklink Video Capture] [video input] too full or near too full (5529% of size: 300000 [rtbufsize parameter])! frame dropped!
Also you may think about some fast color space conversion to meet you HW encoder expectations check hevc_nvenc capabilities:
Code:ffmpeg -h encoder=h264_nvenc >h264_nvenc.txt
-
Apologies for the delay on this I've been sidetracked, and thanks again all for the help. I'm now using:
Code:ffmpeg -thread_queue_size 2500000 -f dshow -video_size 3840x2160 -rtbufsize 2147480000 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -maxrate:v 100M -minrate:v 100M -bufsize:v 100M -pixel_format p010 -pix_fmt p010le -framerate 23.976 -codec:a ac3 -ac 6 -b:a 10M output1234.mkv
Code:-filter_complex "channelmap=map=FL-FF|FR-FR|FC-LFE|LFE-FC|BL-BL|BR-BR:channel_layout=5.1"
Finally it seems like the audio and video quality is a few touches below what's perceivably lossless. OBS (despite all its glitches) was putting out a slightly sharper product. MediaInfo says for the recording created using the command above that the video stream is:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High 10@L5.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 19 s 770 ms
Bit rate : 24.0 Mb/s
Maximum bit rate : 100.0 Mb/s
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.121
Stream size : 56.7 MiB (97%)
Writing library : x264 core 164 r3106 eaa68fa
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=24 / lookahead_threads=4 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=81 / qpstep=4 / vbv_maxrate=100000 / vbv_bufsize=100000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Commercial name : Dolby Digital
Codec ID : ac-3
Duration : 19 s 669 ms
Source duration : 19 s 674 ms
Bit rate mode : Constant
Bit rate : 641 kb/s
Channel(s) : 6 channels
Channel layout : L R C LFE Ls Rs
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 SPF)
Compression mode : Lossy
Stream size : 1.50 MiB (3%)
Source stream size : 1.50 MiB (3%)
Service kind : Complete Main
Default : Yes
Alternate group : 1 -
Looking at your channelmap, it may have failed because you have FL-FF and maybe you meant FL-FL.
I also note that in your original post you were working on the basis of capturing with the hevc_nvenc codec and your current output shows
AVC video, though it is 10-bit. I don't know what setting you would need to preserve the HDR information from the Decklink using FFMPEG but this OBS-Studio page states that it doesn't currently support HDR capture from that device.
https://obsproject.com/kb/video-capture-devices-with-hdr-supportPB -
Nice catch that was a typo I meant FL-FL. I’ve seen that OBS page before and that’s just referring to the fact OBS does not claim to support HDR recording on DeckLink cards, but the cards (or at least some of them, including the one I have, do support HDR). Blackmagic’s Media Express software will record HDR, so I know it works. Interestingly OBS will actually record in HDR from DeckLink with the right settings, so it’s definitely possible, I just need to figure out how to get Ffmpeg to do it.
-
try these settings - https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=125652
-
It looks like that thread is about using DaVinci Resolve to render the exported video in HDR. It would seem that would mean recording in what according to the metadata/MediaInfo is an SDR recording coming out of Ffmpeg, and then running it through DaVinci Resolve to add the HDR metadata? I haven't been able to find much of anything that discusses recording in Ffmpeg in HDR directly. There are some discussions online and people throw some commands in much like what I have that is not working, but not much beyond that.
From the previous post is there an issue that the HEVC_NVENC is not working since it's producing an AVC output? -
here it mentions decklink support - https://www.ffmpeg.org/ffmpeg-devices.html#decklink
see if this will help. -
You had this in your original command line:
Code:-codec:v hevc_nvenc
Some other parameters that may be required to preserve HDR:
Code:-color_trc smpte2084 -color_primaries bt2020 -colorspace bt2020nc
PB -
Thanks for the help everyone. I'm now using:
Code:ffmpeg -thread_queue_size 2500000 -f dshow -video_size 3840x2160 -rtbufsize 2147480000 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -codec:v hevc_nvenc -b:v 80M -maxrate:v 100M -minrate:v 100M -bufsize:v 100M -pixel_format p010 -pix_fmt p010le -framerate 23.976 -codec:a ac3 -ac 6 -b:a 10M -color_trc smpte2084 output1234.mkv
The audio remains a problem. I tried adding:Code:-filter_complex "channelmap=map=FL-FL|FR-FR|FC-LFE|LFE-FC|BL-BL|BR-BR:channel_layout=5.1"
"[Parsed_channelmap_0 @ 0000014e70350340] input channel 'FC' not available from input layout 'stereo'
[Parsed_channelmap_0 @ 0000014e70350340] input channel 'LFE' not available from input layout 'stereo'
[Parsed_channelmap_0 @ 0000014e70350340] input channel 'BL' not available from input layout 'stereo'
[Parsed_channelmap_0 @ 0000014e70350340] input channel 'BR' not available from input layout 'stereo'
[Parsed_channelmap_0 @ 0000014e70350340] Failed to configure input pad on Parsed_channelmap_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:1"
Ffmpeg is identifying the audio as "Guessed Channel Layout for Input Stream #0.1 : stereo" which I would imagine is responsible for this error. The input however is 6 channel 5.1. Interestingly, when I leave out the audio command and use the first command string in this post, it records 6 channels just fine, which MediaInfo identifies as 6 channel AC3, but there is no center channel heard in the recorded/output track. I'm not sure why it's guessing the audio layout, particularly as stereo, when I'm telling Ffmpeg there are 6 channels with "-ac 6"
Also just as something to try for the HDR issue, I tried using Shutter Encoder and processing the video with the H.265 codec and the colorspace under "Colorimetry" set to Rec. 2020 PQ 10bits HDR" while leaving all other settings the same/lossless, which adds the HDR metadata successfully to the output file, but looks very washed out.Last edited by Boxcart; 11th Mar 2023 at 15:15.
-
Some new information from my research: it appears dshow does not actually support HDR in FFmpeg, and either does not support more than 2 channels, or must be configured to do so. Apparently there is a build of ffmpeg with native Blackmagic DeckLink API support that works better, but I can't figure out how to to use it differently: https://forum.blackmagicdesign.com/viewtopic.php?f=12&t=83197
-
Another update: I finally have a command line that works with reference quality sharpness in the video, AC3 audio with channels organized properly, and HDR color. The only remaining problem is adding HDR metadata to the output MKV so it plays back with the proper colors. Right now it skews reddish/bluish. MediaInfo does not detect HDR10 metadata. Here is the FFmpeg command I'm using:
Code:ffmpeg -f dshow -video_pin_name 1 -audio_pin_name 1 -c:v v210 -video_size 3840x2160 -rtbufsize 2147480000 -framerate 24000/1001 -channels 6 -sample_rate 48k -sample_size 16 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -filter_complex "[0:0]scale=w=iw:h=ih:interl=false:eval=init:out_v_chr_pos=-128:out_h_chr_pos=-128:flags=bilinear+accurate_rnd+print_info,format=p010le[vout];[0:1]channelmap=FL-FL|FR-FR|LFE-FC|FC-LFE|BL-BL|BR-BR:5.1[aout]" -map "[vout]" -map "[aout]" -color_range tv -chroma_sample_location left -color_primaries bt2020 -colorspace bt2020nc -color_trc smpte2084 -c:a ac3 -c:v hevc_nvenc -profile:v main10 -preset:v p7 -b:v 80M -maxrate:v 100M -minrate:v 100M -bufsize:v 100M output.mkv
Thanks again to everyone for all the help!
Here is what MediaInfo shows:
Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L5@High
Codec ID : V_MPEGH/ISO/HEVC
Duration : 1 min 26 s
Bit rate : 79.2 Mb/s
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Bits/(Pixel*Frame) : 0.398
Stream size : 820 MiB (97%)
Writing library : Lavc60.6.100 hevc_nvenc
Default : No
Forced : No
Color range : Limited
Color primaries : BT.2020
Transfer characteristics : PQ
Matrix coefficients : BT.2020 non-constant
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Commercial name : Dolby Digital
Codec ID : A_AC3
Duration : 1 min 27 s
Bit rate mode : Constant
Bit rate : 448 kb/s
Channel(s) : 6 channels
Channel layout : L R C LFE Ls Rs
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 SPF)
Bit depth : 32 bits
Compression mode : Lossy
Stream size : 4.66 MiB (0%)
Writing library : Lavc60.6.100 ac3
Service kind : Complete Main
Default : No
Forced : No
Similar Threads
-
Complex FFMPEG command
By nifaf in forum Video ConversionReplies: 0Last Post: 23rd Sep 2021, 08:28 -
Get the complete FFmpeg command line when using FFmpeg Batch Converter
By pascor in forum Newbie / General discussionsReplies: 8Last Post: 13th May 2021, 23:14 -
Guys please I need help with my ffmpeg command
By Fidla in forum Video ConversionReplies: 1Last Post: 21st Jan 2021, 17:36 -
Need a command line for ffmpeg
By NTradd in forum Video ConversionReplies: 11Last Post: 14th Oct 2019, 11:25 -
ffmpeg command line help
By njscorpion in forum Newbie / General discussionsReplies: 2Last Post: 12th Jul 2019, 12:42