| @@ -319,6 +319,7 @@ typedef struct OutputStream { · 318 unmodified lines |
| 319 | 319 | int copy_initial_nonkeyframes; |
| 320 | 320 | |
| 321 | 321 | enum PixelFormat pix_fmts[2]; |
| 322 | + int keep_pix_fmt; |
| 322 | 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 | |
| 707 | 708 | static 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 | 719 | if (ost->st->codec->pix_fmt != PIX_FMT_NONE) { |
| 710 | 720 | return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt))); |
| 711 | 721 | } else if (ost->enc->pix_fmts) { |
| @@ -835,6 +845,10 @@ static int configure_video_filters(FilterGraph *fg) · 123 unmodified lines |
| 835 | 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 | 852 | if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) |
| 839 | 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 | 4676 | video_enc->bits_per_raw_sample = frame_bits_per_raw_sample; |
| 4663 | 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 | 4683 | if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) { |
| 4665 | 4684 | av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt); |
| 4666 | 4685 | exit_program(1); |