[FFmpeg-devel] [PATCH] Playlist API

Geza Kovacs gkovacs
Sat Aug 8 00:09:40 CEST 2009


> Currently it seems to me that playlists through AVFormatContext could only
> be done by assigning each playlist entry a unique set of stream ids. This
> would reuqire some changes in applications to handle but it at least is
> providing the applications with well defined semantics and not some
> continiusly changing values one cannot really depend upon
> 

I had something along these lines implemented before I went for the
current stream-switching model, basically it was like this:

Rather than replacing the existing streams when opening a new playlist
element, nb_streams is incremented by the number of new streams, and the
new streams are appended on the end of the streams list in the same
order they were organized in. For example:

file1 with 2 streams is opened:
nb_streams=2
streams[0]=file1-stream0
streams[1]=file1-stream1

file2 with 3 streams is opened:
nb_streams=5
streams[0]=file1-stream0
streams[1]=file1-stream1
streams[2]=file2-stream0
streams[3]=file2-stream1
streams[4]=file2-stream2

file3 with 1 stream is opened:
nb_streams=6
streams[0]=file1-stream0
streams[1]=file1-stream1
streams[2]=file2-stream0
streams[3]=file2-stream1
streams[4]=file2-stream2
streams[5]=file2-stream0

...etc...

The stream index thus allows each stream to be uniquely identified; just
add a nb_streams_list to the PlaylistContext and store the nb_streams of
each element (so that it will work even after the AVFormatContext is
freed); and by going through the list you can calculate the offset and
actual stream index.

Now the problem with this is of course that you'll hit MAX_STREAMS
rather quickly, and it required some additional code to check if the
AVFormatContext is a playlist and if yes then offset the stream indexes
accordingly, but other than that it worked well.



More information about the ffmpeg-devel mailing list