doc/examples/transcoding: Use the decoders pixel format if the encoder does not list...
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 27 Feb 2016 23:03:14 +0000 (00:03 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 5 Jun 2016 15:10:15 +0000 (17:10 +0200)
This affects rawvideo and wraped_avframe, no others are affected atm

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
doc/examples/transcoding.c

index d5d410b..8633362 100644 (file)
@@ -128,7 +128,10 @@ static int open_output_file(const char *filename)
                 enc_ctx->width = dec_ctx->width;
                 enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
                 /* take first format from list of supported formats */
-                enc_ctx->pix_fmt = encoder->pix_fmts[0];
+                if (encoder->pix_fmts)
+                    enc_ctx->pix_fmt = encoder->pix_fmts[0];
+                else
+                    enc_ctx->pix_fmt = dec_ctx->pix_fmt;
                 /* video time_base can be set to whatever is handy and supported by encoder */
                 enc_ctx->time_base = dec_ctx->time_base;
             } else {