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
29- add libavresample audio conversion library for compatibility29- add libavresample audio conversion library for compatibility
30- MicroDVD decoder30- MicroDVD decoder
31- Avid Meridien (AVUI) decoder31- Avid Meridien (AVUI) decoder
32- accept + prefix to -pix_fmt option to disable automatic conversions.
32 33
33 34
34version 0.10:35version 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
418@item -pix_fmt[:@var{stream_specifier}] @var{format} (@emph{input/output,per-stream})418@item -pix_fmt[:@var{stream_specifier}] @var{format} (@emph{input/output,per-stream})
419Set pixel format. Use @code{-pix_fmts} to show all the supported419Set pixel format. Use @code{-pix_fmts} to show all the supported
420pixel formats.420pixel formats.
421If the selected pixel format can not be selected, ffmpeg will print a
422warning and select the best pixel format supported by the encoder.
423If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an error
424if the requested pixel format can not be selected, and automatic conversions
425inside filter graphs are disabled.
426If @var{pix_fmt} is a single @code{+}, ffmpeg selects the same pixel format
427as the input (or graph output) and automatic conversions are disabled.
428
421@item -sws_flags @var{flags} (@emph{input/output})429@item -sws_flags @var{flags} (@emph{input/output})
422Set SwScaler flags.430Set SwScaler flags.
423@item -vdt @var{n}431@item -vdt @var{n}
ffmpeg.c+19−0
@@ -319,6 +319,7 @@ typedef struct OutputStream { · 318 unmodified lines
319 int copy_initial_nonkeyframes;319 int copy_initial_nonkeyframes;
320 320
321 enum PixelFormat pix_fmts[2];321 enum PixelFormat pix_fmts[2];
322 int keep_pix_fmt;
322} OutputStream;323} OutputStream;
323 324
324 325
@@ -706,6 +707,15 @@ static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum Pixe · 381 unmodified lines
706 707
707static char *choose_pixel_fmts(OutputStream *ost)708static char *choose_pixel_fmts(OutputStream *ost)
708{709{
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 }
709 if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {719 if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
710 return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));720 return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
711 } else if (ost->enc->pix_fmts) {721 } else if (ost->enc->pix_fmts) {
@@ -835,6 +845,10 @@ static int configure_video_filters(FilterGraph *fg) · 123 unmodified lines
835 return ret;845 return ret;
836 }846 }
837 847
848 if (ost->keep_pix_fmt)
849 avfilter_graph_set_auto_convert(fg->graph,
850 AVFILTER_AUTO_CONVERT_NONE);
851
838 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)852 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
839 return ret;853 return ret;
840 854
@@ -4661,6 +4675,11 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in · 3820 unmodified lines
4661 4675
4662 video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;4676 video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
4663 MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);4677 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 }
4664 if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) {4683 if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) {
4665 av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);4684 av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
4666 exit_program(1);4685 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