[Ffmpeg-devel] [PATCH] wrong duration is set with some MOV files

Alexey Sidelnikov avs99
Thu Oct 19 02:14:27 CEST 2006


I have a mov file with some strange DATA stream:
     Stream #0.2(eng): Data: tmcd / 0x64636D74

ffmpeg converts it well, but for some reason duration was not detected 
correct. The real duration is 79 seconds, but ffmpeg reported as 
19-something minutes. It was set incorrect in 
libavformat/utils.c/av_update_stream_timings() function That was because of 
that DATA stream. I added printfs, so the output is here:


$ ffmpeg -i compressed.mov
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard
  built on Oct 17 2006 07:58:41

av_update_stream_timings ... start
st ID = 0. st->codec->codec_id = 25, codec_type = 0, codec_name = 'DV - PAL'
         st->duration = 1975, time_base.num = 1, time_base.den = 25
         start_time = 0
         end_time = 79000000
st ID = 1. st->codec->codec_id = 65537, codec_type = 1, codec_name = ''
         st->duration = 3792000, time_base.num = 1, time_base.den = 48000
         start_time = 0
         end_time = 79000000
st ID = 2. st->codec->codec_id = 0, codec_type = 2, codec_name = ''
         st->duration = 1, time_base.num = 28835, time_base.den = 25
         start_time = 0
         end_time = 1153400000
ic->duration = 1153400000

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'compressed.mov':
  Duration: 00:19:13.4, start: 0.000000, bitrate: 2077 kb/s
  Stream #0.0(eng): Video: dvvideo, yuv420p, 720x576, 25.00 fps(r)
  Stream #0.1(eng): Audio: pcm_s16be, 48000 Hz, stereo, 1536 kb/s
  Stream #0.2(eng): Data: tmcd / 0x64636D74
Must supply at least one output file


As you can see, video and audio streams do have correct duration 
(79000000/AV_TIME_BASE = 79 seconds), but the DATA stream has incorrect one, 
and ffmpeg chooses it. So I propose the patch which will take duration only 
from known (codec_id > CODEC_ID_NONE) audio/video streams (codec_type == 
CODEC_TYPE_AUDIO/VIDEO). Right now I'm a bit confused how to attach files, 
so let me post it here.

Alexey



Index: utils.c
===================================================================
--- utils.c (revision 6731)
+++ utils.c (working copy)
@@ -1462,6 +1462,12 @@
     end_time = MININT64;
     for(i = 0;i < ic->nb_streams; i++) {
         st = ic->streams[i];
+
+        if (!(st->codec->codec_type == CODEC_TYPE_AUDIO ||
+                st->codec->codec_type == CODEC_TYPE_VIDEO) ||
+             st->codec->codec_id == CODEC_ID_NONE)
+                 continue;
+
         if (st->start_time != AV_NOPTS_VALUE) {
             start_time1= av_rescale_q(st->start_time, st->time_base, 
AV_TIME_BASE_Q);
             if (start_time1 < start_time) 







More information about the ffmpeg-devel mailing list