home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / LINUX / gopchop-1.1.7.tar.tar / gopchop-1.1.7.tar / gopchop-1.1.7 / README < prev    next >
Text File  |  2005-05-02  |  14KB  |  325 lines

  1. gopchop - MPEG2 GOP-accurate editor
  2. http://gopchop.org/
  3. Development Version: 1.1.x
  4. Released under GNU General Public License
  5. Kees Cook (kees@outflux.net)
  6.  
  7.  
  8. This tool is used for people wanting to take sections out of MPEG2-PS 
  9. files without re-encoding the resulting frames.  The idea is to write 
  10. specific "Group of Pictures" (GOP) sections to a new MPEG2-PS file.  These 
  11. GOPs will decode correctly (in theory), and the gaps won't be noticed.  I 
  12. wrote this tool to edit commercials out of MPEG2 files produced by my 
  13. KFir MPEG2 capture card.  Using this tool for anything else is really beyond
  14. the scope of its design.
  15.  
  16.  
  17. Requirements
  18. ------------
  19. For gopchop to work, you need two things installed: GTK-1.2, and the 0.4.0
  20. version of mpeg2dec (see http://libmpeg2.sourceforge.net/).  Newer versions
  21. of libmpeg2 may or may not work, depending on the API changes.
  22.  
  23.  
  24. Configuring/Compiling
  25. ---------------------
  26. "./configure" should do the trick.  If you some pre-3.0 version of gcc,
  27. you may have Issues(tm) compiling (and running).  I'd recommend using
  28. 3.0+ of gcc and g++.  If you have both packages installed (RedHat 7.2),
  29. you can run "CC=gcc3 CXX=g++3 ./configure" to force configure to use
  30. the right compiler.
  31.  
  32. I'm still inexperienced when it comes to making and using "./configure" 
  33. files, so for computers that are not mine, you might have to fix things to 
  34. get everything to compile.  If you find stuff that needs correcting, 
  35. please email me and I'll update it.  :)
  36.  
  37. These are the commands I type to build gopchop:
  38.  
  39. ./configure
  40. make
  41. make install
  42.  
  43. If things blow up with autoconf or automake, you can try rebuilding the
  44. configure script:
  45.  
  46. ./autogen.sh
  47.  
  48. If things still resist working right, please email me, and hopefully we can
  49. figure it out.  :)
  50.  
  51.  
  52. Using gopchop
  53. -------------
  54. The basic way to use gopchop is like so:
  55.  
  56.  1) Run gopchop.
  57.  2) Select an MPEG2 with "File / Open".
  58.  3) Drag the slider to the first GOP you want to have in a clip.
  59.         (You can disable "Edit / Preferences... / Auto Refresh" to seek
  60.          faster, and then click "Refresh" to see where you
  61.          are in the file.)
  62.  4) Click "Start Mark".
  63.  5) Drag the slider to the last GOP you want in the clip.
  64.  6) Click "End Mark".  (If you drag the slider somewhere before the
  65.         first mark, "End Mark" will not do anything.)
  66.  7) Repeat steps 3 through 6 to select all the clips you want saved.
  67.  8) Drag clips up and down to reorder them in the Clip List window.
  68.  9) To delete unwanted clips, select it, and hit Del or Backspace.
  69. 10) Save the clips to a new MPEG2 with "File / Export".
  70.  
  71. If you want to save different clips, select "Edit / Clear" and start 
  72. over at step 3.  If you want to use a different source MPEG2, select "File 
  73. / Close" and start over at step 1.
  74.  
  75. At present, I don't support saving clips from multiple different MPEG2 
  76. source files.  In the future, perhaps.
  77.  
  78. This is a *LOSSY* process on MPEGs that have open GOPs.  To close a GOP, I
  79. must toss B-Frames at the start of a GOP.  If you were to mark each frame in
  80. an MPEG for splicing in gopchop, you would end up with fewer frames than you
  81. started with.  To "close" an open GOP, I must toss those B-Frames.  To
  82. stop this behavior, uncheck the "Drop Orphaned Frames" option in the
  83. "Preferences" window.
  84.  
  85.  
  86. Options
  87. -------
  88. Right now, there are several options available in gopchop.  The are in the
  89. "Edit / Preferences..." window:
  90.   Video Output Driver
  91.     Select which video driver you want to use for playback.  The Xv drivers
  92.     correctly handle aspect changes.
  93.   Default Run Speed
  94.     To the right of the "Run" button is the "speed" bar.  Normally,
  95.     this is "1" by default.  It represents the number of GOPs to move forward
  96.     while in "run" mode.  Things can get broken-looking depending on your
  97.     source MPEG2-PS, if you set this above 1.
  98.   Run Loop
  99.     With this on, playback of the stream (via the "Run" button) will loop
  100.     back around to the start when it passes the end of the stream.
  101.   Auto Refresh
  102.     With this on, any time the current GOP changes (via "Prev", "Next", or
  103.     "Run"), the GOP decode window will be updated.  If you're scanning
  104.     through a long stream, it's faster to turn this off, and just click the
  105.     "Refresh" button when you want to see where you are.
  106.   Drop Orphaned Frames
  107.     With this on, all the B-Frames at the start of an open GOP on a clip
  108.     boundry will be removed from the stream.  This is available so that
  109.     the decoders that don't pay attention to the "edited" GOP flag won't
  110.     get confused by the orphaned B-Frames.
  111.   Adjust GOP Timestamps
  112.     This adjusts all GOP timestamps to start at 0:00.0 so that they don't
  113.     jump ahead at cut points.
  114.   Force Prepended System Header
  115.     Adds a Pack with a System Header for unusual streams that need it.  May
  116.     be needed for some DVD authoring tools.
  117.   Drop Trailing Pack with System Header
  118.     During an export, this drop the final Pack if it contains a System
  119.     Header.  May be needed for some DVD authoring tools.
  120.   Ignore Program End Codes
  121.     Continue parsing the input stream even if a "Program End" code is seen.
  122.     This is useful when working on concatenated MPEG files.
  123.   Ignore Errors
  124.     This will disable the error tracing normally done when loading a
  125.     stream.  This is handy if you broken or weird stream that you still want
  126.     to try and load, but you don't want to get spammed by all the diagnostic
  127.     warnings.
  128.  
  129.  
  130. VOB Files
  131. ---------
  132. Since DVD VOB files are MPEG2, you can use gopchop to pull scenes.  
  133. HOWEVER, gopchop is not a DVD-authentication tool.  I might go look at 
  134. libdvdread, but I require an mmap-able file interface (like, say, a direct 
  135. filesystem "open" call).  If you have unencrypted DVDs, or can get the 
  136. unencrypted VOB somewhere to use "open" on it, gopchop should have no 
  137. problems with it.
  138.  
  139.  
  140. What to expect during MPEG2 loading
  141. -----------------------------------
  142. Please keep an eye on your standard error output.  If you have a file that
  143. gopchop doesn't like, you'll hear about it during load on stderr.  If you
  144. want to have gopchop ignore all errors during a load, just check the
  145. "Ignore Errors" option in the "Preferences" window.  This is handy for some
  146. formats that have repeating harmless errors.
  147.  
  148. Usually, when gopchop loads an MPEG2, there will be some "errors" near the 
  149. end of the file.  These errors can generally be ignored.  They have to do 
  150. with how your MPEG2 was created, and expected packet information or 
  151. end-of-file codes might be missing.  That's perfectly okay.
  152.  
  153. I didn't implement parsing for every MPEG2 System packet header out there.  
  154. It's in my TODO list to do it, but you might not be able to load some 
  155. MPEG2s.  The error will say something about "Need to write a parsing 
  156. routine".  Email me if you run into this, and I can get it finished up for 
  157. you.
  158.  
  159. If you have an MPEG2-PS file that doesn't have GOPs correctly built, you may
  160. need to remultiplex your MPEG2-PS file first.  I recommend using "mplex" from
  161. the siemens DVB tools: http://www.linuxtv.org/download/dvb/
  162.  
  163. If your MPEG2-PS file doesn't map single Packs to each Frame, gopchop may
  164. also get freaky.  If your MPEG2-PS file doesn't start GOPs on video packet
  165. boundries, you may see artifacts at the split-points.  If you see the warning
  166. "Whoa: I-Frame number X seen in the same GOP!?" this is probably the cause.
  167.  
  168. At present, gopchop is not very memory efficient or fast (I was trying to
  169. get it to just _work_ first).  It will allocate about 10% of the MPEG2-PS
  170. file's size in memory.  For example, if you have a 1GB MPEG2-PS file, expect
  171. that gopchop will end up allocating about 100MB of memory to load it.
  172.  
  173.  
  174. How it works
  175. ------------
  176. I scan the MPEG2 for a full list of System packets, then examine the
  177. Program Element Stream packets they contain.  In the video PES, I look for
  178. GOP headers (and Picture headers).  Each GOP is then mapped back to the
  179. System packets that contain it (a full GOP can span multiple VES packets,
  180. and multiple System packets).  When a GOP is saved to a new file, the
  181. entire System packet list for that GOP is written as a byte-for-byte copy
  182. from the source MPEG2. In theory, this will take any audio streams along
  183. for the ride.  So far, so good.  :)
  184.  
  185. In the "Info" box, the "Offset" column shows the system packet offset
  186. (for GOPs) and the video packet offset (for Pictures).  The "Bytes"
  187. column lists the bytes contained by all the system packets (for the GOP),
  188. and all the video packets in a Picture.  You'll notice that the Offset
  189. plus the Bytes don't add up to the next Picture's Offset.  This is because
  190. there is stuff between the video packets.  :)  The GOP "Bytes" and "Offset",
  191. however, should add up to the next GOP's "Offset" value.
  192.  
  193. The settings under the "Preferences" window are automatically saved to
  194. ".gopchop/options" in your home directory.
  195.  
  196.  
  197. KNOWN ISSUES
  198. ------------
  199. libmpeg2 (and libvo) sometimes just up and segfault when they bring up a
  200. window.  In porting to libmpeg2 0.4.0, I haven't seen this problem any
  201. more.  Hopefully it's gone.  If it's not, let me know, and I'll continue
  202. to try to isolate it.  (Actually, now I see it again at the end of some
  203. weirder streams.)
  204.  
  205. Some audio streams don't take kindly to be chopped like this.  However, 
  206. they usually have CRC to detect problems.  For example, when I snipped
  207. together some scenes from a DVD, and then played it back with "MPlayer",
  208. the AC3 audio stream reported CRC errors and gracefully dropped the garbled 
  209. packet.  As for the playback, I didn't notice it at all.
  210.  
  211. gopchop assumes that all GOPs will appear in the first video PES packet of 
  212. a System packet.  Technically, this might not be true, but in practice, 
  213. this seems to happen.  As a result, gopchop could fail to load some 
  214. "unusual" MPEG2 files.  If you have some examples, please email me, and 
  215. maybe I can fix my code.  :)  (BTW: I've found a snippet of a DVD I have
  216. that does this, so I'm working to make things saner now...)  Generally,
  217. gopchop works best with hardware encoder streams, rather than software
  218. generated streams.
  219.  
  220. Since gopchop doesn't alter the stream it writes back to disk, things like
  221. time-stamps are really bizarre.  In players like MPlayer, you'll see the
  222. time-stamp during playing jump forward at each splice point.  In fact,
  223. this seriously breaks some players, and I'm hoping to figure out how to
  224. get around it.  I've taken a quick look at "gop-fixup" by Mark Rages, and
  225. I'm hoping to generalize his code and add it to gopchop.  For more info:
  226. http://mlug.missouri.edu/~markrages/tavi/index.php?page=GopFixup
  227.  
  228. The "correct" way to edit MPEG2-PS files is to just set the "broken" flag
  229. in the GOP, and the decoder will throw away the B-frames following the
  230. I-frame in an open GOP.  However, it seems that at least libmpeg2 doesn't
  231. honor the "broken" flag, and I bet other decoders don't too.  Therefore,
  232. I've done BOTH: I've set the "broken" flag, AND removed the B-Frames.
  233. I'm worried that this will break time sync, but it's the only way to
  234. stop from having decoding artifacts due to the B-frames in the open GOP
  235. referring to some previous P-Frame that doesn't exist any more.  If you
  236. want to NOT drop these orphaned B-frames, uncheck the "Drop Orphaned
  237. Frames" checkbox in the "Preferences" window.
  238.  
  239. During video display, the aspect ratio is ignored in everything except
  240. the "Xv" drivers.  Doing software resizing for the other drivers is pretty
  241. low on my list of things to fix since gopchop isn't technically a viewer.  :)
  242.  
  243.  
  244. Special Features
  245. ----------------
  246. If you're really bold, you can try the --pipe command to hook your up
  247. a different viewer instead of the internal drivers.  I've only played
  248. with "mplayer" doing this, and it does a pretty good job.  Nasty A/V sync
  249. problems appear if you try to skip around with gopchop's "auto-refresh"
  250. still selected, so try it without that option.
  251.  
  252.  
  253. Acknowledgements (also see the "AUTHORS" file)
  254. ----------------------------------------------
  255. Kirsten for not kicking me out of the house while I hacked the first version
  256. of this together for a week straight.  :)
  257.  
  258. Paul for having lots and lots of commercials to edit out of huge KFir MPEG2s.
  259.  
  260. Various people from the KFir MPEG2 list (mpeg2@linuxtv.org) for guiding me
  261. towards this program's basic design and helping to stomp bugs, especially:
  262.     Warren Young (warren@etr-usa.com)
  263.     Marcus Metzler (mocm@convergence.de)
  264.     Bram Stolk (b.stolk@chello.nl)
  265.  
  266. Brian (briand@zipcon.net) for being so patient with my broken builds.  :)
  267.  
  268. My fantastic "beta testers" who didn't know they were getting into beta
  269. testing until it was too late:
  270.     Chris Chiappa <chris@chiappa.net>        (TiVo Extraction)
  271.     Stuart L. Morris <stuart@xover.co.uk>        (TS-to-PS)
  272.     Wolfgang Goeller <wgoeller@swissonline.ch>
  273.  
  274. libmpeg2 and libvo authors:
  275.  * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
  276.  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  277.  
  278. David Philippi for pointing out some ugly buffer strategies I was using.
  279.  
  280. Tomi Ollila for pointing out a problem with how I used libmpeg2's states,
  281.     the lack of proper fseek/fseeko usage, and some example MPEG2-PS
  282.     files.
  283.  
  284. Tom Pfeifer, Ivo Koethnig, Klaus Brandl, and others for great example
  285.     MPEG2-PS files that I've used to test parsing and crashing.
  286.  
  287. Bryce Harrington for reorganizing the project, building the new website,
  288.     and showing me how bring life back to the GOPchop community.
  289.  
  290.  
  291. Random Stuff
  292. ------------
  293. There are two cool utilities included in this package.
  294.  
  295. One is called "mpegcat" and has lots of options.  It's basically been my
  296. tool for testing ideas for a new file parsing routine.  You can also extract
  297. streams with it.
  298.  
  299. The other is called "gtkspu" and is used to display SPU bitmaps (DVD subtitles,
  300. menus, etc).  It's really a quicky program, but it works for what I basically
  301. wanted it to do: show me what a given SPU stream had in it.
  302.  
  303.  
  304. Translations
  305. ------------
  306. See the "ABOUT-NLS" file for "gettext" details.  To create another 
  307. translation template, go into the "po" directory, and type:
  308.  
  309.   msginit -i gopchop.pot -o CODE.po
  310.  
  311. where "CODE" is the expected lang code.  To update an existing .po file
  312. from a changed template, type:
  313.  
  314.   msgmerge -U CODE.po gopchop.pot
  315.  
  316. To test your language, gopchop must be installed (so NLS libs can find
  317. the translation files), and you'll need to specify a "full" locale:
  318.  
  319.   LANG=fr_CA gopchop
  320.  
  321.  
  322. -- 
  323. Kees Cook (mpeg2@outflux.net)
  324. http://outflux.net/
  325.