How to convert mkv file (with multiple audio track) to ogv format by presrving all the audio track?

Is it possible to create a ogg file (audio) with multiple track?


In Linux, you have a universal media conversion program called avconv (alternatively ffmpeg). In basic form it is controlled by extensions, so avconv -i input.mkv output.ogm will do the proper conversion.

However, to preserve all streams, you need to use -map option. Let me just cite the manual:

-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]] | [linklabel] (output)
           Designate one or more input streams as a source for the output file. Each input stream is identified by the input file index input_file_id and
           the input stream index input_stream_id within the input file. Both indices start at 0. If specified, sync_file_id:stream_specifier sets which
           input stream is used as a presentation sync reference.

           The first "-map" option on the command line specifies the source for output stream 0, the second "-map" option specifies the source for output
           stream 1, etc.

           A "-" character before the stream identifier creates a "negative" mapping.  It disables matching streams from already created mappings.

           An alternative [linklabel] form will map outputs from complex filter graphs (see the -filter_complex option) to the output file.  linklabel
           must correspond to a defined output link label in the graph.

           For example, to map ALL streams from the first input file to output

                   avconv -i INPUT -map 0 output

           For example, if you have two audio streams in the first input file, these streams are identified by "0:0" and "0:1". You can use "-map" to
           select which streams to place in an output file. For example:

                   avconv -i INPUT -map 0:1 out.wav

           will map the input stream in INPUT identified by "0:1" to the (single) output stream in out.wav.

           For example, to select the stream with index 2 from input file a.mov (specified by the identifier "0:2"), and stream with index 6 from input
           b.mov (specified by the identifier "1:6"), and copy them to the output file out.mov:

                   avconv -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov

           To select all video and the third audio stream from an input file:

                   avconv -i INPUT -map 0:v -map 0:a:2 OUTPUT

           To map all the streams except the second audio, use negative mappings

                   avconv -i INPUT -map 0 -map -0:a:1 OUTPUT

           Note that using this option disables the default mappings for this output file.

So you will need this:

avconv -i nput.mkv -map 0:v -map 0:a output.ogm

And yes, you can store multiple tracks, and even video and text, in OGG file, because it is a universal media container.

| improve this answer | |

You can use dmMediaConverter and in Convert mode and put ogg or ogv extension in the output file like audio.ogg. Also, uncheck "Enable" on video stream it is audio only. You can copy the streams if them are accepted by this container. h264/h265/vp8/vp9 is not accepted by ogg.

enter image description here

| improve this answer | |
  1. First use ffmpeg to identify the audio stream encoding.
  2. Then use ffmpeg to extract the audio stream (in original encoding).
  3. Then, if you really want you could re-encode it to ogg. But it might be most useful to keep the original audio encoding.

  4. First use ffmpeg to identify the audio stream encoding.

    $ ffmpeg -i $f
    Stream #0:0(und): Video: h264 (Main), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, s16 (default)
  5. Then use ffmpeg to extract the audio stream (in original encoding to .mka format).

    ffmpeg -i song.mkv -acodec: copy -vn song.mka

I found this useful:


And this is a really good tip:

Note: Whenever you are in doubt (don’t know what extension to use), then you can simply use the ‘.mka’ extension (‘output.mka‘). Because ‘MKA’ container format can store a huge number of audio codecs. If you choose that however, then some players might not be able to play the audio track. So please be aware of that.

A useful script to convert any mmv and mp4 to mka audio (keeping original audio encoding): convert_vtoa.sh


for f in *.mkv *.mp4; do 
    # ffmpeg -i $f
    echo -n bn=$bn
    if [[ ! -e "$bn.mka" ]] ; then
        echo ffmpeg -i "$f" -acodec: copy -vn "$bn.mka"
        ffmpeg -i "$f" -acodec: copy -vn "$bn.mka"
        echo "      ##### already done. #####"
| improve this answer | |

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.