# *HOWTO* Convert MKV files to PS3 Playable Files

## komp

I dont have time to come to this forum and update the code.

From now on please refer to http://www.vgwatchdog.com/?p=3989 for your ps3 transcoding tools.

Thanks

kompLast edited by komp on Sat Sep 27, 2008 3:50 pm; edited 6 times in total

----------

## nixnut

Moved from Multimedia to Documentation, Tips & Tricks.

----------

## komp

I have had a report of no video but proper audio on some files!  But it still plays and reports correctly on the PS3.

Im looking into this and I have noticed that some streaming software is trying to be too clever with the mime type.

Ill report back with my findings shortly.

Please let me know if this is happening to you.

Rgds

EDITED 12-MAR-2008 :- Added mp4creator HINT addition.

----------

## komp

Here is a FULL output of the script running successfully for those wanting to compare theyre samples.

###

###

##

#

linuxbox# ./ps3convertmkv1 london.roller.girls.pinkvsblack.roller.derby.mkv

EXECUTING COMMAND: mkinfo london.roller.girls.pinkvsblack.roller.derby.mkv

This video is 31.250  frames per second

This audio is 6 Channels. (2=Stereo / 6=Dolby 5.1 / DTS)

We got the first track and it is type AUDIO

We got the second track and it is type VIDEO

Now splitting tracks to seperate files + Wed Mar 12 19:57:10 GMT 2008

Extracting track 1 with the CodecID 'A_AC3' to the file 'audio.ac3'. Container format: Dolby Digital (AC3)

Extracting track 2 with the CodecID 'V_MPEG4/ISO/AVC' to the file 'video.h264'. Container format: AVC/h.264 elementary stream

progress: 100%

Now converting to make it H264 4.1 instead of H264 5.1.  This wont take too long. + Wed Mar 12 19:57:53 GMT 2008

Now remuxing audio and video.

Sorting out the Dolby 5.1 audio

This may take a little longer if not 6 channel audio

*************************************************************

*                                                           *

*  Nero Digital Audio Reference MPEG-4 & 3GPP Audio Encoder *

*  Copyright 2007 Nero AG                                   *

*  All Rights Reserved Worldwide                            *

*                                                           *

*  Package build date: Aug  6 2007                          *

*                                                           *

*                                                           *

*  See -help for a complete list of available parameters.   *

*                                                           *

*************************************************************

MPlayer 1.0rc2-4.1.1 (C) 2000-2007 MPlayer Team

CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz (Family: 15, Model: 4, Stepping: 1)

MMX supported but disabled

MMX2 supported but disabled

SSE supported but disabled

SSE2 supported but disabled

CPUflags:  MMX: 0 MMX2: 0 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0

Compiled for x86 CPU with extensions:

Playing audio.ac3.

libavformat file format detected.

[lavf] Audio stream found, -aid 0

==========================================================================

Opening audio decoder: [liba52] AC3 decoding with liba52

No accelerated IMDCT transform found

No accelerated resampler found

AUDIO: 48000 Hz, 6 ch, s16le, 448.0 kbit/9.72% (ratio: 56000->576000)

Selected audio codec: [a52] afm: liba52 (AC3-liba52)

==========================================================================

[AO PCM] File: audiodump.wav (WAVE)

PCM: Samplerate: 48000Hz Channels: Stereo Format s16le

[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast

[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).

AO: [pcm] 48000Hz 6ch s16le (2 bytes per sample)

Video: no video

Starting playback...

A:2510.5 (41:50.5) of 2510.5 (41:50.5)  3.4%

Exiting... (End of file)

The video isnt exactly compliant right now, I am going to add some proper data to the video like hints  :Smile: 

Error decoding sei message

MP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[0].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeId

MP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[1].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeId

Muxing the files up now, hang on, 2 ticks  :Smile: 

IsoMedia import - track ID 1 - Video (size 1280 x 720)

IsoMedia import - track ID 2 - media type "hint:rtp "

IsoMedia import - track ID 1 - HE-AAC (SR 24000 - SBR-SR 48000 - 6 channels)

Saving to london.roller.girls.pinkvsblack.roller.derby.mp4: 0.500 secs Interleaving

Cleaning up temp files

Deleted audio + video + Hex Backup File

Now finished + Wed Mar 12 20:15:47 GMT 2008

Now place the finished file on your DnLA server or bung it on a USB key

NEXT....

##################

Those errors listed make no difference from what I can see.

17 mins to remux  :Smile: 

----------

## HeissFuss

Thanks for the script komp  :Smile:   It works great.

I was just about to pound one of these out myself before I found your post.

Two things that I'm wondering about though.  Could you add optional output directory/alternate filename?  Also, PS3 supports AC3 audio without conversion provided that it's in an mpeg/vob or avi container.  Unfortunately MP4 doesn't support dolby audio streams, thus the need for conversion.  Do you have any plans of optionally muxing into one of the ac3 supported containers if given an ac3 stream?  That's the issue that I ran into and my attempts at using transcode were dismal failures.

----------

## komp

 *HeissFuss wrote:*   

> Thanks for the script komp   It works great.
> 
> I was just about to pound one of these out myself before I found your post.
> 
> Two things that I'm wondering about though.  Could you add optional output directory/alternate filename?  Also, PS3 supports AC3 audio without conversion provided that it's in an mpeg/vob or avi container.  Unfortunately MP4 doesn't support dolby audio streams, thus the need for conversion.  Do you have any plans of optionally muxing into one of the ac3 supported containers if given an ac3 stream?  That's the issue that I ran into and my attempts at using transcode were dismal failures.

 

Yep I certainly do  :Smile: 

Glad you found the script of use.

I am working on a way of making the audio more compatible with non AAC amps.

I am also looking at making AVC/HD .m2ts files from Matroska source.  So far I have it down to 17mins on a P4-3Ghz CPU.  

Are people concerned about Speed or Features (audio.video) ?

Ill be posting here when I am complete shortly.

----------

## magic919

Great work for a n00b, cheers Komp.  I'm watching for the next phase  :Smile: 

----------

## komp

Quick update :-

I have found that the PS3 will not play any files that have DPB Reference frames more than 3.

NonworkingFile.h264

Picture:

Picture No              : -1

Picture Order Count     : 0

Decoding No             : 0

--------------------------------------------------------

PSNR                    : No ref yuv file

--------------------------------------------------------

Picture Size            : 0x0

Encoding Type           : CABAC

Stream:

Stream Type             : High Profile @ Level 51

Video Type              : Component

Video Format            : YUV420

POC Type                : 0

Timing Type             : Fixed

Max FPS                 : 23.976024

HRD Type                : Not Present

Bit Rate                        : Not Present

CPB Size                        : Not Present

DPB Size                        : 7

Max Ref Frames Num      : 7

workingfile.h264

Picture :

Picture No              : -1

Picture Order Count     : 0

Decoding No             : 0

--------------------------------------------------------

PSNR                    : No ref yuv file

--------------------------------------------------------

Picture Size            : 0x0

Encoding Type           : CABAC

Stream:

Stream Type             : High Profile @ Level 51

Video Type              : Component

Video Format            : YUV420

POC Type                : 0

Timing Type             : Fixed

Max FPS                 : 23.976024

HRD Type                : Not Present

Bit Rate                        : Not Present

CPB Size                        : Not Present

DPB Size                        : 3

Max Ref Frames Num      : 3

Unfortunately this means a new re-encode and thus you will loose a portion of quality, this is just because the more you (re)endcode it just degrades a little.

So if I have to reencode the video in the script based of a decision in the script loop I may as well add the options to reecode the h264 with ac3 into a mpg/vob/ts and thus we will benefit from the Dolby Digital 5.1 as opposed to AAC 5.1

If anyone knows a better fix then please let me know.

----------

## HeissFuss

What are the resolutions of those two samples?

I'm looking forward to your new script.  Please post whenever you have a semi-working version   :Smile: 

----------

## stokesie

can i just ask

does this script work with mediatomb to transcode on the fly

or is it to just convert mkv files

 :Confused: 

----------

## HeissFuss

This is just for converting mkv to ps3 playable mp4 files.

----------

## stokesie

do you have a script for converting wmv to mp4 as my wmv`s have video but no sound.

or any ideas  :Question: 

----------

## BT

stokesie,

You may want to take a look at the transcoding scripts on the MediaTomb HOWTO. You have a choice between VLC and FFmpeg scripts with each having a separate audio and video script. The video scripts will by default convert any video to MPEG-2, but this can be easily changed by modifying the VIDEO_CODEC variable to what ever codec you need.Last edited by BT on Wed Nov 05, 2008 4:11 am; edited 2 times in total

----------

## stokesie

good idea BT

would the codec in my vlc or ffmpeg transcode script change from VIDEO_CODEC="mp2v" to VIDEO_CODEC="mp4v"

the thing is that i had corrupt file message on ps3 when i tried to transcode mkv even though the thumbnail bit works.

is it due to my pc u think not being meaty enough, its a P4 2.4GHz with 1GB mem.

i tried playing on pc with vlc & mplayer but sort of crashie.

anyway the script worked for mkv to mp4 with a few error messages but the result was ok.

so tried to google wmv to mp4 with no real joy.

i am sure that my mediatomb config is fine for transcode hear it is below

<?xml version="1.0" encoding="UTF-8"?>

<config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">

  <server>

    <ui enabled="yes">

      <accounts enabled="no" session-timeout="30">

        <account user="mediatomb" password="mediatomb"/>

      </accounts>

    </ui>

    <name>MediaTomb</name>

    <udn>uuid:70ae94ba-a75b-4912-8366-bee7cdec813e</udn>

    <home>/var/lib/mediatomb</home>

    <webroot>/usr/share/mediatomb/web</webroot>

    <storage>

      <sqlite3 enabled="yes">

        <database-file>mediatomb.db</database-file>

      </sqlite3>

      <mysql enabled="no">

        <host>localhost</host>

        <database>mediatomb</database>

        <username>mediatomb</username>

        <password>mediatomb</password>

      </mysql>

    </storage>

    <protocolInfo extend="yes"/>

  </server>

  <import hidden-files="no">

    <scripting script-charset="UTF-8">

      <common-script>/usr/share/mediatomb/js/common.js</common-script>

      <playlist-script>/usr/share/mediatomb/js/playlists.js</playlist-script>

      <virtual-layout type="builtin">

        <import-script>/usr/share/mediatomb/js/import.js</import-script>

      </virtual-layout>

    </scripting>

    <mappings>

      <extension-mimetype ignore-unknown="no">

        <map from="mp3" to="audio/mpeg"/>

        <map from="ogg" to="application/ogg"/>

        <map from="asf" to="video/x-ms-asf"/>

        <map from="asx" to="video/x-ms-asf"/>

        <map from="wma" to="audio/x-ms-wma"/>

        <map from="wax" to="audio/x-ms-wax"/>

        <map from="wmv" to="video/x-ms-wmv"/>

        <map from="wvx" to="video/x-ms-wvx"/>

        <map from="wm" to="video/x-ms-wm"/>

        <map from="wmx" to="video/x-ms-wmx"/>

        <map from="m3u" to="audio/x-mpegurl"/>

        <map from="pls" to="audio/x-scpls"/>

        <map from="flv" to="video/x-flv"/>

        <map from="avi" to="video/x-divx"/>

        <map from="divx" to="video/x-divx"/>

        <map from="mkv" to="video/x-matroska"/>

      </extension-mimetype>

      <mimetype-upnpclass>

        <map from="audio/*" to="object.item.audioItem.musicTrack"/>

        <map from="video/*" to="object.item.videoItem"/>

        <map from="image/*" to="object.item.imageItem"/>

      </mimetype-upnpclass>

      <mimetype-contenttype>

         <treat mimetype="audio/mpeg" as="mp3"/>

        <treat mimetype="application/ogg" as="ogg"/>

        <treat mimetype="audio/x-flac" as="flac"/>

        <treat mimetype="image/jpeg" as="jpg"/>

        <treat mimetype="audio/x-mpegurl" as="playlist"/>

        <treat mimetype="audio/x-scpls" as="playlist"/>

        <treat mimetype="audio/x-wav" as="pcm"/>

        <treat mimetype="audio/L16" as="pcm"/>

        <treat mimetype="video/x-msvideo" as="avi"/>

        </mimetype-contenttype>

    </mappings>

  </import>

<transcoding enabled="yes">

    <mimetype-profile-mappings>

      <transcode mimetype="application/ogg" using="audio-ffmpeg"/>

      <transcode mimetype="application/ogg" using="video-vlc"/>

      <transcode mimetype="audio/x-flac" using="audio-ffmpeg"/>

      <transcode mimetype="video/x-flv" using="video-vlc"/>

      <transcode mimetype="video/x-matroska" using="video-vlc"/>

      <transcode mimetype="video/x-divx" using="video-thumbnail"/>

      <transcode mimetype="audio/x-flac" using="video-ffmpeg"/>

        <transcode mimetype="video/x-ms-wmv" using="audio-ffmpeg"/>

<transcode mimetype="video/x-matroska" using="video-thumbnail"/>

        </mimetype-profile-mappings>

    <profiles>

      <profile name="audio-ffmpeg" enabled="yes" type="external">

        <mimetype>audio/L16</mimetype>

        <accept-url>yes</accept-url>

        <first-resource>yes</first-resource>

        <accept-ogg-theora>no</accept-ogg-theora>

        <agent command="mediatomb-transcode-audio-ffmpeg" arguments="%in %out"/>

        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>

      </profile>

      <profile name="video-vlc" enabled="yes" type="external">

        <mimetype>video/mpeg</mimetype>

        <accept-url>yes</accept-url>

        <first-resource>yes</first-resource>

        <accept-ogg-theora>yes</accept-ogg-theora>

        <agent command="mediatomb-transcode-video-vlc" arguments="%in %out"/>

        <buffer size="10485760" chunk-size="262144" fill-size="524288"/>

      </profile>

<profile name="video-ffmpeg" enabled="yes" type="external">

                <mimetype>video/mpeg</mimetype>

                <accept-url>yes</accept-url>

                <first-resource>yes</first-resource>

                <accept-ogg-theora>yes</accept-ogg-theora>

                <agent command="mediatomb-transcode-video-ffmpeg" arguments="%in %out"/>

                <buffer size="10485760" chunk-size="262144" fill-size="524288"/>

              </profile>

<profile name="video-thumbnail" enabled="yes" type="external">

        <mimetype>image/jpeg</mimetype>

        <accept-url>yes</accept-url>

        <thumbnail>yes</thumbnail>

        <resolution>128x128</resolution>

        <agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 128"/>

        <buffer size="524288" chunk-size="512" fill-size="1024"/>

      </profile>

 </profiles>

  </transcoding>

</config>  :Embarassed: 

----------

## stokesie

 *stokesie wrote:*   

> do you have a script for converting wmv to mp4 as my wmv`s have video but no sound.
> 
> or any ideas 

 

looks like my prob might be that wmv encoded with wmapro codec thats why no sound as ps3 not support

----------

## BT

stokesie,

If your using the scripts with MT then you definitely need to have mp2v for the video codec as the PS3 will only accept MPEG-2 transcoded streams. If your MKV's are encoded with WMA Pro then FFmpeg and VLC will need to support it for transcoding to work. If they don't, then that would explain why your getting the corrupted file message on the PS3.

----------

## stokesie

it seems like my only option is to re-encode my mkv & wmv files @ the mo.

is there anyway the mkv mp4 script can be modified to do wmv to mp4?

----------

## stokesie

 *BT wrote:*   

> stokesie,
> 
> If your using the scripts with MT then you definitely need to have mp2v for the video codec as the PS3 will only accept MPEG-2 transcoded streams. If your MKV's are encoded with WMA Pro then FFmpeg and VLC will need to support it for transcoding to work. If they don't, then that would explain why your getting the corrupted file message on the PS3.

 

the ps3 will stream mp4 as i have copied some trailers from the ps3 to my pc then streamed via media tomb as mp4 files  :Exclamation: 

----------

## stokesie

 *stokesie wrote:*   

>  *BT wrote:*   stokesie,
> 
> If your using the scripts with MT then you definitely need to have mp2v for the video codec as the PS3 will only accept MPEG-2 transcoded streams. If your MKV's are encoded with WMA Pro then FFmpeg and VLC will need to support it for transcoding to work. If they don't, then that would explain why your getting the corrupted file message on the PS3. 
> 
> the ps3 will stream mp4 as i have copied some trailers from the ps3 to my pc then streamed via media tomb as mp4 files 

 

sorry just realised what u said about transcode not stream

----------

## BT

stokesie,

Try playing your MKV's with the WMA Pro audio on your Linux machine. If they playback without audio then I would suspect that FFmpeg and VLC don't support WMA Pro. In that case you would most likely need to use a platform that has support for that codec i.e. Windows. You would then split the audio and video from the MKV, transocde the audio to ACC and then remux the video and audio into a MP4 file, assuming the video is H.264.

----------

## stokesie

BT

i can hear audio when i playback on linux pc even though picture is crashie due to video being 720 or 1080 format

----------

## stokesie

komp,

do you have a wmv to mp4 ps3 version of your script  :Question: 

----------

## BT

stokesie,

I completely forgot to mention that if your using PS3 firmware 2.20 or greater, then MediaTomb transcoding will not work as a result of the firmware updates. The issue seems to be related to audio and users have discovered that setting the audio sample rate to 44100 from 48000 in the video transcoding script works. This workaround hasn't worked in 100% of cases but has for many users so I suggest you try it. If you could also test the MT video transcoding script without using MT, then you can rule out a problem with the script.

Edit: This issue appears to have been fixed with firmware 2.40 or greater.Last edited by BT on Sun Aug 24, 2008 1:07 am; edited 2 times in total

----------

## Zubziro

Hi

I'm just can't get mp4create to work.... script executes just fine with no errors until:

The video isnt exactly compliant right now, I am going to add some proper data to the video like hints  :Smile: 

Error decoding sei message

MP4ERROR: No such file or directory

/usr/bin/mp4creator: can't write video frame 1

MP4ERROR: FindTrackIndex: Track id 1 doesn't exist

/usr/bin/mp4creator: couldn't create hint track, no media samples

anyone know how to handle this ?

those files created efter I ran script:

```

-rw-r--r-- 1   1,5G 31 jul 16.55 allsang.pa.skansen.2008.e06.swedish.720p.hdtv.x264-gay4life.mkv

-rw-r--r-- 1    180 23 aug 09.16 allsang.pa.skansen.2008.e06.swedish.720p.hdtv.x264-gay4life.mp4

-rw-r--r-- 1  258M 23 aug 09.15 audio.ac3

prw-r--r-- 1        0 23 aug 09.16 audiodump.wav

-rw-r--r-- 1   1,2G 23 aug 09.16 video.h264

-rw-r--r-- 1   1,2G 23 aug 09.15 video.h264.bak 

```

PLZ HELP

----------

## Scu

Hi,

I'm noob and retard, and I need some help...I added needed flags and emerged new software very carefully. Here's what I get when I'm trying to run the original script

 *Quote:*   

>  $ ./mkvps3 bob.HDDVD.x264-hV.mkv 
> 
> EXECUTING COMMAND: mkinfo bob.HDDVD.x264-hV.mkv
> 
> ./mkvps3: line 61: /usr/bin/mkvinfo: No such file or directory
> ...

 

I was unable to start mediatomb, was it supposed to be started?

 *Quote:*   

> # /etc/init.d/mediatomb start
> 
>  * Starting MediaTomb ...
> 
> 2008-09-23 13:03:47   DEBUG: [../src/main.cc:184] main(): Starting in deamon mode...2008-09-23 13:03:47   DEBUG: [../src/main.cc:204] main(): Pid file: /var/run/mediatomb/mediatomb.pid
> ...

 

----------

## magic919

Sound like you need to

emerge  media-video/mkvtoolnix

for your first problem.

Check the logs and see what mediatomb is complaining of.

----------

## Scu

Kind a new with this database stuff. Any ideas?

 *Quote:*   

> # /etc/init.d/mediatomb start
> 
> * Starting MediaTomb ...
> 
> 2008-09-23 13:03:47 DEBUG: [../src/main.cc:184] main(): Starting in deamon mode...2008-09-23 13:03:47 DEBUG: [../src/main.cc:204] main(): Pid file: /var/run/mediatomb/mediatomb.pid
> ...

 

----------

## magic919

Should probably post your mediatomb woes in one of the other parts of the forum.  However...

Run

emerge -pv mediatomb

It is complaining that you have no support for MySQL when you built it.

----------

## s34get

please provide the script as a download. Copy & paste leads me to errors regarding special characters.

----------

