I want to speed up the process of HLS segmentation of .mp4 video. Now, processing a half-hour video can take about 5 minutes, and that is too long. To do this, I decided to split the video into fragments, process each of them in parallel, and then create an .m3u8 file that will contain a list of .ts files from all the resulting playlists in the correct order. I used the next commands:
ffmpeg -i original.mp4 -acodec copy -f segment -segment_time 10 -vcodec copy -reset_timestamps 1 -map 0 output_time_%d.mp4
for splitting the original video to .mp4 fragments 10 seconds long each;
ffmpeg -y -i output_time_0.mp4 -b:v 1M -g 60 -hls_list_size 0 -hls_segment_filename output_time_0_%d.ts -hls_segment_size 50000 -hls_time 3 output_time_0_playlist.m3u8
ffmpeg -y -i output_time_1.mp4 -b:v 1M -g 60 -hls_list_size 0 -hls_segment_filename output_time_1_%d.ts -hls_segment_size 50000 -hls_time 3 output_time_1_playlist.m3u8
and so forth for each fragment. Then I have edited an .m3u8 file in text editor.
I did this, but the problem is that when I try to play my synthetic playlist in the player, playback stops at the beginning of the first "alien" fragment. The flag #EXT-X-DISCONTINUITY
did not change anything.
So I had multiple .m3u8 files:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:4.004000,
#EXT-X-BYTERANGE:385964@0
output_time_0_0.ts
#EXTINF:2.002000,
#EXT-X-BYTERANGE:180104@0
output_time_0_1.ts
#EXTINF:4.004000,
#EXT-X-BYTERANGE:438604@0
output_time_0_2.ts
#EXTINF:0.133467,
#EXT-X-BYTERANGE:142128@0
output_time_0_3.ts
#EXT-X-ENDLIST
and
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:4.004000,
#EXT-X-BYTERANGE:447628@0
output_time_1_0.ts
#EXTINF:2.002000,
#EXT-X-BYTERANGE:222592@0
output_time_1_1.ts
#EXTINF:4.004000,
#EXT-X-BYTERANGE:517940@0
output_time_1_2.ts
#EXTINF:0.100100,
#EXT-X-BYTERANGE:154912@0
output_time_1_3.ts
#EXT-X-ENDLIST
and I've joined them manually, so I have the following one:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:4.004000,
#EXT-X-BYTERANGE:385964@0
output_time_0_0.ts
#EXTINF:2.002000,
#EXT-X-BYTERANGE:180104@0
output_time_0_1.ts
#EXTINF:4.004000,
#EXT-X-BYTERANGE:438604@0
output_time_0_2.ts
#EXTINF:0.133467,
#EXT-X-BYTERANGE:142128@0
output_time_0_3.ts
#EXT-X-DISCONTINUITY
#EXTINF:4.004000,
#EXT-X-BYTERANGE:447628@0
output_time_1_0.ts
#EXTINF:2.002000,
#EXT-X-BYTERANGE:222592@0
output_time_1_1.ts
#EXTINF:4.004000,
#EXT-X-BYTERANGE:517940@0
output_time_1_2.ts
#EXTINF:0.100100,
#EXT-X-BYTERANGE:154912@0
output_time_1_3.ts
#EXT-X-ENDLIST
How do you rate my idea as a whole, and are there any ideas on how to fix the playback error?