[mythtv-users] gopdit, for MPEG-2 -> MPEG-2 cutting

Cory Papenfuss papenfuss at juneau.me.vt.edu
Fri Mar 4 12:46:45 UTC 2005


>  http://home.t-online.de/home/rhtm.e/gopdit/
>
> I've seen this program mentioned once here, but think maybe it
> deserves highlighting, as it seems to answer a frequent question:
> how to quickly cut out commercials from an MPEG-2 stream without
> re-encoding the whole thing or losing audio/visual sync (as happens
> with avidemux).
>
 	There's still a bit of unknown here.  When the Hauppauge card 
glitches (as is more often then case when trying to record from a tape, 
rather than from cable/broadcast), it will fix a broken frame by adjusting 
the PTS/DTS.  That is why avidemux breaks.... it can only handle a single, 
static offset between A and V.... changing the PTS/DTS mid-stream isn't 
handled correctly by avidemux and sync breaks.  I haven't looked through 
the code of gopdit enough yet, but from talking with the author, I think 
that nothing is done to correct the big "time-hole" left when a commercial 
is cut out.  Most players will play it anyway, but trying to edit a 
cut file might not work.  Replex seemed to glue it back together, 
though...

> Gopdit does this by cutting at GOP boundaries, and doing no
> re-encoding.  The author uses it specifically for streams from ATI
> and Hauppauge encoders.  I tested it with something I recorded using
> "cat /dev/video0 > file.mpg" using my PVR-350, and the trimmed file
> had no a/v sync problems.
>
 	There's more issues here.  As gopdit docs claim, if the GOPs are 
closed, it works better than if they're open.  I'm still not completely 
sure how the streams out of the PVR-250, but I *have* seen both open 
(ivtv-0.1.9 capture) and closed (ivtv-0.1.100zz or whatever).  Gopdit 
marks the cut GOPS (correctly) as "broken" according to the MPEG2 spec.

> The 0.2.3-pre experimental version can be run non-interactively (no
> GUI) and take the cutlist from a file.  So this could be used to
> automatically cut commercials if we can figure out how to translate
> myth's cutlist info into one of the formats that gopdit understands.
>
 	I mentioned to the author that there was a need for this a few 
weeks ago and he pounded out the gui-less option.  He said it was still 
rather raw, but it does appear to function.  The nice thing is you can run 
the GUI to set the ~/.gopditrc options, then run it without X to do some 
crunching.

> I've attached the gopdit edit list format info below;  can
> someone tell me how the myth cut list is stored?  The author
> of gopdit expressed willingness to have gopdit support other
> edit list formats, but it might be simpler to get myth to
> generate one of the formats below.
>
 	I wasn't aware that he'd added the ability to deal with other 
cutlist formats.  That's quite good because I belive that the MythTV 
format is a combination of frame and file offset... someone correct me if 
I'm wrong.  An exported .sql of an MPEG-2 .nuv with a cutlist says 
something like this:

INSERT INTO recorded (findid, programid, recgroup, hostname, previouslyshown, lastmodified,cutlist, commflagged, starttime, autoexpire, editing, preserve, endtime, category, deletepending, originalairdate, stars, chanid, description, filesize, subtitle, bookmark, recordid, title, seriesid) VALUES
         ('0', 'EP1031150049', 'Default', 'mythtv.bogus.net', '1', '20050304072930',
'1375 -3537
19199 - 25270
39917 - 47141
62056 - 68987
77522 - 84335
110485 - 111395
', '1', '2005-02-09 06:58:00', '1', '0', '0', '2005-02-09 08:00:00', 
'Documentary', '0', '00
00-00-00', '0', '1049', 'The Alaska pipeline carries crude oil 800 miles 
across the state.',
  '1669148608', 'The Alaskan Oil Pipeline', NULL, '703', 'Modern Marvels', 
'SH103115');

<The big SNIP>

       ('1373', '2005-02-09 06:58:00', '6', '1049', '300929062'),
         ('1374', '2005-02-09 06:58:00', '6', '1049', '301137958'),
         ('1375', '2005-02-09 06:58:00', '3', '1049', NULL),
         ('1375', '2005-02-09 06:58:00', '4', '1049', NULL),
         ('1375', '2005-02-09 06:58:00', '6', '1049', '301355046'),

 	If I'm not mistaken, the 1375-3537, etc are the frames in the 
cutlist, and the '301355046' is the file offset.  What I don't understand 
is that on the one hand the '6' in #1375 says it's a MARK_GOP_START = 6, 
(from programinfo.h).  It's also a MARK_BLANK_FRAME = 3 and 
MARK_COMM_START = 4.  How can it be a GOP start point on one hand, but a 
frame count in the other?

 	Anyway, I would say that all the data is there (whether it be file 
offset or frame number).  It shouldn't be a big deal to convert it into 
gopdit.

-Cory

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



More information about the mythtv-users mailing list