[FFmpeg-devel] Problem with seeking in avi file.
Neil Brown
neilb
Sat Aug 11 02:45:45 CEST 2007
I have another interesting movie file that ffmpeg doesn't quite work
properly with.
This one is an avi file containing dvvideo extracted off a digital
camcorder (I can find out what program was used to exact it if that
might be of interest).
Anyway, the problem is that the first time that I seek into the file,
if I aim for beyond 4:57, I alway arrive at 4:57. Subsequent seeks
work as expected.
e.g.
ffmpeg -ss 400 filename.avi
starts at 4:57, as does any number of seconds greater than 300.\
The file starts with RIFF with a size of 1069618820.
This covers about 1/4 of the file (5 minutes of about 20).
There are 3 more RIFF headers of 1069611496, then
one of 63795560 which completes the file.
The file contains a 'dmlh' tag, so is_odml is set.
The file contains a 'LIST' tag with a 'movi' subtag and a size of
1069467476. This just covers the first of 5 RIFF sections.
So ->movi_end gets set to 1/4 of the way through the file - the end of
the first section.
In avi_read_packet, after a seek further into the file,
'i' is the current position in the file, so this code:
if (i >= avi->movi_end) {
if (avi->is_odml) {
url_fskip(pb, avi->riff_end - i);
avi->riff_end = avi->movi_end = url_fsize(pb);
} else
break;
}
seeks back to the end of the first RIFF, then sets movi_end to the
correct end of the file.
It seems to me that if 'odml' allows as to set movi_end to fsize at
this point, it should allow movi_end to be set to fsize right at the
start.
So I changed avi_read_header so that instead of:
if(size) avi->movi_end = avi->movi_list + size + (size & 1);
else avi->movi_end = url_fsize(pb);
it does
if(size && ! avi->is_odml)
avi->movi_end = avi->movi_list + size + (size & 1);
else avi->movi_end = url_fsize(pb);
As the 'dmlh' header precedes the LIST header (in my example file),
this works and I can seek correctly.
If the dmlh header is allowed to come after LIST, maybe the handler
for dmlh should set movi_end to url_fsize ??
Any help with further understanding, or otherwise getting this issue
fixed would be most appreciated.
If it helps, I can zero out bits of the file that are not read during
testing, compress it, and put it somewhere for download.
Thanks,
NeilBrown
More information about the ffmpeg-devel
mailing list