From c949d5b15d2af23dcbbe2cb35b819d4930625d15 Mon Sep 17 00:00:00 2001
From: Nicolas Noirbent <nicolas.noirbent@smartjog.com>
Date: Fri, 13 Jan 2012 09:58:16 +0100
Subject: [PATCH] ffmpeg.c: transcode_video(): do not go through filter network
 if encoding is not required

This fixes a segmentation fault when doing a transcoding and a stream
copy of the same input stream at the same time, e.g.:

ffmpeg -i in.mkv -c:v mpeg2video transcode.m2v -c copy copy.ts

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 ffmpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 085bb00fcc1..2ee4032b398 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2078,7 +2078,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
     frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio");
     for(i=0;i<nb_output_streams;i++) {
         OutputStream *ost = ost = &output_streams[i];
-        if(check_output_constraints(ist, ost)){
+        if(check_output_constraints(ist, ost) && ost->encoding_needed){
             if (!frame_sample_aspect->num)
                 *frame_sample_aspect = ist->st->sample_aspect_ratio;
             decoded_frame->pts = ist->pts;
-- 
GitLab