1. HLS(m3u8,ts)合并转MP4

1
2
3
4
5
# merge by m3u8 list file
ffmpeg -i path/to/file.m3u8 -codec copy -f mp4 output.mp4

# merge by specific serveral TS file
ffmpeg -i "1.ts|2.ts|3.ts|4.ts" -codec copy -f mp4 output.mp4

2. MP4转m3u8

1
2
3
4
5
6
# Convert to a merged TS file first
ffmpeg -i input.mp4 -codec copy output.ts

# Seperated it and named with format v%04d.ts
ffmpeg -i output.ts -codec copy -map 0 -f segment -segment_list target/path/to/file.m3u8 -segment_time 5 target/path/to/v%04d.ts