Matevz
Matevz

Reputation: 3

Is #EXT-X-DISCONTINUITY tag needed if I build TS segments separately one by one using ffmpeg?

What am I trying to achieve:

I have 1000 PNG images. I would like to have a 30 seconds video with 0.1 fps created from each individual image. Then I would like to create multiple m3u8 playlists from all these videos together one after another, each playlist having videos in random order.

What have I tried:

I created a TS video file for each of my images using this command:

ffmpeg -y -loop 1 -t 30 -r 0.1 -i INPUT_IMAGE_X.png -c:v libx264 -crf 26 -pix_fmt yuv420p OUTPUT_VIDEO_X.ts

Then I created a playlist using the following format:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:30
#EXTINF:30.00000,
OUTPUT_VIDEO_1.ts
#EXTINF:30.00000,
OUTPUT_VIDEO_2.ts
#EXTINF:30.00000,
OUTPUT_VIDEO_3.ts
...
#EXTINF:30.00000,
OUTPUT_VIDEO_1000.ts
#EXT-X-ENDLIST

The issue:

When I play such playlist in iOS app using AVPlayer, the following happens:

Possible solution

I found out that if I insert #EXT-X-DISCONTINUITY tag between all my segments, all segments play correctly for 30 seconds. However I also noticed that AVPlayer needs a lot more loading time before it starts the video in that case.

Question

Is there a possibility to create my videos in such way that discontinuity tags would not be necessary? They make my playlist files larger and add delay to start of the video.

Upvotes: 0

Views: 1406

Answers (1)

hobbs
hobbs

Reputation: 240010

What you need is correct timestamps in each segment. I believe the -itsoffset should do it — -itsoffset 0 (or nothing at all) for the first segment, -itsoffset 30 for the second, -itsoffset 60 for the third, etc.

You could probably also get ffmpeg to do the whole thing for you using the concat demuxer to read the input and -f hls -hls_time 30 -hls_playlist_type vod; the concat demuxer will handle "looping" each image and setting the timestamps correctly, and the hls muxer will write both the TS segments and the HLS manifest.

Upvotes: 0

Related Questions