Opened 2 years ago

Last modified 23 months ago

#5309 new defect

Seek doesn't work in some .mp4 files

Reported by: Arnaud Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: h264 mov seek
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
How to reproduce:

% ffplay -ss 5
ffmpeg version: ffplay version N-78958-g8c24523
built from latest git, on Ubuntu 14.04.3, on 2016-03-07

File is seek_not_working.mp4

The file plays well but always from the beginning: the seek isn't working.

Change History (14)

comment:1 Changed 2 years ago by Arnaud

(will upload sample file)

comment:2 Changed 2 years ago by Arnaud

Problematic file uploaded on the ftp server
I would like to help finding what is the issue and maybe fix it if I can, but I'm not expert with ffmpeg source code, so if someone more experienced has an idea about what is wrong :)

comment:3 Changed 2 years ago by cehoyos

Is the issue not reproducible with ffmpeg (the application)?

comment:4 Changed 2 years ago by Arnaud

I didn't know ffmpeg has a seek option.
I tried it the following way:
./ffmpeg -ss 3 -i seek_not_working.mp4 -frames:v 1 out1.jpg
and yes, it works.

comment:5 Changed 2 years ago by cehoyos

  • Keywords h264 mov added

Did you find a sample with fourcc AVd1?

comment:6 Changed 2 years ago by Arnaud

Sorry, I'm not sure I understand what you meant.
You're asking if I have the same problem with other mp4 files?

comment:7 Changed 2 years ago by cehoyos

No, you promised me in September to search for such a sample. Did you find one?

comment:8 Changed 2 years ago by Arnaud

Ah, ok.
No sorry: I probably lost it when my hard drive crashed some time ago :(

comment:9 Changed 2 years ago by Arnaud

Did someone has any clue about what might be wrong?

comment:10 Changed 2 years ago by cehoyos

  • Keywords seek added

I suspect the file has only one recovery point.

comment:11 follow-up: Changed 23 months ago by Arnaud

Thanks for your reply.

How can I check if the file has only on recovery point and if that can be the issue?

I tried to figure this out by adding a breakpoints in h264.c:decode_recovery_point but never get there, using my "buggy" file, but also some other files (e.g. [1] from [2]) for which seeking works.


comment:12 in reply to: ↑ 11 Changed 23 months ago by cehoyos

Replying to Arnaud:


This file contains many IDR frames.
I don't know the exact semantic definition of recovery points but all IDR frames can be used for seeking.

comment:13 Changed 23 months ago by Arnaud

Oh, OK.
Indeed that seems to be the problem in my initial file: only one IDR frame.
Then I guess this bug can be closed, because there isn't much to fix on ffmpeg library or on ffplay about it, don't you think?

If I'm right VLC uses ffmpeg, and I noticed it is able to seek this file, but it seems like it reads all the frames from the IDR frame to achieve this.
So I guess it's up to applications to implement such behavior on top of ffmpeg's seek if not enough IDR frames are present.

Thanks a lot for your help :)

comment:14 Changed 23 months ago by cehoyos

No IDR- (and no I-) frames are necessary to seek a valid H.264 stream, recovery points are sufficient. A stream analyzer is needed to find out if your stream does contain more than one recovery point.

Note: See TracTickets for help on using tickets.