[FFmpeg-user] Continuos stream of videos using ffmpeg

Stefano Sabatini stefasab at gmail.com
Fri Aug 31 14:11:33 CEST 2012

On date Thursday 2012-08-30 21:50:54 +0530, Kiran Kumar encoded:
> Hi,
>  We are building a solution where we want all the videos to be played one
> after the another like a continuos stream. We are trying to build the
> solution using ffmpeg for encoding/segmenting and apache tomcat server. The
> way we are doing this is
>    1. Each video is individually encoded to h264 and segmented in 10 sec
>    interval. This generates playlist .m3u8 for each video.

>    2. Whenever a set of videos (based on some criterion) needs to be
>    streamed, we then manually create a playlist by concatenating each playlist
>    file (while keeping the m3u8 format intact)

This step looks error prone. Keep in mind that files in segments are
meant to be played *sequentially*, since each segment will keep the
original timestamps.

> For example,
> video A is split as A01.ts and A02.ts.
> video B is split as B01.ts.
> What we are trying to do is create one single playlist like the following.
> #EXTINF:10.285189,
> A01.ts
> #EXTINF:9.285189,
> A02.ts
> #EXTINF:8.000189,
> B01.ts

This really depends on how the player deals with timestamps.
So you have A01.ts starting with timestamps in range 0-10, A02.ts with
timestamps in the range 10-19, B01.ts in the range 0-8. The player may
get confused when it comes to reading B01.ts.

And I'm considering to extend the segment to have an option which
reset timestamps to 0. In general if you want to fix timestamps to
have them sequential you will have to remux the segments (and split
them again).

> The problem that we are facing is that while this works in some cases, it
> fails after playing 2 to 3 videos. If only one video was played, then we
> would know that the solution is not possible. However since we know
> at-least 2 videos play sometimes, we know we are missing something here.
> Any help will be appreciated.
> We are usng the following command to encode/segment the videos.
> ffmpeg -v 9 -loglevel 99 -re -i video.MOV -an \
> -c:v libx264 -b:v 128k \
> -acodec libmp3lame -ar 48000 -ab 64k -vcodec libx264 -b 96k -flags +loop
> -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1
> -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor
> 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp
> 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 \
> -flags -global_header -map 0 -f segment -segment_time 4 \
> -segment_list test.m3u8 -segment_format mpegts stream%05d.ts
ffmpeg-user random tip #26

More information about the ffmpeg-user mailing list