Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
285
rated 0 times [  285] [ 0]  / answers: 1 / hits: 356510  / 3 Years ago, sun, may 23, 2021, 8:07:20

I need to convert a video file from Matroska container into mp4 container. Matroska file contains one h.264 video track and one AC3 sound track. It should be possible to do this losslessly, but how to do it with native Ubuntu tools?



Transcoding is not an option.


More From » ffmpeg

 Answers
4

Perhaps the easiest tool for that is ffmpeg, or avconv from the libav-tools package. Libav is a fork of FFmpeg, which Ubuntu switched to for a few years until Ubuntu 15.04. It is one of the backends for many of the GUI tools mentioned in other answers.



Changing container without re-enconding content could not be simpler:



ffmpeg -i input.mkv -codec copy output.mp4



  • It auto-detects a Matroska to MP4 container conversion based on input/output filenames.


  • -codec copy stream copies, or "re-muxes", the streams from the input to the output without re-encoding. Think of it like a copy and paste.


  • Default stream selection behavior is to select only one stream per stream type. For example, if your input has two video streams and one audio stream then only the video stream with the largest frame size will be selected. Add -map 0 if you want to select all streams from the input.


  • Some containers may not support some formats. So check if your chosen container format, be it mkv, mp4 or even avi has support for all the content in your files (video, audio, subtitles, data, etc). For example, mp4 does not support SubRip subtitles (.srt files).



[#44459] Tuesday, May 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zzlingots

Total Points: 414
Total Questions: 130
Total Answers: 117

Location: Sudan
Member since Tue, Sep 15, 2020
4 Years ago
;