Search code examples
audiovideoffmpegm3u8

Use ffmpeg convert mp4 to hls m3u8 and reserver audio


I have a mp4 file, input0.mp4. Now I want to convert it to a HLS and only reserver audio with one step. Now I can realease it with two steps as follows. First converting it to a mp3 file, second slicing mp3 file to m3m8.

ffmpeg -i input0.mp4 input0.mp3

ffmpeg -i input0.mp3 -c:v libx264 -c:a aac -strict -2 -f hls -hls_list_size 0 output.m3u8

If I want to use ffmpeg to realease it with one step, how can I do it.


Solution

  • I broke down the command to multiple lines, so you can see how does the syntax looks like if you're using the same input for different outputs.

    ffmpeg -i input0.mp4 \
      -vn input0.mp3 \
      -c:v libx264 -c:a aac -strict -2 -f hls -hls_list_size 0 output.m3u8
    

    Hope it helped.