[FFmpeg-devel] Request for comment: Tutorial

Scott Harper orcein
Thu May 24 20:05:54 CEST 2007


On 2007/05/21, at 22:47, Stephen Dranger wrote:

> I have written a rather lengthy ffmpeg tutorial that starts by going
> over Martin Bohme's old tutorial, then proceeding to recreate
> ffplay.c, teaching about how ffmpeg, SDL, and video in general works.
>
> Here's the link:
> http://dranger.com/ffmpeg/ffmpeg.html

Excellent tutorial!  That will be very helpful, especially the part  
where you explain the syncing elements.

The problem I've had with writing a simple player using ffmpeg and  
SDL (I even added a progress-bar like in most media apps!) is  
detecting the END of the video...  I.E. making sure that it PLAYS the  
last frames, and doesn't try to read beyond the end incessantly,  
jumping forward to the end/last frame, noticing that the player is at  
the end and setting it pause playback and know that if you press  
"play" again it should seek to the beginning again and unpause from  
there...  I think part of the problem was that some of the different  
video files I was using might have had different ways of ending.   
Another problem might have been seeking to the end, where I had to  
get the last keyframe and built up (Mpeg4 videos, especially) to the  
last frame's timestamp.

What I was doing was (and this was a few months ago when school was  
lighter and I could afford to be working on it) getting the ratio  
across the playback-bar thing when the user clicked it, then  
multiplying that ratio by the value represented in 'AVFormatContext- 
 >streams[videoStream]->duration', turing it into an integer, and  
seeking to there with AVSEEK_FLAG_BACKWARD, and then decoding/ 
rendering frames in memory until I got to the projected frame...   
Perhaps this was the wrong way of going about it?

The other problem I ran into was that I would decode frames up to the  
seeked-to video frame, but then the audio ratio was comnpletely  
different... like the video frame either changed to quickly or lasted  
noticably (to me) too long before changing... (I am syncing video-to- 
audio, and seeking by audio didn't work because then I missed key  
frames... (those are i-frames, right?)  Did I miss something in audio  
packets having multiple frames that allows me to more accurately  
determine where to begin my audio playback after random seeking?

Anyway, that's my problem area, if you want to write about that. ^_^   
Also, how does seeking by Bytes work?  I saw in your end section how  
it said that was better than by frame number?

Sorry for the long post, hope it was clear enough and on-topic enough  
to not get flames too badly. ^_^

-- Scott




More information about the ffmpeg-devel mailing list