Another dive down the ffmpeg rathole

Lazyweb: how do I get video out of a Blackmagic UltraStudio MiniRecorder using ffmpeg on a Mac?

I tried this once before and gave up, but I'm trying again.

I am attempting this because Flash Media Live Encoder is a piece of shit, and maybe ffmpeg is less of a piece of shit. Har har har.

Flash Media Live Encoder is successfully reading video from this device, and it is configured to read 1280x720 video @ 60 FPS. I believe that that's the only configuration that works.

ffmpeg 3.0.2 sees the AVFoundation devices:

    % ffmpeg -list_devices true -f avfoundation -i ''
    ...
    [AVFoundation input device @ 0x7fc879430480] AVFoundation video devices:
    [AVFoundation input device @ 0x7fc879430480] [0] Blackmagic
    [AVFoundation input device @ 0x7fc879430480] [1] Capture screen 0
    [AVFoundation input device @ 0x7fc879430480] AVFoundation audio devices:
    [AVFoundation input device @ 0x7fc879430480] [0] Blackmagic Audio
    [AVFoundation input device @ 0x7fc879430480] [1] Built-in Input

If I do the following, I get an MP4 file that has audio read from the system's line-in, and has video in it, but the video is black:

    ffmpeg -f avfoundation \
    -video_size 1920x1080 -framerate 30 \
    -i Blackmagic:Built-in \
    -r 16 -t 3 -pix_fmt yuv420p out.mp4

It describes the input as:

    Input #0, avfoundation, from 'Blackmagic:Built-in':
      Duration: N/A, start: 9940065.201200, bitrate: N/A
        Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 1000k tbr, 1000k tbn, 1000k tbc

But if I do "-video_size 1280x720 -framerate 60", which is what FMLE is configured to use, I get this:

    [avfoundation @ 0x7fc7db813800] decoding for stream 0 failed
    [avfoundation @ 0x7fc7db813800] Could not find codec parameters for stream 0 (Video: rawvideo (UYVY / 0x59565955), uyvy422): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, avfoundation, from 'Blackmagic:Built-in':
      Duration: N/A, start: 9939377.616689, bitrate: N/A
        Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
        Stream #0:1: Audio: pcm_f32le, 44100 Hz, stereo, flt, 2822 kb/s
    [buffer @ 0x7fc7dc4129c0] Unable to parse option value "0x0" as image size
        Last message repeated 1 times
        Last message repeated 1 times
    [buffer @ 0x7fc7dc4129c0] Error setting option video_size to value 0x0.

If I specify a bogus frame rate, I can get it to show me the list:

    [avfoundation @ 0x7fd893813800] Supported modes:
    [avfoundation @ 0x7fd893813800] 720x486@[29.970030 29.970030]fps
    [avfoundation @ 0x7fd893813800] 720x486@[23.976024 23.976024]fps
    [avfoundation @ 0x7fd893813800] 720x486@[59.940060 59.940060]fps
    [avfoundation @ 0x7fd893813800] 720x576@[25.000000 25.000000]fps
    [avfoundation @ 0x7fd893813800] 720x576@[50.000000 50.000000]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[23.976024 23.976024]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[24.000000 24.000000]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[25.000000 25.000000]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[29.970030 29.970030]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[30.000000 30.000000]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[25.000000 25.000000]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[29.970030 29.970030]fps
    [avfoundation @ 0x7fd893813800] 1920x1080@[30.000000 30.000000]fps
    [avfoundation @ 0x7fd893813800] 1280x720@[50.000000 50.000000]fps
    [avfoundation @ 0x7fd893813800] 1280x720@[59.940060 59.940060]fps
    [avfoundation @ 0x7fd893813800] 1280x720@[60.000000 60.000000]fps
Tags: , , ,

8 Responses:

  1. someguy says:

    Slightly-less-lazy web suggests adding one of these to your command line might help, to give ffmpeg more data to try and analyze the stream:

    -analyzeduration 5000 -probesize 20000
    -analyzeduration 100M -probesize 100M
    -analyzeduration 1G -probesize 1G

    ... and other various combinations of sizes.

    Other suggestions out there include trying to enable+use the ffmpeg 'decklink' module that speaks some BlackMagic proprietary protocol directly (which may include recompiling ffpmeg, ugh), or possibly using this other streaming software instead of ffmpeg that might speak decklink natively.

    I don't have your exact hardware of course so take all this with a big heaping of YMMV. Apologies if you'd tried any of these before, but didn't see any indication you had in your previous posts.

    • jwz says:

      None of those made it go (though the last one took like ten minutes to fail).

      I didn't realize "decklink" worked on all BM devices. I was gonna recompile ffmpeg and give that a shot, but I can't find the decklink SDK -- all references are to dead links on blackmagic.com. Hooray.

    • jwz says:

      I haven't bothered playing with OBS because as far as I can tell, it's GUI only, and that makes it useless to me. This crap has to run 24/7 unattended.

  2. Ben says:

    FWIW, I use bmdtools:
    https://github.com/lu-zero/bmdtools

    It requires the blackmagic SDK to build, although you probably have that if you're building ffmpeg with decklink.

    I use this command line to capture 1280x720 from a minirecorder to create a 512kbps HLS stream:


    bmdcapture -m 8 -F nut -f pipe:1 -V 3 | ffmpeg \
    -threads 6 -y -i - \
    -c:v libx264 \
    -analyzeduration 10000000 -probesize 100 \
    -b:v 512k -r 29.97 -profile main -preset fast -x264opts level=41 \
    -threads 4 -s 1280x720 -map 0:v \
    -pix_fmt yuv420p \
    -map 0:a \
    -acodec libfaac -ab 48k -ar 44100 \
    -flags +global_header \
    -f segment \
    -segment_time 10 \
    -segment_list stream_hls.m3u8 \
    -segment_list_flags +live \
    -segment_list_entry_prefix http://example.com/stream/ \
    -segment_format mpegts seg_%05d.ts

    I did have an issue with A/V sync, not sure where it's coming from. I think there's an option in ffmpeg to correct for it but I haven't looked in to it.

    This runs on a late 2013 rMBP with a quad i7, you'd probably need to tweak threads for different processors.

  3. random eyeballz says:

    ...well just all WWW staff is just obsolete piece of sh*t *^_^*