How to use ffmpeg to capture h264 for Resolve?

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 10:56 am

I have a Blackmagic Intensity Pro 4K I am using to capture video (lossless h264) with the following settings:

Code: Select all
ffmpeg -f decklink -i "Intensity Pro 4K@20" -acodec copy -vcodec libx264  -preset ultrafast -crf 0  bmagicoutput1.mov


I did this based on the following documentation:
ffmpeg decklink: https://www.ffmpeg.org/ffmpeg-devices.html#decklink

Stack Overflow post on ffmpeg hd settings:
http://stackoverflow.com/questions/1921 ... 20p-from-d

After capturing the video, I can play it back in VLC fine.

However, when I add it to the media pool in Resolve, it immediately shows up as "Media offline."

How can I get Resolve to work with these files? Or, how can I configure ffmpeg to output in a format that Resolve understands?
Offline

Andrew Kolakowski

  • Posts: 5296
  • Joined: Tue Sep 11, 2012 10:20 am

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 1:48 pm

It's because your h264 is 4:2:2 which Resolve does not support. BM sends YUV 4:2:2 signal which then is compressed.

ffmpeg -f decklink -i "Intensity Pro 4K@20" -pix_fmt yuv420p -c:a copy -c:v libx264 -g 1 -preset ultrafast -crf 0 bmagicoutput1.mov

-g 1 creates I frames only file, which should be easier for scrubbing.

You need to force 4:2:0 pixel format, but CRF=0 creates lossless file, which even at 4:2:0 is not supported by Resolve (at least on Mac). You can change it to CRF=1 which will create very high bitrate h264 (extremely high quality but not lossless anymore) and this should work in Resolve.

You can also use ProRes or DNxHR instead of h264 or c:v copy for YUV uncompressed file.
-c:a, -c:v are current commands in ffmpeg, your way is a legacy.

More options for deckling device in ffmepg:
https://www.ffmpeg.org/ffmpeg-devices.html#decklink
if you want for example 10bit , or more audio channels.
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 5:04 pm

Ok, I see that I can't use CRF=0. I also had to add the -rtbufsize option like this:

Code: Select all
ffmpeg -rtbufsize 1500M -f decklink -i "Intensity Pro 4K@20" -pix_fmt yuv420p -c:a copy -c:v libx264 -g 1 -preset ultrafast -crf 1 bmagicoutput57.mov


When I do this, I can get a video that can be played back in Resolve, though playback is not smooth at all. To fix the jerky playback, I added the H264 file to Resolve and converted to DNxHR within Resolve.

If I force 4:2:0 pixel format, I can't get 10-bit, right? The whole reason I wanted to switch from Media Express to something else (ffmpeg) was to get reliable 10-bit without dropped frames.

I saw the 10-bit example in the ffmpeg documentation, but when I tried this command:

Code: Select all
ffmpeg -bm_v210 1 -rtbufsize 1500M -f decklink -i "Intensity Pro 4K@20" -pix_fmt yuv420p -c:a copy -c:v libx264 -g 1 -preset ultrafast -crf 1 bmagicoutput59.mov


the bit depth was still 8 bits according to MediaInfo.

About ProRes/DNxHR:

I'm on Windows, so unfortunately I can't use ProRes. As for DNxHR, ffmpeg does not currently support HQX/444, so the only codecs available are 8-bit:
http://video.stackexchange.com/a/20434/5349
Offline

Andrew Kolakowski

  • Posts: 5296
  • Joined: Tue Sep 11, 2012 10:20 am

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 5:25 pm

h264 can be 10bit (4:2:0, 4:2:2 and even 4:4:4), but you need ffmpeg build with 10bit x264- this is done during compilation (you have to compile yourself or find build on the net). Resolve won't support it anyway.

You can use ProRes- why not? Resolve will decode it fine on PC.

ffmpeg -bm_v210 1 -rtbufsize 1500M -f decklink -i "Intensity Pro 4K@20" -c:a copy -c:v prores -profile:v 3 bmagicoutput59.mov

This will do ProResHQ and it will preserve 10bit. You will need fast machine for this.
-c:v v210 will do 4:2:2 10bit uncompressed, which is very well supported in many apps.

Yes, DNxHR HQX is not yet implemented.
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 6:16 pm

Thank you for the very detailed explanation. I didn't realize ProRes could be encoded with ffmpeg on Windows.

Unfortunately, it seems ProRes encoding is beyond the capabilities of my machine, as I keep getting "Decklink input buffer overrun", and the v210 works but the speed sometimes slightly falls below 1 and it chokes. So I will try to add another SSD to my system tomorrow (currently have two SSDs in a RAID 1 configuration) to see if that helps.
Offline
User avatar

Jean Claude

  • Posts: 2263
  • Joined: Sun Jun 28, 2015 4:41 pm
  • Location: France

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 6:21 pm

If it is possible: change for a raid 0? (Provided that it is not the OS disk)
Windows 10 PRO X64 1809 | DaVinci Resolve Studio 16.0.0B.022 | Fusion Studio 16.0.beta 24 build 24 | Decklink Studio 4K 6G | Desktop Video 11.1.00 | Nvidia 430.64
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 6:28 pm

Sorry, I mispoke. I already have a RAID 0 setup.
Offline
User avatar

Jean Claude

  • Posts: 2263
  • Joined: Sun Jun 28, 2015 4:41 pm
  • Location: France

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 6:33 pm

Hi Patrick,

I thought you were with a Raid 1. Sorry for misunderstanding.


Patrick Kenny wrote:Thank you for the very detailed explanation. I didn't realize ProRes could be encoded with ffmpeg on Windows.

Unfortunately, it seems ProRes encoding is beyond the capabilities of my machine, as I keep getting "Decklink input buffer overrun", and the v210 works but the speed sometimes slightly falls below 1 and it chokes. So I will try to add another SSD to my system tomorrow (currently have two SSDs in a RAID 1 configuration) to see if that helps.
Windows 10 PRO X64 1809 | DaVinci Resolve Studio 16.0.0B.022 | Fusion Studio 16.0.beta 24 build 24 | Decklink Studio 4K 6G | Desktop Video 11.1.00 | Nvidia 430.64
Offline

Andrew Kolakowski

  • Posts: 5296
  • Joined: Tue Sep 11, 2012 10:20 am

Re: How to use ffmpeg to capture h264 for Resolve?

PostSat Jan 28, 2017 7:58 pm

Patrick Kenny wrote:Thank you for the very detailed explanation. I didn't realize ProRes could be encoded with ffmpeg on Windows.

Unfortunately, it seems ProRes encoding is beyond the capabilities of my machine, as I keep getting "Decklink input buffer overrun", and the v210 works but the speed sometimes slightly falls below 1 and it chokes. So I will try to add another SSD to my system tomorrow (currently have two SSDs in a RAID 1 configuration) to see if that helps.


UHD 30p v210 is 670MB/sec, so 2x SSDs (decent) should be fine.
I don't think you need this -rtbufsize. It's when you use directshow, but your are not doing it (using low level BM support).
Try without rtbufsize+v210 codec. You may be also better with older BM drivers. They seams to be getting worse and worse :)
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostSun Jan 29, 2017 7:26 pm

@Jean Claude: Yes, I described my setup incorrectly. So, I apologized for my mistake.

@Andrew Kolakowski:

After testing, I do need the -rtbufsize. Without it, I almost immediately get a "Decklink input buffer overrun" error.

I will try the older BM drivers later.

Testing today, I found that my SSDs are too slow. I get "Decklink input buffer overrun" errors after 30-120 seconds of capture (I'm trying to capture about 20 minutes of video at a time), and when ffmpeg fails in this manner, the capture file will only play back up until the point of failure; I haven't been able to find a way to get ffmpeg to just drop the frames and move on.

Running the Blackmagic Speed Test, I can get 900 MB/s sometimes, but other times I only get 350 MB/sec. It's very inconsistent. I'm new to using RAID so I will have to learn more about what could be going wrong.

The two SSDs I have set up in RAID 0 are a 960GB Sandisk Ultra II (https://www.sandisk.com/home/ssd/ultra-ii-ssd) and a 960GB Sandisk Extreme Pro (https://www.sandisk.com/home/ssd/ultra-ii-ssd), both of which the manufacturer claims can do sequential writes up to 500 MB/s.

The two drives are about 50% full at this time.
Offline

Andrew Kolakowski

  • Posts: 5296
  • Joined: Tue Sep 11, 2012 10:20 am

Re: How to use ffmpeg to capture h264 for Resolve?

PostSun Jan 29, 2017 7:57 pm

Don't mix SSD types, better to stick to the same model. Sometimes even different firmware may cause issues (specially with hardware controllers).
Is it software raid or hardware? Try simple stripe in Windows.
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostMon Jan 30, 2017 5:27 am

It's a software RAID. I made it as a simple stripe in Windows 10.

Unfortunately, I don't have two identical SSDs lying around-- I have the two Sandisk SSDs of the same size, but they are different generations.

I totally forgot about SSD firmware. I installed the firmware update utility and realized, in addition to firmware updates, TRIM was not enabled, so there may be some things I can do to get better performance if I experiment with those settings.
Offline

Patrick Kenny

  • Posts: 65
  • Joined: Mon Nov 28, 2016 4:38 am
  • Location: US

Re: How to use ffmpeg to capture h264 for Resolve?

PostWed Feb 01, 2017 6:19 pm

After continuing to try many different things, I finally figured out that my SSD was just too slow.

I was able to get a steady 29.97fps in ffmpeg with prores by switching from version 3 (HQ) to 2 (standard). Standard quality is sufficient for my purposes.

Andrew thank you so much for helping me through this. I wouldn't have been able to get such a good solution so quickly on my own.
Offline

jendabek

  • Posts: 2
  • Joined: Thu Feb 16, 2017 1:14 pm

Re: How to use ffmpeg to capture h264 for Resolve?

PostFri Feb 17, 2017 10:12 pm

Hello, is this also the reason why it shows Media offline when importing a video recorded by OBS Studio?
Do you think some x264 encoding options could help? What should I try?

Thank you!

Return to DaVinci Resolve

Who is online

Users browsing this forum: mattpf, neelan2001 and 45 guests