Unified · Split
| @@ -283,8 +283,6 @@ typedef struct OutputFilterOptions { · 282 unmodified lines | ||
| 283 | 283 | |
| 284 | 284 | // Codec used for encoding, may be NULL |
| 285 | 285 | const AVCodec *enc; |
| 286 | − // Overrides encoder pixel formats when set. | |
| 287 | − const enum AVPixelFormat *pix_fmts; | |
| 288 | 286 | |
| 289 | 287 | int64_t trim_start_us; |
| 290 | 288 | int64_t trim_duration_us; |
| @@ -311,6 +309,11 @@ typedef struct OutputFilterOptions { · 20 unmodified lines | ||
| 311 | 309 | |
| 312 | 310 | int sample_rate; |
| 313 | 311 | AVChannelLayout ch_layout; |
| 312 | + | |
| 313 | + const int *formats; | |
| 314 | + const int *sample_rates; | |
| 315 | + const AVChannelLayout *ch_layouts; | |
| 316 | + const AVRational *frame_rates; | |
| 314 | 317 | } OutputFilterOptions; |
| 315 | 318 | |
| 316 | 319 | typedef struct InputFilter { |
| @@ -819,11 +819,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, · 818 unmodified lines | ||
| 819 | 819 | ofp->height = opts->height; |
| 820 | 820 | if (opts->format != AV_PIX_FMT_NONE) { |
| 821 | 821 | ofp->format = opts->format; |
| 822 | − } else if (opts->pix_fmts) | |
| 823 | − ofp->formats = opts->pix_fmts; | |
| 824 | − else if (opts->enc && | |
| 825 | − !(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT)) | |
| 826 | − ofp->formats = opts->enc->pix_fmts; | |
| 822 | + } else | |
| 823 | + ofp->formats = opts->formats; | |
| 827 | 824 | |
| 828 | 825 | fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); |
| 829 | 826 | |
| @@ -835,7 +832,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, · 5 unmodified lines | ||
| 835 | 832 | ofp->fps.framerate = ost->frame_rate; |
| 836 | 833 | ofp->fps.framerate_max = ost->max_frame_rate; |
| 837 | 834 | ofp->fps.framerate_supported = ost->force_fps || !opts->enc ? |
| 838 | − NULL : opts->enc->supported_framerates; | |
| 835 | + NULL : opts->frame_rates; | |
| 839 | 836 | |
| 840 | 837 | // reduce frame rate for mpeg4 to be within the spec limits |
| 841 | 838 | if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4) |
| @@ -847,21 +844,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, · 5 unmodified lines | ||
| 847 | 844 | case AVMEDIA_TYPE_AUDIO: |
| 848 | 845 | if (opts->format != AV_SAMPLE_FMT_NONE) { |
| 849 | 846 | ofp->format = opts->format; |
| 850 | − } else if (opts->enc) { | |
| 851 | − ofp->formats = opts->enc->sample_fmts; | |
| 847 | + } else { | |
| 848 | + ofp->formats = opts->formats; | |
| 852 | 849 | } |
| 853 | 850 | if (opts->sample_rate) { |
| 854 | 851 | ofp->sample_rate = opts->sample_rate; |
| 855 | − } else if (opts->enc) { | |
| 856 | − ofp->sample_rates = opts->enc->supported_samplerates; | |
| 857 | − } | |
| 852 | + } else | |
| 853 | + ofp->sample_rates = opts->sample_rates; | |
| 858 | 854 | if (opts->ch_layout.nb_channels) { |
| 859 | − int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL, | |
| 860 | − &opts->ch_layout); | |
| 855 | + int ret = set_channel_layout(ofp, opts->ch_layouts, &opts->ch_layout); | |
| 861 | 856 | if (ret < 0) |
| 862 | 857 | return ret; |
| 863 | − } else if (opts->enc) { | |
| 864 | − ofp->ch_layouts = opts->enc->ch_layouts; | |
| 858 | + } else { | |
| 859 | + ofp->ch_layouts = opts->ch_layouts; | |
| 865 | 860 | } |
| 866 | 861 | break; |
| 867 | 862 | } |
| @@ -952,6 +952,39 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, · 951 unmodified lines | ||
| 952 | 952 | |
| 953 | 953 | snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); |
| 954 | 954 | |
| 955 | + if (ost->type == AVMEDIA_TYPE_VIDEO) { | |
| 956 | + if (!keep_pix_fmt) { | |
| 957 | + ret = avcodec_get_supported_config(enc_ctx, NULL, | |
| 958 | + AV_CODEC_CONFIG_PIX_FORMAT, 0, | |
| 959 | + (const void **) &opts.formats, NULL); | |
| 960 | + if (ret < 0) | |
| 961 | + return ret; | |
| 962 | + } | |
| 963 | + if (!ost->force_fps) { | |
| 964 | + ret = avcodec_get_supported_config(enc_ctx, NULL, | |
| 965 | + AV_CODEC_CONFIG_FRAME_RATE, 0, | |
| 966 | + (const void **) &opts.frame_rates, NULL); | |
| 967 | + if (ret < 0) | |
| 968 | + return ret; | |
| 969 | + } | |
| 970 | + } else { | |
| 971 | + ret = avcodec_get_supported_config(enc_ctx, NULL, | |
| 972 | + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, | |
| 973 | + (const void **) &opts.formats, NULL); | |
| 974 | + if (ret < 0) | |
| 975 | + return ret; | |
| 976 | + ret = avcodec_get_supported_config(enc_ctx, NULL, | |
| 977 | + AV_CODEC_CONFIG_SAMPLE_RATE, 0, | |
| 978 | + (const void **) &opts.sample_rates, NULL); | |
| 979 | + if (ret < 0) | |
| 980 | + return ret; | |
| 981 | + ret = avcodec_get_supported_config(enc_ctx, NULL, | |
| 982 | + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, | |
| 983 | + (const void **) &opts.ch_layouts, NULL); | |
| 984 | + if (ret < 0) | |
| 985 | + return ret; | |
| 986 | + } | |
| 987 | + | |
| 955 | 988 | // MJPEG encoder exports a full list of supported pixel formats, |
| 956 | 989 | // but the full-range ones are experimental-only. |
| 957 | 990 | // Restrict the auto-conversion list unless -strict experimental |
| @@ -964,7 +997,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, · 6 unmodified lines | ||
| 964 | 997 | AV_PIX_FMT_NONE }; |
| 965 | 998 | |
| 966 | 999 | if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) |
| 967 | − opts.pix_fmts = mjpeg_formats; | |
| 1000 | + opts.formats = mjpeg_formats; | |
| 968 | 1001 | } |
| 969 | 1002 | |
| 970 | 1003 | if (threads_manual) { |