Quite often I try to play videos encoded in mkv on my playstation 3 over the network. I use PS3 Media Player on my Mac. Unfortunately, PS3 Media Player tries to transcode the mkv video to mp4 before streaming it to the playstation – and my 2007 iMac is too slow to do this when it comes to HD (720p and above). Hence I was looking for a way to losslessly convert the file format from mkv to mp4 beforehand, so that the PS3 Media Player can simply pipe the video through the network. And guess what: it is straight forward and very simple.
You will need Macports to do this.
1. Install ffmpeg
sudo port install ffmpeg +nonfree
2. Convert a video
ffmpeg -y -i INPUT.mkv -c copy OUTPUT.mp4
2a. Convert a video while shuffling around the audio streams
Assuming you have an input video file with multiple audio streams but your output file should only have one.
First, check the streams in the input file
$ ffmpeg -i INPUT.mkv [...] Stream #0:0: Video: h264 [...] Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default) Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s [...]
Assume you only want the german audio, you can convert the video as follows:
ffmpeg -y -i INPUT.mkv -c copy -map 0:0 -map 0:1 OUTPUT.mp4
The “-map” options tell ffmpeg to put input stream 0 into output file 0. Also, input stream 1 is put into output file 0. Input stream 2 will not be used.