Commit e9025573 authored by Matthias Hunstock's avatar Matthias Hunstock Committed by Marton Balint

decklink: support all valid numbers of audio channels

As it is already written in the documentation, BMD DeckLink cards
are capable of capturing 2, 8 or 16 audio channels (for SDI Inputs).
Currently the value is hardcoded to 2. Introduces new option.
Reviewed-by: 's avatarDeti Fliegl <deti@fliegl.de>
Signed-off-by: 's avatarMatthias Hunstock <atze@fem.tu-ilmenau.de>
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 5fc310f7
...@@ -218,7 +218,8 @@ On Windows, you need to run the IDL files through @command{widl}. ...@@ -218,7 +218,8 @@ On Windows, you need to run the IDL files through @command{widl}.
DeckLink is very picky about the formats it supports. Pixel format is DeckLink is very picky about the formats it supports. Pixel format is
uyvy422 or v210, framerate and video size must be determined for your device with uyvy422 or v210, framerate and video size must be determined for your device with
@command{-list_formats 1}. Audio sample rate is always 48 kHz and the number @command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
of channels can be 2, 8 or 16. of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single
audio track.
@subsection Options @subsection Options
...@@ -246,6 +247,10 @@ can use the special @option{all} constant to select all possible lines, or ...@@ -246,6 +247,10 @@ can use the special @option{all} constant to select all possible lines, or
receivers. Capturing teletext only works for SD PAL sources in 8 bit mode. receivers. Capturing teletext only works for SD PAL sources in 8 bit mode.
To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}. To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}.
@item channels
Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}.
Defaults to @samp{2}.
@end table @end table
@subsection Examples @subsection Examples
...@@ -276,6 +281,12 @@ Capture video clip at 1080i50 10 bit: ...@@ -276,6 +281,12 @@ Capture video clip at 1080i50 10 bit:
ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
@end example @end example
@item
Capture video clip at 1080i50 with 16 audio channels:
@example
ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
@end example
@end itemize @end itemize
@section dshow @section dshow
......
...@@ -33,6 +33,7 @@ struct decklink_cctx { ...@@ -33,6 +33,7 @@ struct decklink_cctx {
int64_t teletext_lines; int64_t teletext_lines;
double preroll; double preroll;
int v210; int v210;
int audio_channels;
}; };
#endif /* AVDEVICE_DECKLINK_COMMON_C_H */ #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
...@@ -466,6 +466,17 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ...@@ -466,6 +466,17 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
} }
#endif #endif
/* Check audio channel option for valid values: 2, 8 or 16 */
switch (cctx->audio_channels) {
case 2:
case 8:
case 16:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n");
return AVERROR(EINVAL);
}
iter = CreateDeckLinkIteratorInstance(); iter = CreateDeckLinkIteratorInstance();
if (!iter) { if (!iter) {
av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
...@@ -543,7 +554,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ...@@ -543,7 +554,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE; st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codec->sample_rate = bmdAudioSampleRate48kHz; st->codec->sample_rate = bmdAudioSampleRate48kHz;
st->codec->channels = 2; st->codec->channels = cctx->audio_channels;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
ctx->audio_st=st; ctx->audio_st=st;
...@@ -587,7 +598,8 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ...@@ -587,7 +598,8 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
ctx->teletext_st = st; ctx->teletext_st = st;
} }
result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2); av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codec->channels);
result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codec->channels);
if (result != S_OK) { if (result != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n"); av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
......
...@@ -35,6 +35,7 @@ static const AVOption options[] = { ...@@ -35,6 +35,7 @@ static const AVOption options[] = {
{ "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"}, { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
{ "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"}, { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
{ "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"}, { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"},
{ "channels", "number of audio channels", OFFSET(audio_channels), AV_OPT_TYPE_INT , { .i64 = 2 }, 2, 16, DEC },
{ NULL }, { NULL },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment