Início / Conhecimento / Avançado
Common ffmpeg Commands for M3U8
Este artigo está disponível em chinês e inglês; a tradução para português está a caminho.
ffmpeg is the most reliable tool for HLS. Master the commands below and you can handle the vast majority of requests.
Remux directly to MP4
ffmpeg -i input.m3u8 -c copy output.mp4 attempts a direct remux. If the segment codecs are MP4-compatible (such as H.264 + AAC), this is the fastest route.
When you need to re-encode
ffmpeg -i input.m3u8 -c:v libx264 -c:a aac output.mp4 covers incompatible codecs. It's slower but universally usable.
Merge first, process later
For TS segments, ffmpeg -i "concat:1.ts|2.ts|3.ts" -c copy out.ts merges them before further work. With many segments, a file list plus -f concat is more robust.
Encrypted streams
ffmpeg reads #EXT-X-KEY from the playlist automatically to fetch the key. If the key needs extra request headers, pass them with -headers.
For long videos, test your parameters on a short clip with
-t first, then run the full job — it saves a lot of time.