Signed-off-by: Matthias Hunstock <atze@fem.tu-ilmenau.de> Signed-off-by: Marton Balint <cus@passwd.hu>tags/n3.3
| @@ -233,6 +233,12 @@ Defaults to @option{false}. | |||||
| If set to @option{true}, print a list of supported formats and exit. | If set to @option{true}, print a list of supported formats and exit. | ||||
| Defaults to @option{false}. | Defaults to @option{false}. | ||||
| @item format_code <FourCC> | |||||
| This sets the input video format to the format given by the FourCC. To see | |||||
| the supported values of your device(s) use @option{list_formats}. | |||||
| Note that there is a FourCC @option{'pal '} that can also be used | |||||
| as @option{pal} (3 letters). | |||||
| @item bm_v210 | @item bm_v210 | ||||
| If set to @samp{1}, video is captured in 10 bit v210 instead | If set to @samp{1}, video is captured in 10 bit v210 instead | ||||
| of uyvy422. Not all Blackmagic devices support this option. | of uyvy422. Not all Blackmagic devices support this option. | ||||
| @@ -296,21 +302,21 @@ ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro' | |||||
| @end example | @end example | ||||
| @item | @item | ||||
| Capture video clip at 1080i50 (format 11): | |||||
| Capture video clip at 1080i50: | |||||
| @example | @example | ||||
| ffmpeg -f decklink -i 'Intensity Pro@@11' -acodec copy -vcodec copy output.avi | |||||
| ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' -acodec copy -vcodec copy output.avi | |||||
| @end example | @end example | ||||
| @item | @item | ||||
| Capture video clip at 1080i50 10 bit: | Capture video clip at 1080i50 10 bit: | ||||
| @example | @example | ||||
| ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi | |||||
| ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi | |||||
| @end example | @end example | ||||
| @item | @item | ||||
| Capture video clip at 1080i50 with 16 audio channels: | Capture video clip at 1080i50 with 16 audio channels: | ||||
| @example | @example | ||||
| ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi | |||||
| ffmpeg -channels 16 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi | |||||
| @end example | @end example | ||||
| @end itemize | @end itemize | ||||
| @@ -33,6 +33,7 @@ extern "C" { | |||||
| #include "libavformat/avformat.h" | #include "libavformat/avformat.h" | ||||
| #include "libavformat/internal.h" | #include "libavformat/internal.h" | ||||
| #include "libavutil/imgutils.h" | #include "libavutil/imgutils.h" | ||||
| #include "libavutil/intreadwrite.h" | |||||
| #include "libavutil/bswap.h" | #include "libavutil/bswap.h" | ||||
| } | } | ||||
| @@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, | |||||
| int i = 1; | int i = 1; | ||||
| HRESULT res; | HRESULT res; | ||||
| av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, mode number %d\n", | |||||
| width, height, tb_num, tb_den, field_order, direction, num); | |||||
| av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, mode number %d, format code %s\n", | |||||
| width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)"); | |||||
| if (ctx->duplex_mode) { | if (ctx->duplex_mode) { | ||||
| DECKLINK_BOOL duplex_supported = false; | DECKLINK_BOOL duplex_supported = false; | ||||
| @@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, | |||||
| return AVERROR(EIO); | return AVERROR(EIO); | ||||
| } | } | ||||
| char format_buf[] = " "; | |||||
| if (cctx->format_code) | |||||
| memcpy(format_buf, cctx->format_code, FFMIN(strlen(cctx->format_code), sizeof(format_buf))); | |||||
| BMDDisplayMode target_mode = (BMDDisplayMode)AV_RB32(format_buf); | |||||
| AVRational target_tb = av_make_q(tb_num, tb_den); | AVRational target_tb = av_make_q(tb_num, tb_den); | ||||
| ctx->bmd_mode = bmdModeUnknown; | ctx->bmd_mode = bmdModeUnknown; | ||||
| while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) { | while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) { | ||||
| BMDTimeValue bmd_tb_num, bmd_tb_den; | BMDTimeValue bmd_tb_num, bmd_tb_den; | ||||
| int bmd_width = mode->GetWidth(); | int bmd_width = mode->GetWidth(); | ||||
| int bmd_height = mode->GetHeight(); | int bmd_height = mode->GetHeight(); | ||||
| BMDDisplayMode bmd_mode = mode->GetDisplayMode(); | |||||
| BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance(); | BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance(); | ||||
| mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den); | mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den); | ||||
| @@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, | |||||
| if ((bmd_width == width && | if ((bmd_width == width && | ||||
| bmd_height == height && | bmd_height == height && | ||||
| !av_cmp_q(mode_tb, target_tb) && | !av_cmp_q(mode_tb, target_tb) && | ||||
| field_order_eq(field_order, bmd_field_dominance)) || i == num) { | |||||
| ctx->bmd_mode = mode->GetDisplayMode(); | |||||
| field_order_eq(field_order, bmd_field_dominance)) | |||||
| || i == num | |||||
| || target_mode == bmd_mode) { | |||||
| ctx->bmd_mode = bmd_mode; | |||||
| ctx->bmd_width = bmd_width; | ctx->bmd_width = bmd_width; | ||||
| ctx->bmd_height = bmd_height; | ctx->bmd_height = bmd_height; | ||||
| ctx->bmd_tb_den = bmd_tb_den; | ctx->bmd_tb_den = bmd_tb_den; | ||||
| @@ -47,6 +47,7 @@ struct decklink_cctx { | |||||
| int audio_input; | int audio_input; | ||||
| int video_input; | int video_input; | ||||
| int draw_bars; | int draw_bars; | ||||
| char *format_code; | |||||
| }; | }; | ||||
| #endif /* AVDEVICE_DECKLINK_COMMON_C_H */ | #endif /* AVDEVICE_DECKLINK_COMMON_C_H */ | ||||
| @@ -539,9 +539,10 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) | |||||
| goto error; | goto error; | ||||
| } | } | ||||
| if (mode_num > 0) { | |||||
| if (mode_num > 0 || cctx->format_code) { | |||||
| if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) { | if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname); | |||||
| av_log(avctx, AV_LOG_ERROR, "Could not set mode number %d or format code %s for %s\n", | |||||
| mode_num, (cctx->format_code) ? cctx->format_code : "(unset)", fname); | |||||
| ret = AVERROR(EIO); | ret = AVERROR(EIO); | ||||
| goto error; | goto error; | ||||
| } | } | ||||
| @@ -31,6 +31,7 @@ | |||||
| static const AVOption options[] = { | static const AVOption options[] = { | ||||
| { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | ||||
| { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | ||||
| { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC }, | |||||
| { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, | ||||
| { "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"}, | ||||
| @@ -29,7 +29,7 @@ | |||||
| #define LIBAVDEVICE_VERSION_MAJOR 57 | #define LIBAVDEVICE_VERSION_MAJOR 57 | ||||
| #define LIBAVDEVICE_VERSION_MINOR 3 | #define LIBAVDEVICE_VERSION_MINOR 3 | ||||
| #define LIBAVDEVICE_VERSION_MICRO 100 | |||||
| #define LIBAVDEVICE_VERSION_MICRO 101 | |||||
| #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ | #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ | ||||
| LIBAVDEVICE_VERSION_MINOR, \ | LIBAVDEVICE_VERSION_MINOR, \ | ||||