PDA

View Full Version : Distributed transcoding problems


unidog
11th March 2005, 04:15
For a university project I'm working on a distributed transcoding environment to convert a given mpeg 2 video stream to a mpeg 1 stream.
But I'm running into trouble, so here is the full story ;) :

I have to use BOINC [1] to take care of the distribution and result gathering work. This means I have to supply work-units and an application, so I split the original mpeg 2 movie into several +/-5MB chunks using mpgtx [2] which works on a GOP basis. For the application I wrote a small client-app that calls ffmpeg to do the encoding part.

But I've run into trouble when merging the result files. Since the last frames of the final GOP in the chunks are made of B-frames, I also include the following GOP. That way the B-frame can use the previous P- and next I-frame...

Rejoining this chunks with something like 'mpgtx -j chunk-001.mpg [-0:04.30[ chunk-002.mpg -o chunk.mpg' (where 0:04.30 is the time of the movie given with mpgtx -i chunk-001.mpg) gives a perfect movie... so I suppose mpgtx is doing its job the right way.

Tried to encode the files without the extra trailing gop, but the result I got was missing 2 frames at the end, probably the last 2 B-frames of the mpeg2 gop.
The command used was something like 'ffmpeg -y -i chunk-00${I}.mpg -aspect 4:3 -sgop -hq -target pal-vcd out-${I}.mpg'.
Joining these result files gave a movie that wasn't fluent, or at least not for the entire movie.


So, I now add a final GOP to the end of the chunks, and use ffmpeg as
'ffmpeg -y -i chunk-00${I}.mpg -target pal-vcd -aspect 4:3 -sgop -hq -g 12 -sc_threshold 1000000000 out-001.mpg'

This should convert the mpeg2 file to a mpeg1 file, using an aspect ratio of 4:3, and a GOP size of 12 (the sgop and sc_threshold are used to enforce this gop size). The gop size is set to 12 because that's the gop size of the original mpeg2 movie, which makes it easy to remove the double gop.

The problem however is that the encoded mpeg1 files have a couple of identical frames in the beginning of them (a I-frame followed by 2 P-frames). I guess this has something to do with the mpgtx program, which I think splits the mpeg2 files before the I-frame of the next gop; but since the frames are stored in another order than they are played, that gop also got 2 frames in it which are actually from the previous gop. Joining these results together when removing the last gop of each part also gives a movie with some faults in it.

I hope all of this makes sense ;)

So, my question: has anyone experience with splitting, encoding and rejoining mpeg2 to mpeg1 movies in linux, and if so, how are you doing it? Or, anyone got an idea how I can remove the first 2 frames of a movie using a linux command line program?


Thanks.


[1] http://boinc.berkeley.edu
[2] http://mpgtx.sourceforge.net