I want to rewrite the m3u8 output in ffmpeg and change the playback order of divided ts files.

Asked 2 years ago, Updated 2 years ago, 93 views

I would like to edit the m3u8 file and change the playback order of the TS file.
If anyone knows how to do it, please let me know.

The assumption is one m3u8 file and several TS files.
If you output ffmpeg in m3u8 format, you get the following results:
The correct condition is to play the TS file towards 1→4 as shown in [1.ts→2.ts→3.ts→4.ts].
Below are the contents of the actual m3u8 file.

#EXTM3U
# ext-x-version —3
# ext-x-media-sequence:0
# ext-x-allow-cache —yes (allows caching).
# ext-x-targetduration:5
# extinf: 4.027222,
test0000.ts
# extinf: 4.004000,
test0001.ts
# extinf: 4.004000,
test0002.ts
# extinf: 4.004000,
test0003.ts
# EXT-X-ENDLIST

We would like to rewrite this m3u8 to the following format to achieve the following:
Suppose you want to play the TS file from 4 to 4 toward 4→1, such as [4.ts→3.ts→2.ts→1.ts].
We edited m3u8 in the intended playback order as follows:
However, the playback of the video doesn't go as expected, and it will harden.

#extm3u.
# ext-x-version —3
# ext-x-media-sequence:0
# ext-x-allow-cache:yes
# ext-x-targetduration:5
# extinf: 4.027222,
test0003.ts
# extinf: 4.004000,
test0002.ts
# extinf: 4.004000,
test0001.ts
# extinf: 4.004000,
test0000.ts 
# EXT-X-ENDLIST

If I want to change the order of TS files like this, how can I edit the m3u8 files?
Or should I re-create the m3u8 file after changing the order of the ts file with the ffmpeg command?

I would be very grateful if you could help me.

ffmpeg

2022-09-30 17:09

1 Answers

We would like to rewrite this m3u8 to the following format to achieve the following:
Suppose you want to play the TS file from 4 to 4 toward 4→1, such as [4.ts→3.ts→2.ts→1.ts].
[...]
However, the playback of the video doesn't go as expected, and it will harden.

It is impossible to reorder video segments by rewriting m3u8 files.
"The TS file itself also contains ""video and audio playback location information""."(Example: test0001.ts contains information to play in 4-8 second positions.)

Even if you simply rewrite the TS file entry order in the m3u8 file, the playback location information remains the same, so the player was suddenly instructed to play the video/audio in the future or in the past, and the playback of the video was hardened.


2022-09-30 17:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.