MacOS下FFmpeg Decklink采集BlackMagic设备,如何实现本地预览?
Nice to hear your DeckLink to YouTube stream is working smoothly—adding a local preview is a common need, and FFmpeg has a couple of solid ways to pull this off. Let’s walk through two methods tailored for your macOS setup:
Method 1: Single Command with the Tee Muxer
The tee muxer lets you route your processed video to both YouTube and a local preview window in one go. This keeps things clean and avoids running separate FFmpeg instances. Update your command to this:
ffmpeg -f decklink -format_code 'Hi50' -i 'UltraStudio Express' -deinterlace \ -b:v 1M -vcodec h264 -pix_fmt yuv420p -color_range 1 -acodec aac \ -f tee "[f=flv]rtmp://a.rtmp.youtube.com/live2/*******|[f=nut]pipe:1" | ffplay -f nut -
Breakdown of the changes:
- The
teemuxer splits the stream into two destinations: your existing YouTube RTMP endpoint, and a pipe using the lightweight NUT container (ideal for real-time streaming). ffplayreads directly from the pipe and opens a preview window instantly.- This works on macOS as long as you have
ffplayinstalled (it’s included with most DeckLink-enabled FFmpeg builds—verify withffplay -versionif you’re unsure).
Method 2: Separate SDL Preview Output
If you prefer a more straightforward setup without pipes, you can add a second output that sends the video to a local SDL window. Here’s how to adjust your command:
ffmpeg -f decklink -format_code 'Hi50' -i 'UltraStudio Express' -deinterlace \ # YouTube stream (unchanged from your original command) -b:v 1M -vcodec h264 -pix_fmt yuv420p -color_range 1 -acodec aac -f flv rtmp://a.rtmp.youtube.com/live2/******* \ # Local preview output -vcodec rawvideo -pix_fmt uyvy422 -f sdl "BlackMagic Capture Preview"
Breakdown:
- The first output block is exactly your working YouTube stream—no changes needed here.
- The second output uses
rawvideo(no compression, minimal latency) withuyvy422(a pixel format that plays nicely with DeckLink captures) and sends it to an SDL window labeled "BlackMagic Capture Preview". - SDL is lightweight, so the preview will pop up quickly with very little delay, perfect for monitoring your feed.
Quick macOS Tips:
- Ensure your FFmpeg build has SDL support: run
ffmpeg -formats | grep sdl—if you seeSDLlisted, you’re good to go. - If you notice preview latency, try temporarily removing
-deinterlaceto test (you can re-add it once you confirm the preview works, since Hi50 requires deinterlacing for proper playback). - For the tee method, if pipes give you trouble, replace
pipe:1with a temporary file path like/tmp/preview_stream.nutand runffplay /tmp/preview_stream.nutin a separate terminal window—pipes are cleaner, but this is a reliable fallback.
内容的提问来源于stack exchange,提问作者Манаф Иракский
相关产品推荐
相关产品推荐

