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
233If set to @option{true}, print a list of supported formats and exit.233If set to @option{true}, print a list of supported formats and exit.
234Defaults to @option{false}.234Defaults to @option{false}.
235 235
236@item format_code <FourCC>
237This sets the input video format to the format given by the FourCC. To see
238the supported values of your device(s) use @option{list_formats}.
239Note that there is a FourCC @option{'pal '} that can also be used
240as @option{pal} (3 letters).
241
236@item bm_v210242@item bm_v210
237If set to @samp{1}, video is captured in 10 bit v210 instead243If set to @samp{1}, video is captured in 10 bit v210 instead
238of uyvy422. Not all Blackmagic devices support this option.244of uyvy422. Not all Blackmagic devices support this option.
@@ -296,21 +302,21 @@ ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro' · 57 unmodified lines
296@end example302@end example
297 303
298@item304@item
299Capture video clip at 1080i50 (format 11):305Capture video clip at 1080i50:
300@example306@example
301ffmpeg -f decklink -i 'Intensity Pro@@11' -acodec copy -vcodec copy output.avi307ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' -acodec copy -vcodec copy output.avi
302@end example308@end example
303 309
304@item310@item
305Capture video clip at 1080i50 10 bit:311Capture video clip at 1080i50 10 bit:
306@example312@example
307ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi313ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
308@end example314@end example
309 315
310@item316@item
311Capture video clip at 1080i50 with 16 audio channels:317Capture video clip at 1080i50 with 16 audio channels:
312@example318@example
313ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi319ffmpeg -channels 16 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
314@end example320@end example
315 321
316@end itemize322@end itemize
libavdevice/decklink_common.cpp+12−4
@@ -33,6 +33,7 @@ extern "C" { · 32 unmodified lines
33#include "libavformat/avformat.h"33#include "libavformat/avformat.h"
34#include "libavformat/internal.h"34#include "libavformat/internal.h"
35#include "libavutil/imgutils.h"35#include "libavutil/imgutils.h"
36#include "libavutil/intreadwrite.h"
36#include "libavutil/bswap.h"37#include "libavutil/bswap.h"
37}38}
38 39
@@ -158,8 +159,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 119 unmodified lines
158 int i = 1;159 int i = 1;
159 HRESULT res;160 HRESULT res;
160 161
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 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",
162 width, height, tb_num, tb_den, field_order, direction, num);163 width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
163 164
164 if (ctx->duplex_mode) {165 if (ctx->duplex_mode) {
165 DECKLINK_BOOL duplex_supported = false;166 DECKLINK_BOOL duplex_supported = false;
@@ -196,12 +197,17 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 30 unmodified lines
196 return AVERROR(EIO);197 return AVERROR(EIO);
197 }198 }
198 199
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);
199 AVRational target_tb = av_make_q(tb_num, tb_den);204 AVRational target_tb = av_make_q(tb_num, tb_den);
200 ctx->bmd_mode = bmdModeUnknown;205 ctx->bmd_mode = bmdModeUnknown;
201 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {206 while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
202 BMDTimeValue bmd_tb_num, bmd_tb_den;207 BMDTimeValue bmd_tb_num, bmd_tb_den;
203 int bmd_width = mode->GetWidth();208 int bmd_width = mode->GetWidth();
204 int bmd_height = mode->GetHeight();209 int bmd_height = mode->GetHeight();
210 BMDDisplayMode bmd_mode = mode->GetDisplayMode();
205 BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();211 BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();
206 212
207 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);213 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
@@ -210,8 +216,10 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 2 unmodified lines
210 if ((bmd_width == width &&216 if ((bmd_width == width &&
211 bmd_height == height &&217 bmd_height == height &&
212 !av_cmp_q(mode_tb, target_tb) &&218 !av_cmp_q(mode_tb, target_tb) &&
213 field_order_eq(field_order, bmd_field_dominance)) || i == num) {219 field_order_eq(field_order, bmd_field_dominance))
214 ctx->bmd_mode = mode->GetDisplayMode();220 || i == num
221 || target_mode == bmd_mode) {
222 ctx->bmd_mode = bmd_mode;
215 ctx->bmd_width = bmd_width;223 ctx->bmd_width = bmd_width;
216 ctx->bmd_height = bmd_height;224 ctx->bmd_height = bmd_height;
217 ctx->bmd_tb_den = bmd_tb_den;225 ctx->bmd_tb_den = bmd_tb_den;
libavdevice/decklink_common_c.h+1−0
@@ -47,6 +47,7 @@ struct decklink_cctx { · 46 unmodified lines
47 int audio_input;47 int audio_input;
48 int video_input;48 int video_input;
49 int draw_bars;49 int draw_bars;
50 char *format_code;
50};51};
51 52
52#endif /* AVDEVICE_DECKLINK_COMMON_C_H */53#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
539 goto error;539 goto error;
540 }540 }
541 541
542 if (mode_num > 0) {542 if (mode_num > 0 || cctx->format_code) {
543 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {543 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);
545 ret = AVERROR(EIO);546 ret = AVERROR(EIO);
546 goto error;547 goto error;
547 }548 }
libavdevice/decklink_dec_c.c+1−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
31static const AVOption options[] = {31static const AVOption options[] = {
32 { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },32 { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
33 { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },33 { "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 },
34 { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },35 { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
35 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},36 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
36 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},37 { "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
29 29
30#define LIBAVDEVICE_VERSION_MAJOR 5730#define LIBAVDEVICE_VERSION_MAJOR 57
31#define LIBAVDEVICE_VERSION_MINOR 331#define LIBAVDEVICE_VERSION_MINOR 3
32#define LIBAVDEVICE_VERSION_MICRO 10032#define LIBAVDEVICE_VERSION_MICRO 101
33 33
34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 LIBAVDEVICE_VERSION_MINOR, \35 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