确保decklink设备已经接入
lspci | grep Blackm
02:00.0 Multimedia video controller: Blackmagic Design DeckLink SDI
Micro
确保decklink驱动已经正确安装
lsmod | grep blackmagic
blackmagic_io 2068480 2
确保ffmpeg已经启用decklink,如何配置之前的博文已经提到。
ffmpeg -devices
DE alsa ALSA audio output DE decklink Blackmagic
DeckLink output
查看decklink在ffmpeg中对应的设备名称
ffmpeg -sources
或
ffmpeg -sources
Auto-detected sources for decklink: 92:a08498c0:00000000 [DeckLink
SDI Micro] (none)
查看ffmpeg支持decklink的各种参数
ffmpeg -h demuxer=decklink
ffmpeg官网上有decklink的参数解释
http://ffmpeg.org/ffmpeg-all.html#decklink-1
以下是伪代码:
AVDictionary *options = NULL;
// av_dict_set(&options, "video_size", "640x480", 0);
// av_dict_set(&options, "framerate", "30", 0);
// av_dict_set(&options, "pixel_format", "yuyv422,", 0);
// av_dict_set(&dict, "video_size", "1280*720", AV_DICT_MATCH_CASE);
// av_dict_set(&dict, "framerate", "10", AV_DICT_MATCH_CASE);
//以上参数如果不设置的话,就会用默认值,但默认值摄像头不一定支持
int re = avformat_open_input(&ic, "92:a08498c0:00000000", ifmt, &options);
if (re != 0)
{
printf("无法打开输入流\n");
ErrorFunc(re);
}
re = avformat_find_stream_info(ic, NULL);
int video_index = -1;
for (int i = 0; i < ic->nb_streams; i++)
{
if (ic->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
{
// ic->streams[i]->codecpar
video_index = i;
}
}
printf("ic->streams[i]->codecpar-W:%d\n", ic->streams[video_index]->codecpar->width);
printf("ic->streams[i]->codecpar-H:%d\n", ic->streams[video_index]->codecpar->height);
printf("ic->streams[i]->codecpar-F:%d\n", ic->streams[video_index]->avg_frame_rate);
程序打印如下:
[decklink @ 0x559c264d8f00] Autodetected the input mode [decklink @
0x559c264d8f00] Found Decklink mode 1280 x 720 with rate 60.00
ic->streams[i]->codecpar-W:1280 ic->streams[i]->codecpar-H:720
ic->streams[i]->codecpar-F:60