1. Zakhar Zibarov
  2. FFVideo
  3. Issues
Issue #4 open

Iterating through frames does not start with the first frame

Anonymous created an issue

Hey Zakhar,

Thanks for making this amazing wrapper. I love how easy it is to use. I was wondering why some of my frames were missing after encoding an image sequence with ffmpeg to video, today.

I read the video with ffvideo and after some time I realized that ffvideo does not start to read a video with the first frame.

Try:

vs = VideoStream('my.mp4', frame_mode='RGB')
for frame in vs:
    print frame.frameno

Depending on the video I am reading, the frame numbers start with 5 or 7. Exactly the number of frames I missed before.

While printing this out, I also realized that the frame-numbering is buggy, too. (Seems to be a rounding error).

(I am on Fedora 18, ffmpeg version 1.0.5 Copyright (c) 2000-2012 the FFmpeg developers built on Mar 10 2013 12:20:58 with gcc 4.7.2 (GCC) 20121109 (Red Hat 4.7.2-8))

My output of the snippet above:

7
8
9
11
11
12
14
14
15
17
17
18
20
20
21
23
23
24
25
26
27
28
29
30
31
32
33
35
35
36
37
38
39
41
41
42
43
44
45
46
47
48
49
50
51
53
53
54
55
56
57
58
59
60
62
62
63
65
65
...

Comments (4)

  1. groakat NA

    Ok I registered to clarify/ update the issue.

    I am not sure what happened, but after a restart yesterday, I get a correct frame number sequence (no holes or duplications). However, the numbering starts still somehow at 4.

    Using ffmpeg (both, fedora package and a recompiled git head from today)

    ffmpeg -i "/tmp/test.mp4" -an -f image2 "/tmp/testSequence/output_%05d.jpg"
    

    gives me the complete sequence. (So I guess ffmpeg is ok).

    Another remark. The first frame that ffVideo extracts (and reports as frame number 4) is identical with the first frame that ffmpeg extracts. So that is correct, in a way. Just the internal index is wrong. The last frame that ffVideo extracts is identical to the [last - 4]th frame ffmpeg extracted.

    If I do

    # load test.mp that has 1761 frames
    vs = VideoStream('/tmp/test.mp4', frame_mode='RGB')
    frame = vs.get_frame_no(1760)
    

    This frame also is identical to the [last - 4]th frame ffmpeg extracted.

    To conclude, I think the counting is wrong by some offset. I had a look in your code, but I could not figure out where the problem is. Something I noticed, though, is that although you seem not to use a frame number to extract the consecutive frames, I could not find anywhere an initialization of the frame number.

  2. groakat NA

    Another remark. If I use your wrapper to read in a file encoded with the FFV1 codec, it seems as all frames are read correctly. At least the frame numbers are complete/correct.

    So maybe its really something with ffmpeg. Can you try to reproduce the error? I am happy to lend a hand if needed.

  3. Log in to comment