[FFmpeg-devel] [PATCH] ffmpeg_opt: discard packets correctly

Ganesh Ajjanagadde gajjanagadde at gmail.com
Mon Jul 13 08:44:00 CEST 2015


libav commit 13f6917c merged in 574dcb5b results in
unnecessary seeks due to discarded packets;
especially problematic over a network.

Fixes Ticket4126

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 ffmpeg_opt.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index a356cad..b8dfdfe 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -608,7 +608,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
         ist->st = st;
         ist->file_index = nb_input_files;
         ist->discard = 1;
-        st->discard  = AVDISCARD_ALL;
 
         ist->ts_scale = 1.0;
         MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
@@ -709,7 +708,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
                     exit_program(1);
             }
             ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
-
+            if (o->video_disable)
+                st->discard = AVDISCARD_ALL;
             break;
         case AVMEDIA_TYPE_AUDIO:
             ist->guess_layout_max = INT_MAX;
@@ -720,9 +720,11 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
             ist->resample_sample_rate    = ist->dec_ctx->sample_rate;
             ist->resample_channels       = ist->dec_ctx->channels;
             ist->resample_channel_layout = ist->dec_ctx->channel_layout;
-
+            if (o->audio_disable)
+                st->discard = AVDISCARD_ALL;
             break;
         case AVMEDIA_TYPE_DATA:
+            break;
         case AVMEDIA_TYPE_SUBTITLE: {
             char *canvas_size = NULL;
             if(!ist->dec)
@@ -734,6 +736,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
                 av_log(NULL, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size);
                 exit_program(1);
             }
+            if (o->subtitle_disable)
+                st->discard = AVDISCARD_ALL;
             break;
         }
         case AVMEDIA_TYPE_ATTACHMENT:
-- 
2.4.5



More information about the ffmpeg-devel mailing list