[mythtv-users] How to Transcode BBC HD and keep AC3 sound intact.

Another Sillyname anothersname at googlemail.com
Wed Sep 9 16:45:03 UTC 2009


I've noticed assorted postings on the list previously about
transcoding BBC HD material and problems users had keeping the AC3
sound intact and synced.

With the recent slight change to the transmission method of some BBC
HD material I decided to allocate a bit of time to trying to work it
out.

This is NOT a script and needs to be run from the command line, I'll
look to see if there's some way to incorporate this stuff into
nuvexport, I'll also have a look at ITV HD to see whether it works for
that.

You need pretty up to date versions of ffmpeg and mencoder installed
on the machine you intend to transcode with, how to install them is
outside the scope of this so you'll have to google elsewhere.

Firstly create a directory on the machine you intend to perform the
transcode on.

Open a command session and change to the directory you just created
(if you intend to run multiple transcodes simultaneously you need your
command session to be in a different directory for each transcode to
accommodate the 2 pass file log else they interfere with each other).

The following line will do the first pass....

ffmpeg -i /path/to/input/file/and/its/name -vcodec mpeg4 -r 25 -map
0:0 -map 0:3 -ss hh:mm:ss.000 -t hh:mm:ss.000 -acodec copy -b 3600k -s
hd720 -pass 1 /output/file/path/and/name.avi

-vcodec is self explanatory
-r 25 forces the frame rate to 25fps - This should always be correct
for BBC material
-map 0:0 This takes the first stream and outputs it to the output
file, 0:0 is nearly always the video stream
-map 0:3 This takes the fourth stream and outputs it to the output
file, 0:3 is usually the AC3 audio stream
-ss Is where you want to create the new file from, as well as
hh:mm:ss.000 format you can just use seconds
-t Is how long you want the new file to run for, as well as
hh:mm:ss.000 format you can just use seconds
-acodec is self explanatory - I would suggest doing nothing to the stream
-b 3600k Is the bitrate for the recording, 3600k produces a file about
1.1GB for a 40 minute(ish) program - You can dabble here to your own
taste.
-s hd720 Resizes the output file dimensions to 1280x720 You can have
the output file any dimensions you want, use man ffmpeg for other
valid dimensions

When the first pass has finished check the output file for the correct
dimensions, start position and end position, IGNORE timeclock and skip
related issues at this point, I'll fix them shortly.

If you're happy that the new file starts where you want and ends where
you and is the right dimensions then run pass 2

ffmpeg -i /path/to/input/file/and/its/name -vcodec mpeg4 -r 25 -map
0:0 -map 0:3 -ss hh:mm:ss.000 -t hh:mm:ss.000 -acodec copy -b 3600k -s
hd720 -pass 2 /output/file/path/and/name.avi

You'll be asked to confirm you want to overwrite the existing file, say yes.

Once this is finished you should have a good file, however it reports
the end time incorrectly.

The last stage is to re-index the file so that audio and video report
the correct file length.

mencoder /path//to/output/file/above.avi -oac copy -ovc copy -forceidx
-o /path/to/new/output/file.avi

You should now have a fully working transcode of the BBC HD material,
resized to 720p and with AC3 sound working and in sync.

As an example a 40 minute BBC recording takes about 9-10GB in the
original format, without any noticeable loss of quality (subjective I
realise) this comes down to about 1GB.

I've tried this now on about 6 different recordings and it seems to
work OK, if anyone has problems please post in the thread.


More information about the mythtv-users mailing list