[mythtv-users] Re: Anyone tried MPEG2 to MPEG2 transcoding?

Cory Papenfuss papenfuss at juneau.me.vt.edu
Thu Jul 21 12:09:23 EDT 2005

> Someone tried a couple of years ago to get mpeg2 transcoding to work, and 
> could never get it to work properly.  That's why Gavin (Beirdo) wrote the 
> mpeg2cut module for me to include in nuvexport.  So far, avidemux is the 
> *only* program capable of true lossless mpeg2 cutting (without resorting to 
> cutting at a GOP, which is not good enough). Then, in his tests, he 
> discovered that lvemux was the only program capable of stitching the audio 
> and video back together without sync problems.
 	The problem (as I've painfully discovered and discussed before) is 
that the ivtv cards change the audio and video relative timestamps (PTS, 
DTS, etc).  That information is at the PS level, and avidemux blindly 
strips PS into A and V.  If the sync offset isn't constant, it gets off as 
the clip progresses

> Unfortunately, afaik, lve does NOT work with fedora core 3 or later (along 
> with some other modern distros -- I forget the exact library conflict), 
> preventing mpeg2cut from doing its job.
> Now, he's been working on extracting the relevant portions from each of those 
> programs into a single app (esp. so that it wouldn't require X or anything 
> like that), but it will likely take him awhile to finish.
 	It's a difficult problem that few programs have been able to 
solve.  ProjectX seems to be the closes, but I've heard the streams it 
produces has other issues.  In particular, think of cutting out a chunk of 
a clip where the PTS changes... do you now have to parse *all* MPEG 
packets thereafter to update to the new PTS less changes and the 4-5 
minutes of commercials removed?  Also, forward/backward GOP references get 

 	Ideally, that's what the lossless cutter would do, though.  Parse 
the whole stream, and either cut on GOPs fixing all timestamps along the 
way, or even better would be to reencode around GOP boundaries at 
cutpoints for frame-accurate edits.

 	I would also suggest that a "lossy" reencode to MPEG2 would not be 
without merit at the point in time.  People have struggled with getting 
MPEG2 captures burned to DVD (sans commercials) for the same reasons as 
above.  As I understand it, transcoding from within Myth basically 
decodes (using the myth playback engine with *can* parse A/V correctly), 
then reencodes.  Although it would be time consuming and introduce a 
generation loss, adding an {MPEG2, MPEG4, RTJPEG}->MPEG2 as a transcoder 
would be useful as a stopgap at this point.

> For now, if all you want to do is save space, just transcode to mpeg4 with 
> mythtv (keep in mind, it's optimized for encoding speed, not quality), or if 
> you have the time, run nuvexport's xvid exporter (I prefer transcode, but it 
> defaults to ffmpeg).  Nuvexport's default xvid settings should give you about 
> 350M/hour (minus commercials) at 624x464 (weird res, but that's how the 
> calculations best come out after you crop 2% of the edges to get rid of 
> broadcast noise).

 	Speaking of that, anyone ever tried for a high-quality version? 
Something like a 2-pass encode with denoising, etc?



* Cory Papenfuss                                                        *
* Electrical Engineering candidate Ph.D. graduate student               *
* Virginia Polytechnic Institute and State University                   *

More information about the mythtv-users mailing list