VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. 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!
    Quote Quote  
  2. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by Boxcart View Post
    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!
    see here - https://trac.ffmpeg.org/wiki/Capture/Blackmagic
    Quote Quote  
  3. Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    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!
    see here - https://trac.ffmpeg.org/wiki/Capture/Blackmagic
    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.
    Quote Quote  
  4. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by Boxcart View Post
    Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    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!
    see here - https://trac.ffmpeg.org/wiki/Capture/Blackmagic
    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
    Quote Quote  
  5. Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    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!
    see here - https://trac.ffmpeg.org/wiki/Capture/Blackmagic
    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
    Which resulted in:

    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!
    However I thend re-did the rtbufsize parameter as:

    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
    and got a successful recording, albeit one that is highly compressed (MediaInfo showing bitrate of 218 kb/s) with no HDR and no audio.
    Quote Quote  
  6. Member
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    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"
    And adjust the audio bitrate to something like:

    Code:
    -b:a 448k
    And maybe pix_fmt should be:

    Code:
    p010le
    PB
    Quote Quote  
  7. Originally Posted by autodidact View Post
    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"
    And adjust the audio bitrate to something like:

    Code:
    -b:a 448k
    And maybe pix_fmt should be:

    Code:
    p010le
    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
    I now get a successful recording, with some issues. According to MediaInfo the output is:

    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 19:17.
    Quote Quote  
  8. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    maybe:
    -codec:a ac3 -ac 6 -b:a 10M
    Quote Quote  
  9. 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!
    there is answer in ffmpeg logs - your buffersize is way too small - AFAIR it is provided in Bytes so you need to multiply 300000 bytes by 5529% so it should be around 16MB at least but at some point it may be necessary to increase it further 10..100 times more so at some point perhaps even around 1.6GB - depends on HW speed
    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
    Quote Quote  
  10. 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
    I can now record without any issues and the output is good. The outstanding problems now are that HDR is not working, and the center and LFE channels are flipped (a longstanding issue with Blackmagic Design cards) and so I need to use a command to fix that. I tried:

    Code:
    -filter_complex "channelmap=map=FL-FF|FR-FR|FC-LFE|LFE-FC|BL-BL|BR-BR:channel_layout=5.1"
    but that caused ffmpeg to give the error: "failed to parse channel map." I'm not sure if that command works for recording streams or only when processing files through ffmpeg.

    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
    Quote Quote  
  11. Member
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    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-support
    PB
    Quote Quote  
  12. Originally Posted by autodidact View Post
    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-support
    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.
    Quote Quote  
  13. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by Boxcart View Post
    Originally Posted by autodidact View Post
    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-support
    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
    Quote Quote  
  14. Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    Originally Posted by autodidact View Post
    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-support
    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?
    Quote Quote  
  15. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by Boxcart View Post
    Originally Posted by october262 View Post
    Originally Posted by Boxcart View Post
    Originally Posted by autodidact View Post
    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-support
    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.
    Quote Quote  
  16. Member
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Originally Posted by Boxcart View Post
    From the previous post is there an issue that the HEVC_NVENC is not working since it's producing an AVC output?
    You had this in your original command line:
    Code:
    -codec:v hevc_nvenc
    It is not in your current command line. This would give you gpu accelerated HEVC encoding. Without it or some other encoder like libx265, ffmpeg is probably using libx264 as default. HEVC is newer generation than AVC and is more commonly associated with HDR, though maybe not required.

    Some other parameters that may be required to preserve HDR:
    Code:
    -color_trc smpte2084 -color_primaries bt2020 -colorspace bt2020nc
    I'm not sure whether they should be used before your input or after.
    PB
    Quote Quote  
  17. 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
    I added all three color metadata tags/commands that autodidact suggested above, but "-colorspace bt2020nc" caused the video to be too dark and "-color_primaries bt2020" caused it to be too red so I removed those two. It now looks reference quality sharp, with good color, albeit still no HDR metadata in the output file according to MediaInfo, but the video looks pretty close to HDR, though with no metadata to tell the display to enable HDR. For reference there was also no HDR metadata showing in MediaInfo when the 2 other color commands were present. Perhaps it's possible to just add the HDR metadata to the output file with something like MKVToolNix? I'm not sure how to do that though.

    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"
    to the code above to fix the Blackmagic Design swapped LFE/center channel problem, which results in this error which prevents the recording from starting:

    "[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 16:15.
    Quote Quote  
  18. 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
    Quote Quote  
  19. 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
    Any idea how to add container-level HDR metadata? That's the last hurdle to overcome and then I have a 100% working setup.

    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
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!