LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2015, 08:06 AM   #1
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Rep: Reputation: 20
Convert mkv to mp4 in terminal - how?


I want to convert my mkv (Matroska) files to mp4 from the terminal command line . How do I do that?
I have tried a couple of programs but they don't appear to work. FFmulticonverter and Winff don't work. There has to be a better way.

Thanks, gael

Linux Mint 17.02 Cinnamon.

Last edited by gael33; 11-30-2015 at 08:07 AM.
 
Old 11-30-2015, 08:21 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,462

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
The swiss army knife for converting videos is ffmpeg. Alternatively, avconv (a fork of ffmpeg) or mencoder.
 
Old 11-30-2015, 08:27 AM   #3
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by berndbausch View Post
The swiss army knife for converting videos is ffmpeg. Alternatively, avconv (a fork of ffmpeg) or mencoder.
Thanks Bernd, I have tried using ffmpeg through the GUI and I couldn't get it to work
 
Old 11-30-2015, 08:31 AM   #4
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Original Poster
Rep: Reputation: 20
How do I use mencoder?
 
Old 11-30-2015, 08:35 AM   #5
jens
Senior Member
 
Registered: May 2004
Location: Belgium
Distribution: Debian, Slackware, Fedora
Posts: 1,434

Rep: Reputation: 273Reputation: 273Reputation: 273
Do you really need to convert its content as well?
Both are containers and can be converted without re-encoding.

Code:
ffmpeg -i foobar.mkv -vcodec copy -acodec copy foobar.mp4
PS: replace "ffmpeg" with "avconv" if you don't have it.
 
Old 11-30-2015, 08:40 AM   #6
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by jens View Post
Do you really need to convert its content as well?
Both are containers and can be converted without re-encoding.

Code:
ffmpeg -i foobar.mkv -vcodec copy -acodec copy foobar.mp4
PS: replace "ffmpeg" with "avconv" if you don't have it.
Thanks Jens, I take it that the 'foobar' is the name of the mkv file that I want converting?

gael
 
Old 11-30-2015, 08:47 AM   #7
jens
Senior Member
 
Registered: May 2004
Location: Belgium
Distribution: Debian, Slackware, Fedora
Posts: 1,434

Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by gael33 View Post
I take it that the 'foobar' is the name of the mkv file that I want converting?
Yes.

Both mkv and mp4 can (usually) store the same data and don't require re-encoding (saving time and cpu).
 
Old 11-30-2015, 08:54 AM   #8
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Original Poster
Rep: Reputation: 20
gael33@gael33-Aspire-X3950 ~ $ ffmpeg -i Game of Thrones S05E01.mkv -vcodec copy -acodec copy Game of Thrones S05E01.mp4
ffmpeg: command not found

Am I missing something?

gael
 
Old 11-30-2015, 09:02 AM   #9
jens
Senior Member
 
Registered: May 2004
Location: Belgium
Distribution: Debian, Slackware, Fedora
Posts: 1,434

Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by gael33 View Post
ffmpeg: command not found

Am I missing something?
Yes, ... ffmpeg
Replace ffmpeg with avconv (ffmpeg was forked because of its bad management, luckily they've fixed their issues and it will soon be available in the "main" repo again).

Last edited by jens; 11-30-2015 at 09:56 AM.
 
Old 11-30-2015, 09:03 AM   #10
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,462

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Quote:
Originally Posted by gael33 View Post
gael33@gael33-Aspire-X3950 ~ $ ffmpeg -i Game of Thrones S05E01.mkv -vcodec copy -acodec copy Game of Thrones S05E01.mp4
ffmpeg: command not found

Am I missing something?

gael
Yes, you are probably missing the command. You have to find out how to install it on Mint.
A few years ago the ffmpeg community split in two, and a new tool named avconv was born, initially practically identical to ffmpeg. Debian used to include avconv in its repositories rather than ffmpeg, perhaps Mint is the same.
I hear that the latest Debian has moved back to ffmpeg.
 
Old 11-30-2015, 10:25 AM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134Reputation: 2134
handbrake is a very nice CLI tool for compressing and encoding mkv files in mp4. I use it all the time for compressing my blu-ray mkv rips to mp4.

You can get the source here:
https://handbrake.fr/downloads.php

Once you have the prerequisites installed, you can build it with:
Code:
./configure
cd build
make
gmake
make install
Then to run it:
Code:
HandBrakeCLI -Z "AppleTV 3" -s scan -F --subtitle-burned -N eng -i file.mkv -o file.mp4
This part:
-Z "AppleTV 3"
uses the Apple TV 3 preset, which is a high quality 1080p low compression set of flags. There are plenty of other presets for other resolutions and compression ratios, or you can set the flags individually if you want.

This part:
-s scan --subtitle-burned -N eng
scans the mkv file for forced or temporary English subtitles (portions of the video that are in another language and subtitled) and burns them into the video stream.
 
Old 11-30-2015, 03:08 PM   #12
phantomfreak
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Rep: Reputation: Disabled
Quote:
Originally Posted by gael33 View Post
gael33@gael33-Aspire-X3950 ~ $ ffmpeg -i Game of Thrones S05E01.mkv -vcodec copy -acodec copy Game of Thrones S05E01.mp4
ffmpeg: command not found

Am I missing something?

gael
To install ffmpeg in ubuntu based derivatives

Code:
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg
 
Old 11-30-2015, 03:33 PM   #13
gael33
Member
 
Registered: Feb 2009
Location: Scotland
Distribution: Linux Mint 18.3 Cinnamon 64 bit
Posts: 316

Original Poster
Rep: Reputation: 20
Okay, I would like to thank everyone who made important suggestions, I can now use the terminal to change file formats, although somewhere along the line I updated Handbrake to 0.10.2 (x86_64) and can now easily reformat video from Matroska to mp4 using a super interface (GUI).

Thanks again,

gael.
 
Old 11-30-2015, 03:42 PM   #14
phantomfreak
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Rep: Reputation: Disabled
Yeah, handbrake is great. I use the commandline version mostly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert mkv to mp4 to play on PS3 ? robertpolson Linux - General 1 09-11-2007 03:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration