History

avdevice/decklink: new option 'format_code' to set video format by fourCC

Matthias Hunstock committed 9 years ago

Commit b3a2ada1 parent 607bffb6 files · +28 −11Browse files

Unified · Split

6 files
  1. doc/indevs.texi +10 −4
  2. libavdevice/decklink_common.cpp +12 −4
  3. libavdevice/decklink_common_c.h +1 −0
  4. libavdevice/decklink_dec.cpp +3 −2
  5. libavdevice/decklink_dec_c.c +1 −0
  6. libavdevice/version.h +1 −1
doc/indevs.texi+10−4
@@ -233,6 +233,12 @@ Defaults to @option{false}. · 232 unmodified lines
233233 If set to @option{true}, print a list of supported formats and exit.
234234 Defaults to @option{false}.
235235
236+@item format_code <FourCC>
237+This sets the input video format to the format given by the FourCC. To see
238+the supported values of your device(s) use @option{list_formats}.
239+Note that there is a FourCC @option{'pal '} that can also be used
240+as @option{pal} (3 letters).
241+
236242 @item bm_v210
237243 If set to @samp{1}, video is captured in 10 bit v210 instead
238244 of uyvy422. Not all Blackmagic devices support this option.
@@ -296,21 +302,21 @@ ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro' · 57 unmodified lines
296302 @end example
297303
298304 @item
299−Capture video clip at 1080i50 (format 11):
305+Capture video clip at 1080i50:
300306 @example
301−ffmpeg -f decklink -i 'Intensity Pro@@11' -acodec copy -vcodec copy output.avi
307+ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' -acodec copy -vcodec copy output.avi
302308 @end example
303309
304310 @item
305311 Capture video clip at 1080i50 10 bit:
306312 @example
307−ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
313+ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
308314 @end example
309315
310316 @item
311317 Capture video clip at 1080i50 with 16 audio channels:
312318 @example
313−ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
319+ffmpeg -channels 16 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
314320 @end example
315321
316322 @end itemize
libavdevice/decklink_common.cpp+12−4
@@ -33,6 +33,7 @@ extern "C" { · 32 unmodified lines
3333 #include "libavformat/avformat.h"
3434 #include "libavformat/internal.h"
3535 #include "libavutil/imgutils.h"
36+#include "libavutil/intreadwrite.h"
3637 #include "libavutil/bswap.h"
3738 }
3839
@@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 119 unmodified lines
158159 int i = 1;
159160 HRESULT res;
160161
161− 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",
162− width, height, tb_num, tb_den, field_order, direction, num);
162+ 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",
163+ width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
163164
164165 if (ctx->duplex_mode) {
165166 DECKLINK_BOOL duplex_supported = false;
@@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 30 unmodified lines
196197 return AVERROR(EIO);
197198 }
198199
200+ char format_buf[] = " ";
201+ if (cctx->format_code)
202+ memcpy(format_buf, cctx->format_code, FFMIN(strlen(cctx->format_code), sizeof(format_buf)));
203+ BMDDisplayMode target_mode = (BMDDisplayMode)AV_RB32(format_buf);
199204 AVRational target_tb = av_make_q(tb_num, tb_den);
200205 ctx->bmd_mode = bmdModeUnknown;
201206 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
202207 BMDTimeValue bmd_tb_num, bmd_tb_den;
203208 int bmd_width = mode->GetWidth();
204209 int bmd_height = mode->GetHeight();
210+ BMDDisplayMode bmd_mode = mode->GetDisplayMode();
205211 BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();
206212
207213 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
@@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines
210216 if ((bmd_width == width &&
211217 bmd_height == height &&
212218 !av_cmp_q(mode_tb, target_tb) &&
213− field_order_eq(field_order, bmd_field_dominance)) || i == num) {
214− ctx->bmd_mode = mode->GetDisplayMode();
219+ field_order_eq(field_order, bmd_field_dominance))
220+ || i == num
221+ || target_mode == bmd_mode) {
222+ ctx->bmd_mode = bmd_mode;
215223 ctx->bmd_width = bmd_width;
216224 ctx->bmd_height = bmd_height;
217225 ctx->bmd_tb_den = bmd_tb_den;
libavdevice/decklink_common_c.h+1−0
@@ -47,6 +47,7 @@ struct decklink_cctx { · 46 unmodified lines
4747 int audio_input;
4848 int video_input;
4949 int draw_bars;
50+ char *format_code;
5051 };
5152
5253 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
libavdevice/decklink_dec.cpp+3−2
@@ -539,9 +539,10 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 538 unmodified lines
539539 goto error;
540540 }
541541
542− if (mode_num > 0) {
542+ if (mode_num > 0 || cctx->format_code) {
543543 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
544− av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
544+ av_log(avctx, AV_LOG_ERROR, "Could not set mode number %d or format code %s for %s\n",
545+ mode_num, (cctx->format_code) ? cctx->format_code : "(unset)", fname);
545546 ret = AVERROR(EIO);
546547 goto error;
547548 }
libavdevice/decklink_dec_c.c+1−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 static const AVOption options[] = {
3232 { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
3333 { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
34+ { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
3435 { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
3536 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
3637 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
libavdevice/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVDEVICE_VERSION_MAJOR 57
3131 #define LIBAVDEVICE_VERSION_MINOR 3
32−#define LIBAVDEVICE_VERSION_MICRO 100
32+#define LIBAVDEVICE_VERSION_MICRO 101
3333
3434 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
3535 LIBAVDEVICE_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t