Fix crash occurring when the list of sample formats is not defined in the 
encoder,
use the decoder one in that case.

Possibly fix issue:
http://trac.ffmpeg.org/ticket/5849
---
 doc/examples/transcode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 1d22a4b09e..3c72b9377e 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -189,8 +189,10 @@ static int open_output_file(const char *filename)
                 ret = av_channel_layout_copy(&enc_ctx->ch_layout, 
&dec_ctx->ch_layout);
                 if (ret < 0)
                     return ret;
-                /* take first format from list of supported formats */
-                enc_ctx->sample_fmt = encoder->sample_fmts[0];
+
+                /* take first format from list of supported formats or use 
decoder one */
+                enc_ctx->sample_fmt = encoder->sample_fmts ? 
encoder->sample_fmts[0] : dec_ctx->sample_fmt;
+
                 enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
             }
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to