[FFmpeg-user] [ffplay] after changing to another audio stream, audio will become out of sync with video
Lifeng Ren
renlifeng at gmail.com
Fri Mar 2 06:23:56 CET 2012
hi,
I want to report that after changing to another audio stream, audio and
video becomes out of sync.
steps to reproduce:
$ ffplay video-with-2-audio-stream.mpg
a (press a to toggle audio stream)
I also find this can be avoided by patching ffplay.c as such.
diff --git a/ffplay.c b/ffplay.c
index 93097e1..ac31ce6 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2725,6 +2725,7 @@ static void stream_cycle_channel(VideoState *is, int
codec_type)
AVFormatContext *ic = is->ic;
int start_index, stream_index;
AVStream *st;
+ double pos;
if (codec_type == AVMEDIA_TYPE_VIDEO)
start_index = is->video_stream;
@@ -2765,8 +2766,10 @@ static void stream_cycle_channel(VideoState *is, int
codec_type)
}
}
the_end:
+ pos = get_master_clock(is);
stream_component_close(is, start_index);
stream_component_open(is, stream_index);
+ stream_seek(is, (int64_t)(pos * AV_TIME_BASE), 0, 0);
}
More information about the ffmpeg-user
mailing list