Apple HLS streams MPEG-2 TS files containing video and audio data in packetized elementary stream format. These segments (.ts files) can be joined in order to build final video.

Recent version of HLS can now produce segments with video data only in TS files, and audio data only in another TS files. This is used to serve multilanguages video.

Regardless of HLS itself, how can I process to remux TS files containing video data, and audio data, in one TS file? Joining TS files together doesn't work; I get data from first TS file combined with the same type of data from next TS files (only video or audio).

  • I don't know enough to give an actual solution, but some reading seems to indicate that FFMPEG may be able to deal with this.
    – AJ Henderson
    May 14 '14 at 3:02
  • I just checked and yes, you are right. FFmpeg handles HLS with multiple audio tracks. I will take a look at source now.
    – Velcro
    May 14 '14 at 16:47

You can use tsMuxer to add the audio stream from one .ts file into the .ts file containing the video or vice versa. This is called muxing and doesn't affect the quality of the audio or video in any way.


Do you have a m3u8 file? If so, I assume you can just do

ffmpeg -i indexfile.m3u8 -acodec copy -vcodec copy output.ts

You could also convert it directly into the mp4 container:

ffmpeg -i indexfile.m3u8 -acodec copy -vcodec copy output.mp4
  • This does not work when the indexfile.m3u8 has a separate url for audio and a seperate url for video_01.m3u8
    – chovy
    Jun 4 '17 at 20:40
  • @chovy: Can you show me that file? I think it should possibly work with option -map and maybe a second option -i which takes the same inputfile (in your case video_01.m3u8).
    – erik
    Jun 6 '17 at 1:08
  • 1
    it works if i do ffmpeg -i <audio-stream> -i <video-stream> -async 1 -c copy test.m3u8
    – chovy
    Jun 7 '17 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.