History

ffmpeg: accept + prefix to -pix_fmt option to disable automatic conversions.

Nicolas George committed 14 years ago

Commit 9cf5bcd1 parent 440af103 files · +28 −0Browse files

Unified · Split

3 files
  1. Changelog +1 −0
  2. doc/ffmpeg.texi +8 −0
  3. ffmpeg.c +19 −0
Changelog+1−0
@@ -29,6 +29,7 @@ version next: · 28 unmodified lines
2929 - add libavresample audio conversion library for compatibility
3030 - MicroDVD decoder
3131 - Avid Meridien (AVUI) decoder
32+- accept + prefix to -pix_fmt option to disable automatic conversions.
3233
3334
3435 version 0.10:
doc/ffmpeg.texi+8−0
@@ -418,6 +418,14 @@ also sources and sinks). This is an alias for @code{-filter:v}. · 417 unmodified lines
418418 @item -pix_fmt[:@var{stream_specifier}] @var{format} (@emph{input/output,per-stream})
419419 Set pixel format. Use @code{-pix_fmts} to show all the supported
420420 pixel formats.
421+If the selected pixel format can not be selected, ffmpeg will print a
422+warning and select the best pixel format supported by the encoder.
423+If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an error
424+if the requested pixel format can not be selected, and automatic conversions
425+inside filter graphs are disabled.
426+If @var{pix_fmt} is a single @code{+}, ffmpeg selects the same pixel format
427+as the input (or graph output) and automatic conversions are disabled.
428+
421429 @item -sws_flags @var{flags} (@emph{input/output})
422430 Set SwScaler flags.
423431 @item -vdt @var{n}
ffmpeg.c+19−0
@@ -319,6 +319,7 @@ typedef struct OutputStream { · 318 unmodified lines
319319 int copy_initial_nonkeyframes;
320320
321321 enum PixelFormat pix_fmts[2];
322+ int keep_pix_fmt;
322323 } OutputStream;
323324
324325
@@ -706,6 +707,15 @@ static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum Pixe · 381 unmodified lines
706707
707708 static char *choose_pixel_fmts(OutputStream *ost)
708709 {
710+ if (ost->keep_pix_fmt) {
711+ if (ost->filter)
712+ avfilter_graph_set_auto_convert(ost->filter->graph->graph,
713+ AVFILTER_AUTO_CONVERT_NONE);
714+ if (ost->st->codec->pix_fmt == PIX_FMT_NONE)
715+ return NULL;
716+ ost->pix_fmts[0] = ost->st->codec->pix_fmt;
717+ return ost->pix_fmts;
718+ }
709719 if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
710720 return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
711721 } else if (ost->enc->pix_fmts) {
@@ -835,6 +845,10 @@ static int configure_video_filters(FilterGraph *fg) · 123 unmodified lines
835845 return ret;
836846 }
837847
848+ if (ost->keep_pix_fmt)
849+ avfilter_graph_set_auto_convert(fg->graph,
850+ AVFILTER_AUTO_CONVERT_NONE);
851+
838852 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
839853 return ret;
840854
@@ -4661,6 +4675,11 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in · 3820 unmodified lines
46614675
46624676 video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
46634677 MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
4678+ if (frame_pix_fmt && *frame_pix_fmt == '+') {
4679+ ost->keep_pix_fmt = 1;
4680+ if (!*++frame_pix_fmt)
4681+ frame_pix_fmt = NULL;
4682+ }
46644683 if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) {
46654684 av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
46664685 exit_program(1);

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