使用 ffmpeg、ubuntu 在 decklink 上转换流输出

使用 ffmpeg、ubuntu 在 decklink 上转换流输出

转贴于黑魔法

设备:DeckLink SDI

Ubuntu 22.04

使用 gcc 11 构建的 ffmpeg 版本 6.0(Ubuntu 11.4.0-1ubuntu1~22.04)

Decklink SDK 12.7

我能够成功地将本地文件播放到 decklink 卡,但我们最终希望能够通过 decklink 播放 HLS 流。

supervisor@hls-playback:~$ ffmpeg -I 'sample.mp4' -f decklink -pix_fmt uyvy422 'DeckLink SDI'
ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/home/supervisor/ffmpeg_build --pkg-config-flags=--static --extra-cflags='-I/home/supervisor/ffmpeg_build/include -I/home/supervisor/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-L/home/supervisor/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/supervisor/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-openssl --enable-decklink
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2023-09-21T23:35:44.000000Z
  Duration: 00:54:25.40, start: 0.000000, bitrate: 20262 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 19939 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
    Metadata:
      creation_time   : 2023-09-21T23:35:44.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
    Metadata:
      creation_time   : 2023-09-21T23:35:45.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[decklink @ 0x559e49d08dc0] Found Decklink mode 1920 x 1080 with rate 29.97
Output #0, decklink, to 'DeckLink SDI':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    encoder         : Lavf60.3.100
  Stream #0:0(eng): Video: wrapped_avframe, uyvy422(tv, bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn (default)
    Metadata:
      creation_time   : 2023-09-21T23:35:44.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 wrapped_avframe
  Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2023-09-21T23:35:45.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 pcm_s16le
frame=  451 fps= 31 q=-0.0 Lsize=N/A time=00:00:15.01 bitrate=N/A speed=1.04x    0x   
video:211kB audio:2816kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

但当我尝试播放直播流时,出现了错误:[decklink @ 0x56068cecf500] 不支持的视频大小、帧速率或场序!使用 -list_formats 1 检查可用格式。[out#0/decklink @ 0x56068ced1980] 无法写入标题(编解码器参数不正确?):输入/输出错误 [aost#0:1/pcm_s16le @ 0x56068cfa7280] 初始化输出流时出错:转换失败!

supervisor@hls-playback:~$ ffmpeg -i https://sampleurl.com/index_1.m3u8 -f decklink -pix_fmt uyvy422 'DeckLink SDI'
ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/home/supervisor/ffmpeg_build --pkg-config-flags=--static --extra-cflags='-I/home/supervisor/ffmpeg_build/include -I/home/supervisor/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-L/home/supervisor/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/supervisor/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-openssl --enable-decklink
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
[hls @ 0x56068cdc78c0] Skip ('#EXT-X-VERSION:3')
[hls @ 0x56068cdc78c0] Opening 'https://sampleurl.com/index_1_00009.ts' for reading
[hls @ 0x56068cdc78c0] Opening 'https://sampleurl.com/index_1_00010.ts' for reading
Input #0, hls, from 'https://sampleurl.com/index_1.m3u8':
  Duration: N/A, start: 98.300000, bitrate: N/A
  Program 0
    Metadata:
      variant_bitrate : 0
  Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn
    Metadata:
      variant_bitrate : 0
  Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
  Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[decklink @ 0x56068cecf500] Unsupported video size, framerate or field order! Check available formats with -list_formats 1.
[out#0/decklink @ 0x56068ced1980] Could not write header (incorrect codec parameters ?): Input/output error
[aost#0:1/pcm_s16le @ 0x56068cfa7280] Error initializing output stream:
Conversion failed!

-list_formats 输出:

ffmpeg -i https://sampleurl.com/index_1.m3u8 -f decklink -list_formats 1 'DeckLink SDI'
.
.
.
[decklink @ 0x55dbf177b5c0] Supported formats for 'DeckLink SDI':
   format_code   description
   ntsc      720x486 at 30000/1001 fps (interlaced, lower field first)
   nt23      720x486 at 24000/1001 fps
   pal       720x576 at 25000/1000 fps (interlaced, upper field first)
   23ps      1920x1080 at 24000/1001 fps
   24ps      1920x1080 at 24000/1000 fps
   Hp25      1920x1080 at 25000/1000 fps
   Hp29      1920x1080 at 30000/1001 fps
   Hp30      1920x1080 at 30000/1000 fps
   Hi50      1920x1080 at 25000/1000 fps (interlaced, upper field first)
   Hi59      1920x1080 at 30000/1001 fps (interlaced, upper field first)
   Hi60      1920x1080 at 30000/1000 fps (interlaced, upper field first)
   hp50      1280x720 at 50000/1000 fps
   hp59      1280x720 at 60000/1001 fps
   hp60      1280x720 at 60000/1000 fps

看来我的 720 30fps 流不受任何 DeckLink 卡支持。ffmpeg 是否可以在将输出发送到卡之前将流转换为兼容格式?

相关内容