ffmpeglive-streaming

How to generate TS streams from middle of a source video?


I am using ffmpeg to create m3u8 playlist for a video (actually a live video stream). I am using the following command:

ffmpeg -i /home/ubuntu/Download/1459530099245.mkv -c:a aac -strict experimental -ac 2 -ar 48k -ab 64k -c:v libx264 -s 480x270 -aspect 16:9 -b:v 400k -r 15 -g 45 -profile:v baseline -level 3.0 -f hls -hls_time 9 -hls_list_size 0  /home/ubuntu/Download/New Playlist.m3u8

It produces m3u8 file as well as ts files.

Question: simply, how can we produce m3u8 playlist and TS files for a particular duration of source video? E.g., I want to get playlist only for first 20 seconds or so?


Solution

  • You can use command -to. Just add -to 00:00:20 after input path In your variant:

    ffmpeg -i /home/ubuntu/Download/1459530099245.mkv -to 00:00:20 -c:a aac -strict experimental -ac 2 -ar 48k -ab 64k -c:v libx264 -s 480x270 -aspect 16:9 -b:v 400k -r 15 -g 45 -profile:v baseline -level 3.0 -f hls -hls_time 9 -hls_list_size 0 /home/ubuntu/Download/New Playlist.m3u8
    

    More information here: http://www.bogotobogo.com/FFMpeg/ffmpeg_seeking_ss_option_cutting_section_video_image.php