Search code examples
ffmpegflac

Slice FLAC file into 5 second segments


I have a FLAC audio file that I want to slice into 5 second segments. I don't need to resample or change the data in any way.

What tools/libraries are there for this? Should I be looking at ffmpeg? I actually want to create a HLS stream so a tool that would do that would be a bonus but if I can simply chunk the audio data I can create the playlist myself.


Solution

  • Use the segment muxer:

    ffmpeg -i input.flac -f segment -segment_time 5 output_%03d.flac
    
    • In this example outputs will be named output_001.flac, output_002.flac, etc.
    • Add -reset_timestamps 1 if your need to reset timestamps at the beginning of each segment.
    • Since you asked there is also the HLS muxer, but that's a different topic from the question title.