[FFmpeg-cvslog] ffmpeg: Do not fill gap before the first decodable frame on single stream input files unless the user explicitly requests it.
Michael Niedermayer
git at videolan.org
Sun Nov 17 20:06:26 CET 2013
ffmpeg | branch: release/2.1 | Michael Niedermayer <michaelni at gmx.at> | Thu Nov 14 01:21:20 2013 +0100| [4b846f0ccf8094b4b14e8e3b8a06955ff48eca15] | committer: Michael Niedermayer
ffmpeg: Do not fill gap before the first decodable frame on single stream input files unless the user explicitly requests it.
Fixes different behavior to JM and probably several if not all
reference decoders.
We cannot just do this unconditionally as it would ruin AV sync in
some use cases.
Bug-Found-by: BugMaster
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit d7ebeba80c609e160a171168b3434c342a652237)
Conflicts:
ffmpeg.c
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b846f0ccf8094b4b14e8e3b8a06955ff48eca15
---
ffmpeg.c | 17 +++++++++++++++--
ffmpeg.h | 2 ++
ffmpeg_opt.c | 1 +
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index 001e5c1..6629a5f 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -817,10 +817,23 @@ static void do_video_out(AVFormatContext *s,
nb_frames = 1;
format_video_sync = video_sync_method;
- if (format_video_sync == VSYNC_AUTO)
+ if (format_video_sync == VSYNC_AUTO) {
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
+ if ( ist
+ && format_video_sync == VSYNC_CFR
+ && input_files[ist->file_index]->ctx->nb_streams == 1
+ && input_files[ist->file_index]->input_ts_offset == 0) {
+ format_video_sync = VSYNC_VSCFR;
+ }
+ }
switch (format_video_sync) {
+ case VSYNC_VSCFR:
+ if (ost->frame_number == 0 && delta - duration >= 0.5) {
+ av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration));
+ delta = duration;
+ ost->sync_opts = lrint(sync_ipts);
+ }
case VSYNC_CFR:
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (delta < -1.1)
@@ -2357,7 +2370,7 @@ static int transcode_init(void)
if (ost->filter && !(codec->time_base.num && codec->time_base.den))
codec->time_base = ost->filter->filter->inputs[0]->time_base;
if ( av_q2d(codec->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH
- && (video_sync_method == VSYNC_CFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){
+ && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){
av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
"Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
}
diff --git a/ffmpeg.h b/ffmpeg.h
index 054e718..1471739 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -51,6 +51,7 @@
#define VSYNC_PASSTHROUGH 0
#define VSYNC_CFR 1
#define VSYNC_VFR 2
+#define VSYNC_VSCFR 0xfe
#define VSYNC_DROP 0xff
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
@@ -281,6 +282,7 @@ typedef struct InputFile {
int eof_reached; /* true if eof reached */
int eagain; /* true if last read attempt returned EAGAIN */
int ist_index; /* index of first stream in input_streams */
+ int64_t input_ts_offset;
int64_t ts_offset;
int64_t last_ts;
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index c9283d6..d154807 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -852,6 +852,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->ist_index = nb_input_streams - ic->nb_streams;
f->start_time = o->start_time;
f->recording_time = o->recording_time;
+ f->input_ts_offset = o->input_ts_offset;
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = o->rate_emu;
More information about the ffmpeg-cvslog
mailing list