Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Schlaile <peter@schlaile.de>2010-11-01 21:13:10 +0300
committerPeter Schlaile <peter@schlaile.de>2010-11-01 21:13:10 +0300
commit1b18ea58239b39538f1947cbc1ee0fba9cd26dd9 (patch)
treef500002e9a1ef2f4910fb24bf9c0315f21506e13 /source/blender/imbuf/intern/anim_movie.c
parent3a8c37bb240f9226526b70165c04c911ed4d3c14 (diff)
== FFMPEG ==
This fixes a rather subtle seeking issue with ffmpeg and Sony XDCAM-footage. Problem is: MPEG2 streams within an MP4 container can contain a start time - at several places. There is a starttime within the video and audio streams and one within the container. FFMpeg commandline tool only uses the container starttime and we used the stream starttime. The world would be a better place, if those two timestamps always match up, since in XDCAM-footage those two starttimes differ in 4 frames - and the container has the right one. We now always use the container start time as ffmpeg commandline tool does (in the hope, that there is a good explaination for this and this is the right thing(tm) to do). I tested this also with HDV footage, which seems to work with the new code, too. Additional fix: disabled seek_by_bytes again, since it will only work correctly, if ffmpeg guessed the HDV bitrate right (which it doesn't). If you have seeking issues with HDV and have an older version of ffmpeg installed, please upgrade, newer versions have some fixes in them.
Diffstat (limited to 'source/blender/imbuf/intern/anim_movie.c')
-rw-r--r--source/blender/imbuf/intern/anim_movie.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 8df0d69bcfa..421ef08dc25 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -839,7 +839,15 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
}
}
+/* disable seek_by_bytes for now, since bitrates are guessed wrong!
+ also: MPEG2TS-seeking was fixed in later versions of ffmpeg, so problem
+ is somewhat fixed by now (until we add correct timecode management code...)
+*/
+#if 0
seek_by_bytes = !!(anim->pFormatCtx->iformat->flags & AVFMT_TS_DISCONT);
+#else
+ seek_by_bytes = FALSE;
+#endif
if (position != anim->curposition + 1) {
#ifdef FFMPEG_OLD_FRAME_RATE
@@ -851,12 +859,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
av_q2d(anim->pFormatCtx->streams[anim->videoStream]
->r_frame_rate);
#endif
- double time_base =
- av_q2d(anim->pFormatCtx->streams[anim->videoStream]
- ->time_base);
+ double pts_time_base = av_q2d(anim->pFormatCtx->streams[anim->videoStream]->time_base);
long long pos;
- long long st_time = anim->pFormatCtx
- ->streams[anim->videoStream]->start_time;
+ long long st_time = anim->pFormatCtx->start_time;
int ret;
if (seek_by_bytes) {
@@ -876,7 +881,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
}
if (st_time != AV_NOPTS_VALUE) {
- pos += st_time * AV_TIME_BASE * time_base;
+ pos += st_time;
}
}
@@ -891,9 +896,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
}
pts_to_search = (long long)
- (((double) position) / time_base / frame_rate);
+ (((double) position) / pts_time_base / frame_rate);
if (st_time != AV_NOPTS_VALUE) {
- pts_to_search += st_time;
+ pts_to_search += st_time / pts_time_base/ AV_TIME_BASE;
}
pos_found = 0;