rbash88 / pyffmpeg

Automatically exported from code.google.com/p/pyffmpeg
0 stars 0 forks source link

seek_to_frame with GOP files #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

is it possible to force pyffmpeg to seek to any frame? It seems to me that if  
I use MPEG file (actually MXF with IMX30 essence), I am only able to seek to 
keyframes, or use step() method to step one frame ahead... so for example I 
can't just go one frame back. I've tried to rebuild pyffmpeg with uncommented 
AVSEEK_FLAG_ANY flag in seek_to method, but it didn't help.

Thanks

Martin

Original issue reported on code.google.com by martin...@gmail.com on 10 Dec 2010 at 11:55

GoogleCodeExporter commented 8 years ago
Hi martin, 

Sorry for very late reply. I was very busy at the moment you wrote, and I 
forgot to answer later. 

* It is true, that even with all option enabled sometime FFMPEG is not able to 
seek 
to the exact frame you were querying.

However, the wrapper code normally contains some code that does the following :
* check the start time of the sequence (to avoid some offset),
* seek a little bit before the programmed sequence and then use step(), as long 
we don't reach the expected time code... 

* These option may be enabled or disabled using some options in the constructor 
and/or the track selector... (Unfortunately the behavior of FFMPEG in seeking 
sometime depends of the version of FFMPEG, and on the version, so to write a 
good player is not all the time as straightforward as it ought to be)

So, what seems possible, that if you have a long-gop you need to seek earlier 
than 
usual and then to find out the good frame... In order to do that try to increase
the value of seek_before in the constructor... It is possible that a quite 
large value is necessary... Because, for most video format it is becoming more 
and more un-necessary, I somehow kept these value to a minimum in order not to 
slow-down the 
reading process for others.

Let me know if it helps, sorry for that very late answer.

Original comment by bertr...@lm3labs.com on 4 Jan 2011 at 3:48

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hello,

I have a problem slightly similar to this. I've noticed that when I use 
seek_to_frame(N) to seek to frame N and then do get_next_frame() to read the 
frame, I get frame N+1. Obviously, I can work around this by doing 
seek_to_frame(N-1) and then get_next_frame() in order to get frame N. However, 
this prevents me from ever reading the first frame of a video file (frame 0). 
Even if I just open the video and then call get_next_frame() right away, I 
still get the second frame of the video (frame 1). Am I missing something here?

I should mention that, apart from the small problem above, Pyffmpeg has been 
working great for me. It allows me to seek to specific frames in many different 
file formats, including ones where ffmpeg and OpenCV fail miserably. Thank you 
so much for your work on this.

Original comment by adriano....@gmail.com on 2 Mar 2012 at 12:53