Manually transcoding with mencoder and tsMuxeR

For help and support with issues specific to Mac OS X
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply.

Manually transcoding with mencoder and tsMuxeR

Postby Raptor399 » Tue May 31, 2011 7:48 am

Hi,

I wonder how to manually transcode a Quicktime Movie using mencoder and tsMuxer.
PMS is basically a graphical interface around shell commands, so based on the commands in the debug.log it should be possible to recreate the same steps.

Here is what I have come up with so far:
Code: Select all
#!/bin/bash
# test.sh - Script to test mencoder and tsMuxeR  on OSX without the noisy PMS log messages
# - Install PS3 Media Server
# - Download a QuickTime movie (e.g. from trailers.apple.com), save it as "test.mov"
# - Run this script with "sh test.sh"
MENCODER="/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder"
TSMUXER="/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/tsMuxeR"

# PMS would create this file
if [ ! -f tsMuxeR.meta ]; then
    cat > tsMuxeR.meta <<EOM
MUXOPT --no-pcr-on-video-pid --new-audio-pes --no-asyncio  --vbr --vbv-len=500
V_MPEG4/ISO/AVC, "video", fps=25, level=4.1, insertSEI, contSPS, track=1
A_AC3, "audio", track=2
EOM
fi

# Same as PMS calls from debug.log, but stripped of "-quiet" and "-really-quiet" arguments and used simple filenames
"$MENCODER" -ss 0 test.mov -msglevel statusline=2 -ovc copy -nosound -mc 0 -noskip -of rawvideo -o video
"$MENCODER" -ss 0 test.mov -msglevel statusline=2 -channels 6 -ovc copy -of rawaudio -mc 0 -noskip \
    -oac lavc -lavcopts acodec=ac3:abitrate=256 -af lavcresample=48000 -srate 48000 -o audio

"$TSMUXER" tsMuxeR.meta video.mp4


The mencoder bit works, but tsMuxer bugs out with an error.
Somehow PMS seems to be able to make it work and generate some output, though. :?:

How do I get this to work?
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Manually transcoding with mencoder and tsMuxeR

Postby Raptor399 » Wed Jun 01, 2011 9:35 pm

The answer is: "not".

It turns out that PMS is modifying the mencoder video output by inserting headers in "net/pms/io/PipeIPCProcess.java":
Code: Select all
if (modifier != null && modifier.isH264_annexb()) {
   in = new H264AnnexBInputStream(in, modifier.getHeader());
}

and "net/pms/util/H264AnnexBInputStream.java" adds some magic bytes to the stream.
That is why the raw mencoder output makes tsMuxeR crash when executing commands in the shell, while it works in PMS.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Manually transcoding with mencoder and tsMuxeR

Postby Raptor399 » Wed Jun 01, 2011 11:18 pm

Turns out you can actually get PMS to generate the output for you.
Uncomment the following in "net/pms/io/PipeIPCProcess.java":

Code: Select all
      /*try {
         debug = new FileOutputStream(System.currentTimeMillis() + "debug");
      } catch (Exception e1) {}*/


and recompile PMS. PMS will now duplicate the streams as "/Applications/PS3\ Media\ Server.app/Contents/Resources/Java/*debug".

The biggest file is what the "video" file should have been, so copy it over the generated "video" file and outcomment the video generating line in the script.
Since PMS does not touch the audio stream - well, not in my testcase anyway - there is no need to copy that debug file.

Run the script and - lo and behold! - it results in a file being generated! 8-)
This file can be played directly on the PS3, just copy it in a directory shared by PMS.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am


Return to Mac OS X Support

Who is online

Users browsing this forum: No registered users and 3 guests