Author Topic: Mkv to HLS transcoding with ffmpeg  (Read 3471 times)


  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Mkv to HLS transcoding with ffmpeg
« on: April 30, 2020, 08:24:48 AM »
Hi guys, in Windows10, how can i create a hls file (exporting the corresponding m3u8) from a mkv containing multiple audio tracks and multiple subtitles using FFmpeg ?

I´m trying to convert an mkv file to be streamed in hls (packets), but didn´t understood how to do it.

I have a mkv containing

a) Video in mp4 format (encoded with h264) to be used/transcoded in several different resolutions 640x480, 960x720 etc (in .ts format). I mean, the mkv contains, for example 1280*960 and then export in other other formats as well (640*480 etc)
b) 2 or more audio tracks (encoded as mp3 format) (The output can be in aac or mp3 work as well on streamings ? or it can only be embdeded inside the .ts file_
c) 2 or more subtitles (built with srt or WebVTT format) The desired output format is webvtt

I would like to create a playlist in m3u8 containing several small pieces (something around 256 kb each or 6 seconds per chunk) of .ts file that can allow me to stream the video and all it´s multiple audio and multiple subtitles each one on their own subdirectories.

I tried to follow the commands here : and here:

But i didn´t succeed to make it work.

I tried this command:

ffmpeg -i teste.mkv -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8

It did created the ts and vtt files, but, it did not putted the generated files on their own subdirectories, and neither exported the different audio channels (in case, the test.mkv file contains 2 audio tracks and 2 subtitles) as it shows in the zip file as an example on the 1st link.

How can this be done ?


The goal is to produce similar result as the attached files, except that the input is a mkv file containining multiple audio tracks and multpile subtittles to all of them be exported on their proper formats (and different resolutions) to video on demand production.

Best Regards,

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites: