m2vmp2cut-0.65-dev/ANNOUNCE m2vmp2cut-0.67-dev/ANNOUNCE
1Last committed: $Id: ANNOUNCE 2101 2008-05-26 19:57:03Z too $1Last committed: $Id: ANNOUNCE 2169 2008-07-25 12:53:35Z too $
22
3ANNOUNCE for m2vmp2cut 0.65 (Faux pas):3ANNOUNCE for m2vmp2cut 0.67 (Success Is Not An Option):
44
5This is development release of m2vmp2cut -- frame accurate (currently PAL)5This is development release of m2vmp2cut -- frame accurate (currently PAL)
6mpeg2 video (m2v file) with accompanied mp2 audio (mp2 file) cutter.6mpeg2 video (m2v file) with accompanied mp2 audio (mp2 file) cutter.
14This software is available currently at http://www.iki.fi/too/sw/m2vmp2cut/14This software is available currently at http://www.iki.fi/too/sw/m2vmp2cut/
15and is licensed under GNU Public License (GPL).15and is licensed under GNU Public License (GPL).
1616
17Changes since 0.65 (r2101, Faux pas):
18 Audio visualizer around current position in m2vcut-gui, to find
19 (silent) spot for cutpoint.
20 Test speedups, now audio is pre-scanned too,
21 Some usage tunes, fixes and enchangements,
22 Bug fixes in almost every area.
23
17Changes since 0.63 (r2069, Epic Fail):24Changes since 0.63 (r2069, Epic Fail):
18 Target size estimation25 Target size estimation.
19 Keyboard control adjustments in gui26 Keyboard control adjustments in gui.
20 Bug fixes27 Bug fixes.
2128
22Changes since 0.62 (r1256, Gender-neutral pronouns):29Changes since 0.62 (r1256, Gender-neutral pronouns):
23 Added graphical gui client for cutpoint selection.30 Added graphical gui client for cutpoint selection.

m2vmp2cut-0.65-dev/HISTORY m2vmp2cut-0.67-dev/HISTORY
1# Created using svn -v log | sed -n -e '${x;p;x;p;q};/^--*$/{x;/./p;d};x;p'1# Created using svn -v log | sed -n -e '${x;p;x;p;q};/^--*$/{x;/./p;d};x;p'
2# This file is not version controlled2# This file is not version controlled
33
4------------------------------------------------------------------------
5r2169 | too | 2008-07-25 15:53:35 +0300 (Fri, 25 Jul 2008) | 1 line
6Changed paths:
7 M /main/projects/m2vmp2cut/ANNOUNCE
8 M /main/projects/m2vmp2cut/INSTALL
9 M /main/projects/m2vmp2cut/README
10 M /main/projects/m2vmp2cut/VERSION
11
12Version 0.67-dev
13------------------------------------------------------------------------
14r2168 | too | 2008-07-25 15:27:52 +0300 (Fri, 25 Jul 2008) | 1 line
15Changed paths:
16 M /main/projects/m2vmp2cut/bin/wrapper.sh
17
18m2vcut-gui test: check existence of .../out.mpg, for better output error msgs
19------------------------------------------------------------------------
20r2167 | too | 2008-07-25 11:57:56 +0300 (Fri, 25 Jul 2008) | 1 line
21Changed paths:
22 M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh
23
24--disable-shared
25------------------------------------------------------------------------
26r2165 | too | 2008-07-23 12:46:35 +0300 (Wed, 23 Jul 2008) | 1 line
27Changed paths:
28 M /main/projects/m2vmp2cut/Makefile
29
30use snapshot version in installation.
31------------------------------------------------------------------------
32r2164 | too | 2008-07-23 12:31:07 +0300 (Wed, 23 Jul 2008) | 1 line
33Changed paths:
34 M /main/projects/m2vmp2cut/Makefile
35
36snapshot installable again.
37------------------------------------------------------------------------
38r2163 | too | 2008-07-23 12:20:55 +0300 (Wed, 23 Jul 2008) | 1 line
39Changed paths:
40 M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh
41 M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh
42
43path to libmpeg2-0.5.1.tar.gz given as arg for building.
44------------------------------------------------------------------------
45r2162 | too | 2008-07-23 12:20:15 +0300 (Wed, 23 Jul 2008) | 1 line
46Changed paths:
47 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
48
49suppress m2vmp2cut path in messages...
50------------------------------------------------------------------------
51r2161 | too | 2008-07-23 11:46:17 +0300 (Wed, 23 Jul 2008) | 1 line
52Changed paths:
53 M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh
54
55small message clarification tune.
56------------------------------------------------------------------------
57r2158 | too | 2008-07-23 11:39:41 +0300 (Wed, 23 Jul 2008) | 1 line
58Changed paths:
59 M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh
60 M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh
61
622 missing x propsets
63------------------------------------------------------------------------
64r2157 | too | 2008-07-21 16:18:31 +0300 (Mon, 21 Jul 2008) | 1 line
65Changed paths:
66 M /main/projects/m2vmp2cut/Makefile
67
68Fix version at '_dist' target (no more at 'install' target)
69------------------------------------------------------------------------
70r2156 | too | 2008-07-21 15:49:35 +0300 (Mon, 21 Jul 2008) | 1 line
71Changed paths:
72 M /main/projects/m2vmp2cut/m2vmp2cut
73
74show version if no args given
75------------------------------------------------------------------------
76r2155 | too | 2008-07-21 15:33:41 +0300 (Mon, 21 Jul 2008) | 1 line
77Changed paths:
78 M /main/projects/m2vmp2cut/Makefile
79 M /main/projects/m2vmp2cut/VERSION
80 M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh
81
82Source & makefile ready for 0.67(-dev) -- docs + testing todo
83------------------------------------------------------------------------
84r2154 | too | 2008-07-21 15:20:06 +0300 (Mon, 21 Jul 2008) | 1 line
85Changed paths:
86 M /main/projects/m2vmp2cut/src/Makefile
87 M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh
88
89better libmpeg2 requirement message. subprog.o removed...
90------------------------------------------------------------------------
91r2152 | too | 2008-07-20 20:56:09 +0300 (Sun, 20 Jul 2008) | 1 line
92Changed paths:
93 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
94 M /main/projects/m2vmp2cut/src/Makefile
95 A /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh
96
97check and use libmpeg2 0.5.1.
98------------------------------------------------------------------------
99r2151 | too | 2008-07-20 18:47:58 +0300 (Sun, 20 Jul 2008) | 1 line
100Changed paths:
101 A /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh
102 A /main/projects/m2vmp2cut/tools/buildlibmpeg-trunk.sh (from /main/projects/m2vmp2cut
/tools/buildlibmpeg.sh:2150)
103 D /main/projects/m2vmp2cut/tools/buildlibmpeg.sh
104
105buildlibmpeg scripts for 0.5.1 and trunk builds
106------------------------------------------------------------------------
107r2138 | too | 2008-06-14 08:52:25 +0300 (Sat, 14 Jun 2008) | 1 line
108Changed paths:
109 M /main/projects/m2vmp2cut/src/wavgraph.c
110
111proper structure initialization (c99 style)
112------------------------------------------------------------------------
113r2137 | too | 2008-06-13 22:14:59 +0300 (Fri, 13 Jun 2008) | 5 lines
114Changed paths:
115 M /main/projects/m2vmp2cut/bin/wrapper.sh
116 M /main/projects/m2vmp2cut/doc/m2vcut_help-default
117 M /main/projects/m2vmp2cut/doc/m2vcut_help-fi_FI
118 M /main/projects/m2vmp2cut/src/m2vcut-gui.c
119 M /main/projects/m2vmp2cut/src/wavgraph.c
120
121m2vcut-gui: Key Q -> qq to exit. keys 1234567890 jumps to 5-95% in video file
122wavgraph: Show 1 pixel dots at video frame egdes. Color changes
123m2vcut_help-*: Add number key doc. Q -> qq
124wrapper.sh: Add '25 1' args to wavgraph command line (video frame rate info)
125------------------------------------------------------------------------
126r2136 | too | 2008-06-12 21:41:09 +0300 (Thu, 12 Jun 2008) | 1 line
127Changed paths:
128 M /main/projects/m2vmp2cut/bin/wrapper.sh
129 M /main/projects/m2vmp2cut/src/warpxpointer.c
130
131-tries -> -trysecs. warp_m2vcut_exit
132------------------------------------------------------------------------
133r2135 | too | 2008-06-12 21:27:49 +0300 (Thu, 12 Jun 2008) | 1 line
134Changed paths:
135 M /main/projects/m2vmp2cut/src/warpxpointer.c
136
137sleep time reduced from 2 sec to 500 msec. tries val internally doubled...
138------------------------------------------------------------------------
139r2134 | too | 2008-06-12 21:22:08 +0300 (Thu, 12 Jun 2008) | 1 line
140Changed paths:
141 M /main/projects/m2vmp2cut/bin/wrapper.sh
142
143use warpxpointer in wrapper.sh, in agraph.
144------------------------------------------------------------------------
145r2133 | too | 2008-06-12 21:11:48 +0300 (Thu, 12 Jun 2008) | 1 line
146Changed paths:
147 M /main/projects/m2vmp2cut/src/warpxpointer.c
148
149warpxpointer: removed daemon, replaced with tries
150------------------------------------------------------------------------
151r2132 | too | 2008-06-12 21:01:57 +0300 (Thu, 12 Jun 2008) | 1 line
152Changed paths:
153 M /main/projects/m2vmp2cut/src/warpxpointer.c
154
155warpxpointer can now take daemon and name args.
156------------------------------------------------------------------------
157r2131 | too | 2008-06-12 19:57:00 +0300 (Thu, 12 Jun 2008) | 1 line
158Changed paths:
159 M /main/projects/m2vmp2cut/bin/wrapper.sh
160 M /main/projects/m2vmp2cut/src/Makefile
161 A /main/projects/m2vmp2cut/src/warpxpointer.c
162
163added warpxpointer, not useful yet (because of 'feh')
164------------------------------------------------------------------------
165r2130 | too | 2008-06-11 23:19:45 +0300 (Wed, 11 Jun 2008) | 2 lines
166Changed paths:
167 M /main/projects/m2vmp2cut/bin/wrapper.sh
168 M /main/projects/m2vmp2cut/doc/m2vcut_help-default
169 M /main/projects/m2vmp2cut/doc/m2vcut_help-fi_FI
170 M /main/projects/m2vmp2cut/src/m2vcut-gui.c
171
172Q quits m2vcut-gui. 'a' added to help texts.
173use 'feh' or 'display' to show agraph (or print error)
174------------------------------------------------------------------------
175r2129 | too | 2008-06-11 23:06:07 +0300 (Wed, 11 Jun 2008) | 1 line
176Changed paths:
177 M /main/projects/m2vmp2cut/bin/wrapper.sh
178 M /main/projects/m2vmp2cut/src/wavgraph.c
179
180current position in agraph
181------------------------------------------------------------------------
182r2128 | too | 2008-06-11 20:36:24 +0300 (Wed, 11 Jun 2008) | 1 line
183Changed paths:
184 M /main/projects/m2vmp2cut/bin/wrapper.sh
185 M /main/projects/m2vmp2cut/src/Makefile
186 M /main/projects/m2vmp2cut/src/m2vcut-gui.c
187 M /main/projects/m2vmp2cut/src/wavgraph.c
188
189agraph scaling and integration
190------------------------------------------------------------------------
191r2127 | too | 2008-06-11 18:37:21 +0300 (Wed, 11 Jun 2008) | 1 line
192Changed paths:
193 M /main/projects/m2vmp2cut/src/wavgraph.c
194
195first graphs!
196------------------------------------------------------------------------
197r2126 | too | 2008-06-11 16:31:19 +0300 (Wed, 11 Jun 2008) | 1 line
198Changed paths:
199 M /main/projects/m2vmp2cut/bin/wrapper.sh
200 M /main/projects/m2vmp2cut/src/wavgraph.c
201
202(wav|a)graph work going on...
203------------------------------------------------------------------------
204r2124 | too | 2008-06-09 22:21:37 +0300 (Mon, 09 Jun 2008) | 1 line
205Changed paths:
206 M /main/projects/m2vmp2cut/bin/wrapper.sh
207 M /main/projects/m2vmp2cut/src/wavgraph.c
208
209some progress in audio visualizing code
210------------------------------------------------------------------------
211r2123 | too | 2008-06-07 18:44:35 +0300 (Sat, 07 Jun 2008) | 1 line
212Changed paths:
213 A /main/projects/m2vmp2cut/src/wavgraph.c
214
215beginnings of 'wavgraph' (work name)
216------------------------------------------------------------------------
217r2122 | too | 2008-06-04 22:12:21 +0300 (Wed, 04 Jun 2008) | 1 line
218Changed paths:
219 M /main/projects/m2vmp2cut/bin/wrapper.sh
220
221most adata code on wrapper.sh
222------------------------------------------------------------------------
223r2121 | too | 2008-06-03 22:54:32 +0300 (Tue, 03 Jun 2008) | 1 line
224Changed paths:
225 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
226 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
227 M /main/projects/m2vmp2cut/bin/wrapper.sh
228 M /main/projects/m2vmp2cut/src/mp2cutpoints.c
229
230move command. mp2cutpoints seek accelerator bugfix. tunes.
231------------------------------------------------------------------------
232r2120 | too | 2008-06-01 23:39:23 +0300 (Sun, 01 Jun 2008) | 1 line
233Changed paths:
234 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
235 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
236
237cosmic.
238------------------------------------------------------------------------
239r2119 | too | 2008-06-01 23:29:22 +0300 (Sun, 01 Jun 2008) | 1 line
240Changed paths:
241 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
242
243tunes
244------------------------------------------------------------------------
245r2118 | too | 2008-06-01 22:33:35 +0300 (Sun, 01 Jun 2008) | 1 line
246Changed paths:
247 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
248 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
249 M /main/projects/m2vmp2cut/src/mp2cutpoints.c
250
251scan. speedup. fixes.
252------------------------------------------------------------------------
253r2117 | too | 2008-05-31 17:09:20 +0300 (Sat, 31 May 2008) | 1 line
254Changed paths:
255 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
256 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
257
258m2vmp2cut.sh: commands arg reorg.
259------------------------------------------------------------------------
260r2116 | too | 2008-05-31 13:58:18 +0300 (Sat, 31 May 2008) | 1 line
261Changed paths:
262 M /main/projects/m2vmp2cut/src/mp2cutpoints.c
263
264scan percentage fixes...
265------------------------------------------------------------------------
266r2115 | too | 2008-05-31 13:13:07 +0300 (Sat, 31 May 2008) | 1 line
267Changed paths:
268 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
269
270s/audio.info/audio.cuts/
271------------------------------------------------------------------------
272r2114 | too | 2008-05-31 12:55:10 +0300 (Sat, 31 May 2008) | 1 line
273Changed paths:
274 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
275
276audio.scan added to (2nd) mp2cutpoints command line
277------------------------------------------------------------------------
278r2113 | too | 2008-05-31 12:16:54 +0300 (Sat, 31 May 2008) | 1 line
279Changed paths:
280 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
281 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
282
283more of video.index and audio.scan creation
284------------------------------------------------------------------------
285r2111 | too | 2008-05-31 10:45:14 +0300 (Sat, 31 May 2008) | 1 line
286Changed paths:
287 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
288 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
289 M /main/projects/m2vmp2cut/bin/wrapper.sh
290 M /main/projects/m2vmp2cut/src/mp2cutpoints.c
291
292tunes and future preparation.
293------------------------------------------------------------------------
294r2110 | too | 2008-05-31 10:24:35 +0300 (Sat, 31 May 2008) | 1 line
295Changed paths:
296 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
297
298insufficient testing :(
299------------------------------------------------------------------------
300r2109 | too | 2008-05-31 10:22:43 +0300 (Sat, 31 May 2008) | 1 line
301Changed paths:
302 M /main/projects/m2vmp2cut/src/mp2cutpoints.c
303
304--scan option done, not used yet.
305------------------------------------------------------------------------
306r2108 | too | 2008-05-28 22:12:26 +0300 (Wed, 28 May 2008) | 1 line
307Changed paths:
308 M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl
309 M /main/projects/m2vmp2cut/bin/wrapper.sh
310 M /main/projects/m2vmp2cut/src/m2vcut-gui.c
311
312--test speedups and bugfixes.
313------------------------------------------------------------------------
314r2107 | too | 2008-05-28 13:01:55 +0300 (Wed, 28 May 2008) | 1 line
315Changed paths:
316 M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh
317
318-c /dev/null
4------------------------------------------------------------------------319------------------------------------------------------------------------
5r2101 | too | 2008-05-26 22:57:03 +0300 (Mon, 26 May 2008) | 1 line320r2101 | too | 2008-05-26 22:57:03 +0300 (Mon, 26 May 2008) | 1 line
6Changed paths:321Changed paths:

m2vmp2cut-0.65-dev/INSTALL m2vmp2cut-0.67-dev/INSTALL
10After this find the location of 'projectx.jar' and symlink10After this find the location of 'projectx.jar' and symlink
11it to m2vmp2cut installation, like:11it to m2vmp2cut installation, like:
1212
13ln -s path/to/projectx.jar PREFIX/lib/m2vmp2cut-0.65/bin/projectx.jar13ln -s path/to/projectx.jar PREFIX/lib/m2vmp2cut-0.67/bin/projectx.jar
1414

m2vmp2cut-0.65-dev/Makefile m2vmp2cut-0.67-dev/Makefile
33
4.PHONY: ALWAYS4.PHONY: ALWAYS
55
6install chkprefix: VER=`sed -n 's/ver=//p' m2vmp2cut`
6install release chkprefix: VER=`sed -n '1s/ .*/-dev/p' VERSION`7release: VER=`sed -n '1s/ .*/-dev/p' VERSION`
8#release: VER=`sed -n '1s/ .*//p' VERSION`
7snapshot: VER=`sed -n '1s/ .*//p' VERSION`+r`svnversion . | tr : =`9snapshot: VER=`sed -n '1s/ .*//p' VERSION`+r`svnversion . | tr : =`
810
9all: ALWAYS11all: ALWAYS
10 cd src && make all12 cd src && make all
13 @echo; echo Build done.; echo
1114
12chkprefix: ALWAYS15chkprefix: ALWAYS
13 @case "$(PREFIX)" in \16 @case "$(PREFIX)" in \
34install: chkfiles chkprefix37install: chkfiles chkprefix
35 cp $(TRG_BINS:%=bin/%) $(PREFIX)/lib/m2vmp2cut-$(VER)/bin38 cp $(TRG_BINS:%=bin/%) $(PREFIX)/lib/m2vmp2cut-$(VER)/bin
36 cp $(TRG_DOCS:%=doc/%) $(PREFIX)/lib/m2vmp2cut-$(VER)/doc39 cp $(TRG_DOCS:%=doc/%) $(PREFIX)/lib/m2vmp2cut-$(VER)/doc
40 cp m2vmp2cut $(PREFIX)/bin/m2vmp2cut
37 v=$(VER); sed "s/=devel/=$$v/" m2vmp2cut > $(PREFIX)/bin/m2vmp2cut41# v=$(VER); sed "s/=devel/=$$v/" m2vmp2cut > $(PREFIX)/bin/m2vmp2cut
38 chmod 755 $(PREFIX)/bin/m2vmp2cut42# chmod 755 $(PREFIX)/bin/m2vmp2cut
3943
40HISTORY: ALWAYS #SvnVersion_unmodified #ALWAYS #$(FILES)44HISTORY: ALWAYS #SvnVersion_unmodified #ALWAYS #$(FILES)
41 ( echo "# Created using svn -v log" | tr '\012' ' ';\45 ( echo "# Created using svn -v log" | tr '\012' ' ';\
57chkrelease: SvnVersion_unmodified HISTORY61chkrelease: SvnVersion_unmodified HISTORY
58 rm -f SvnVersion62 rm -f SvnVersion
59 @case $(VER) in \63 @case $(VER) in \
60 *-dev) ;; [2468]) ;; \64 *-dev) ;; *[2468]) ;; \
61 *) echo Version $(VER) not suitable for release.; exit 1 ;; \65 *) echo Version $(VER) not suitable for release.; exit 1 ;; \
62 esac66 esac
6367
72 cd tools && sh tarlisted.c76 cd tools && sh tarlisted.c
7377
74_dist: tools/tarlisted78_dist: tools/tarlisted
79 v=$(VER); sed "s/=devel/=$$v/" m2vmp2cut > m2vmp2cut.mod
75 version=m2vmp2cut-$(VER); { echo 755 root root . $$version /; \80 version=m2vmp2cut-$(VER); { echo 755 root root . $$version /; \
76 grep '^#,#' Makefile | while read _ f x; do p=755; d=$$f; \81 grep '^#,#' Makefile | while read _ f x; do p=755; d=$$f; \
77 test -d $$f && d=/ || case $$x in '') p=644;; esac; \82 test -d $$f && d=/ || { test -f $$d.mod && d=$$d.mod; \
83 case $$x in '') p=644;; esac; }; \
78 echo $$p root root . $$version/$$f $$d; done; } \84 echo $$p root root . $$version/$$f $$d; done; } \
79 | tools/tarlisted -Vz -o $$version.tar.gz85 | tools/tarlisted -Vz -o $$version.tar.gz
86 rm m2vmp2cut.mod
87 @echo Created m2vmp2cut-$(VER).tar.gz
8088
81# XXX unify89# XXX unify
82clean: ALWAYS90clean: ALWAYS
134#,# src/m2vtoyuv.c142#,# src/m2vtoyuv.c
135#,# src/Makefile143#,# src/Makefile
136#,# src/mp2cutpoints.c144#,# src/mp2cutpoints.c
145#,# src/warpxpointer.c
146#,# src/wavgraph.c
137#,# src/x.c147#,# src/x.c
138#,# src/x.h148#,# src/x.h
139#,# src/zzob.c149#,# src/zzob.c
140#,# src/zzob.h150#,# src/zzob.h
141151
142#,# tools152#,# tools
143#,# tools/buildlibmpeg.sh x153#,# tools/buildlibmpeg-051.sh x
144#,# tools/chksyslibmpeg.sh x154#,# tools/chksyslibmpeg.sh x
155#,# tools/chklibmpeg-051.sh x
145#,# tools/tarlisted.c x156#,# tools/tarlisted.c x
146#,# tools/xdist.pl x
147157
148#EOF158#EOF

m2vmp2cut-0.65-dev/README m2vmp2cut-0.67-dev/README
1Last committed: $Id: README 2101 2008-05-26 19:57:03Z too $1Last committed: $Id: README 2169 2008-07-25 12:53:35Z too $
22
3README for m2vmp2cut 0.65:3README for m2vmp2cut 0.67:
44
5m2vmp2cut is frame accurate (currently PAL) mpeg2 video (m2v file)5m2vmp2cut is frame accurate (currently PAL) mpeg2 video (m2v file)
6with accompanied mp2 audio (mp2 file) cutter.6with accompanied mp2 audio (mp2 file) cutter.

m2vmp2cut-0.65-dev/VERSION m2vmp2cut-0.67-dev/VERSION
10.65 (2008-05-26) "Faux pas"10.67 (2008-07-25) "Success Is Not An Option"
22
3$Id: VERSION 2101 2008-05-26 19:57:03Z too $3$Id: VERSION 2169 2008-07-25 12:53:35Z too $
44
5-- use sed -n '1s/ .*//p' VERSION to read version number from this file --5-- use sed -n '1s/ .*//p' VERSION to read version number from this file --
66

m2vmp2cut-0.65-dev/bin/m2vmp2cut.pl m2vmp2cut-0.67-dev/bin/m2vmp2cut.pl
6# All rights reserved6# All rights reserved
7#7#
8# Created: Sun Sep 05 11:12:24 EEST 2004 too8# Created: Sun Sep 05 11:12:24 EEST 2004 too
9# Last modified: Mon May 26 19:57:49 EEST 2008 too9# Last modified: Tue Jun 03 22:53:29 EEST 2008 too
10#10#
11# This program is licensed under the GPL v2. See file COPYING for details.11# This program is licensed under the GPL v2. See file COPYING for details.
1212
55my $aonly = 0;55my $aonly = 0;
56my $stop = 0;56my $stop = 0;
57my $sync = 0;57my $sync = 0;
58my $test = 0;58my $test = -1;
59my $last = 0;59my $last = 0;
60my $evbr = 0;60my $evbr = 0;
61my $requant = 0.0;61my $requant = 0.0;
62my $mplexopts = '-M -f 8';62my $mplexopts = '-M -f 8';
6363
64my $dir = undef;
64while (defined $ARGV[0] && $ARGV[0] =~ /^--/)65while (defined $ARGV[0] && $ARGV[0] =~ /^--/)
65{66{
66 $_ = $ARGV[0];67 $_ = $ARGV[0];
68 $dir = $1, shift @ARGV, next if (/^--dir=(.*)/);
67 $asr = $1 + 0, shift @ARGV, next if (/^--asr=(\d)\b/);69 $asr = $1 + 0, shift @ARGV, next if (/^--asr=(\d)\b/);
68 $stop = 1, shift @ARGV, next if (/^--stop\b/);70 $stop = 1, shift @ARGV, next if (/^--stop\b/);
69 $nomux = 1, shift @ARGV, next if (/^--nomux\b/);71 $nomux = 1, shift @ARGV, next if (/^--nomux\b/);
8688
87$nomux = 1 if ($aonly);89$nomux = 1 if ($aonly);
8890
91unless (defined $dir) {
89showdoc 1, 'Usage' if (@ARGV < 1);92 showdoc 1, 'Usage' if (@ARGV < 1);
90
91die "$ARGV[0]: not a directory.\n", unless -d $ARGV[0];
92
93my $dir = shift @ARGV;93 $dir = shift @ARGV;
94}
95
96die "$dir: not a directory.\n", unless -d $dir;
9497
95# XXX add parsing of -v, -a, -s, -c, -i...98# XXX add parsing of -v, -a, -s, -c, -i...
96# symlinks...99# symlinks...
99my $sfile = 0; # "$dir/subtitles...";102my $sfile = 0; # "$dir/subtitles...";
100my $cfile = "$dir/cutpoints";103my $cfile = "$dir/cutpoints";
101my $ifile = "$dir/video.index";104my $ifile = "$dir/video.index";
105my $jfile = "$dir/audio.scan";
102my $range = 0;106my $range = 0;
103my $workdir = "m2vmp2cut-work";107my $workdir = "m2vmp2cut-work";
104108
112116
113# XXX some cmdline error handling...117# XXX some cmdline error handling...
114118
115foreach ($vfile, $afile, $sfile, $cfile, $ifile) {119foreach ($vfile, $afile, $sfile, $cfile) {
116 -r $_ or die "File $_ not readable\n" if $_;120 -r $_ or die "File $_ not readable\n" if $_;
117}121}
122
123# XXX move to a later place
124# also maybe sub eprint($) { print STDERR $_[0]; } # + nl-version
125print("Creating $ifile...\n"), system $m2vscan, $vfile, $ifile
126 unless -r $ifile;
127print("Creating $jfile...\n"), system $mp2cutpoints, '--scan', $afile, $jfile
128 unless -r $jfile;
118129
119if ($range) {130if ($range) {
120 $_ = $range;131 $_ = $range;
144 $framelist = "@tlist";155 $framelist = "@tlist";
145}156}
146157
147if ($test)158if ($test > 0)
148{159{
149 if ($test > 0) { $test = 24 if ($test < 24); }160 $test = 50 if ($test < 50);
150 else { $test = -24 if ($test > -24); }
151161
152 my @tlist;162 my @tlist;
153 foreach (split(',', $framelist))163 foreach (split(',', $framelist))
154 {164 {
155 my ($s, $e) = split('-');165 my ($s, $e) = split('-');
156 push(@tlist,166 my ($ss, $ee) = ($s + $test, $e - $test);
157 sprintf("%d-%d,%d-%d", $s, $s + $test, $e - $test, $e));167 if ($ee > $ss) {
168 push(@tlist, "$s-$ss,$ee-$e");
169 }
170 else { push(@tlist, "$s-$e"); }
171
158 }172 }
159 $framelist = "@tlist";173 $framelist = "@tlist";
174 $test = 1;
160}175}
161176
162my @ranges;177my @ranges;
227242
228seek(I, 0, 0) || die "Seek failed: $!.\n";243seek(I, 0, 0) || die "Seek failed: $!.\n";
229244
245my $estimate;
246if ($test < 0) {
230my ($vsize, $asize) = ((stat $vfile)[7], (stat $afile)[7]);247 my ($vsize, $asize) = ((stat $vfile)[7], (stat $afile)[7]);
231my $estimate = int(($vsize + $asize) * $frames / $allframes * 1.033);248 $estimate = int(($vsize + $asize) * $frames / $allframes * 1.033);
232undef $vsize; undef $asize;249}
233250
234open SH, '>', "$wd/do.sh" || die "Can not create job script: $!\n";251open SH, '>', "$wd/do.sh" || die "Can not create job script: $!\n";
235chmod 0755, "$wd/do.sh";252chmod 0755, "$wd/do.sh";
273mainpid=\$\$290mainpid=\$\$
274trap 'kill -USR1 0' 0291trap 'kill -USR1 0' 0
275292
276'$m2vmp2cut_sh' vermatch 4 \\\n\t|| die 'Tool version mismatch. Rerun!';293'$m2vmp2cut_sh' vermatch 5 \\\n\t|| die 'Tool version mismatch. Rerun!';
277294
278EOF295EOF
279296
299} else {316} else {
300 $evbr = $avbr;317 $evbr = $avbr;
301}318}
319my $met = '';
320$met = "-4 4 -2 4", $evbr = int($evbr * 1.2) if ($test >= 0);
302321
303print STDERR "video frames: @ranges.\n";322print STDERR "video frames: @ranges.\n";
304print SH "# video frames: @ranges\n";323print SH "# video frames: @ranges\n";
360 { echo; echo $efc $range $frames $evbr; echo; } >> "$wd/mpeg2enc.out"379 { echo; echo $efc $range $frames $evbr; echo; } >> "$wd/mpeg2enc.out"
361380
362 _m2vtoyuv -q \$I $range "$vfile" \\381 _m2vtoyuv -q \$I $range "$vfile" \\
363 | mpeg2enc -f 3 -b $evbr -R 2 -K "\$fa" \$dc -s \\382 | mpeg2enc -f 3 -b $evbr $met -R 2 -K "\$fa" \$dc -s \\
364 -o "$wd/enctmp.out.$efc.m2v" \\383 -o "$wd/enctmp.out.$efc.m2v" \\
365 >> "$wd/mpeg2enc.out" 2>&1384 >> "$wd/mpeg2enc.out" 2>&1
366385
387406
388 $copystart = $nextgoppos;407 $copystart = $nextgoppos;
389408
409 if ($test >= 0 && ($test++ & 1) == 0) {
410 $frames -= $encframes;
411 }
412 else {
390 enccmdblk("@m2v2yuvrange", $encframes, $enccopystart);413 enccmdblk("@m2v2yuvrange", $encframes, $enccopystart);
414 }
391}415}
392416
393sub endcut($)417sub endcut($)
415 die "A/V sync correction requires adding silence audio, ",439 die "A/V sync correction requires adding silence audio, ",
416 "which is currently not supported.\n" if ($frametimems < 0);440 "which is currently not supported.\n" if ($frametimems < 0);
417441
418 my $ms = ($frametimems % 1000);442 my $ms = ($frametimems % 1000);
419 my $s = int($frametimems / 1000) % 60;443 my $s = int($frametimems / 1000) % 60;
420 my $m = int($frametimems / 1000 / 60) % 60;444 my $m = int($frametimems / 1000 / 60) % 60;
421 my $h = int($frametimems / 1000 / 60 / 60);445 my $h = int($frametimems / 1000 / 60 / 60);
424 return sprintf "%02d:%02d.%03d", $m, $s, $ms if ($m > 0);448 return sprintf "%02d:%02d.%03d", $m, $s, $ms if ($m > 0);
425 return sprintf "%02d.%03d", $s, $ms;449 return sprintf "%02d.%03d", $s, $ms;
426}450}
451
452die "aonly and test mutually exclusive\n" if ($aonly && $test >= 0);
427453
428my @timecodes;454my @timecodes;
429$" = ' ';455$" = ' ';
431foreach (@ranges)457foreach (@ranges)
432{458{
433 ($s, $e) = split('-');459 ($s, $e) = split('-');
460 my ($ts, $te);
434461
435 lookx($s + 1, 0);462 lookx($s + 1, 0);
436 unless ($aonly)463 unless ($aonly)
437 {464 {
438 print SH "# ======== $prevgopff $currgopff ($s) $nextgopff ",465 print SH "# ======== $prevgopff $currgopff ($s) $nextgopff ",
439 "-- $prevgoppos $currgoppos $nextgoppos\n";466 "-- $prevgoppos $currgoppos $nextgoppos\n";
467 $ts = $nextgopff;
440 begincut($s);468 begincut($s);
441469
442 lookx($e, 1);470 lookx($e, 1);
444 "-- $prevgoppos $currgoppos $nextgoppos\n";472 "-- $prevgoppos $currgoppos $nextgoppos\n";
445 endcut($e);473 endcut($e);
446 }474 }
475
476 if ($test >= 0 && ($test & 1)) {
477 $te = $currgopff;
478 } else { ($ts, $te) = ($s, $e); }
479
447 my ($ts, $te) = (palframe2timecode($s,$sync), palframe2timecode($e,$sync));480 ($ts, $te) = (palframe2timecode($ts,$sync), palframe2timecode($te,$sync));
448481
449 push @timecodes, "$ts-$te";482 push @timecodes, "$ts-$te";
450}483}
451484
452print SH "# ++++++++ $prevgopff $currgopff ($e) $nextgopff ",485print SH "# ++++++++ $prevgopff $currgopff ($e) $nextgopff ",
453 "-- $prevgoppos $currgoppos $nextgoppos\n";486 "-- $prevgoppos $currgoppos $nextgoppos\n";
487if ($test >= 0 && ($test++ & 1)) {
488 $frames -= $encframes;
489}
490else {
454enccmdblk("@m2v2yuvrange", $encframes, $enccopystart) unless ($aonly);491 enccmdblk("@m2v2yuvrange", $encframes, $enccopystart) unless ($aonly);
492}
455undef $s; undef $e;493undef $s; undef $e;
456$" = ',';494$" = ',';
457495
483521
484 undef $maxasrval; undef $maxasr; undef $counter;522 undef $maxasrval; undef $maxasr; undef $counter;
485523
486
487 my $reqq = '';524 my $reqq = '';
488 $reqq = "tcrequant -d 2 -f $requant |" if ($requant);525 $reqq = "tcrequant -d 2 -f $requant |" if ($requant);
489526
494}531}
495532
496print STDERR "Scanning audio for cut points.\n";533print STDERR "Scanning audio for cut points.\n";
497my $audiocutfilepos534my $audiocutfilepos =
498 = `$mp2cutpoints "@timecodes" \"$afile\" \"$wd/audio.info\"`535 qx($mp2cutpoints "@timecodes" "$afile" "$wd/audio.cuts" "$dir/audio.scan")
499 || exit 1;536 || exit 1;
500537
501chomp($audiocutfilepos);538chomp($audiocutfilepos);
526ls -lrtac "$wd"563ls -lrtac "$wd"
527date564date
528EOF565EOF
529if (! $nomux) {566if (! $nomux && $test < 0) {
530 print SH "\n", 'numtune () { ', "\n";567 print SH "\n", 'numtune () { ', "\n";
531 print SH q( echo $1 | sed 's/\\(...\\)$/ \\1/; s/\\(...\\) / \\1 /; s/\\(...\\) /568 print SH q( echo $1 | sed 's/\\(...\\)$/ \\1/; s/\\(...\\) / \\1 /; s/\\(...\\) /
\\1 /'; }), "\n\n"; \\1 /'; }), "\n\n";
532 print SH "echo; echo estimated size: `numtune $estimate` bytes\n";569 print SH "echo; echo estimated size: `numtune $estimate` bytes\n";
562}599}
563600
564print "\nDone, Result (if any) in '$wd/",601print "\nDone, Result (if any) in '$wd/",
565 $nomux? "out.(m2v|mp2)": "out.mpg", "'.\n\n";602 $nomux? "out.(m2v|mp2)": "out.mpg", "'\n\n";

m2vmp2cut-0.65-dev/bin/m2vmp2cut.sh m2vmp2cut-0.67-dev/bin/m2vmp2cut.sh
7# All rights reserved7# All rights reserved
8#8#
9# Created: Wed Apr 23 21:40:17 EEST 2008 too9# Created: Wed Apr 23 21:40:17 EEST 2008 too
10# Last modified: Mon May 19 18:37:22 EEST 2008 too10# Last modified: Wed Jul 23 12:03:42 EEST 2008 too
1111
12e2 () { echo "$@" >&2; }12e2 () { echo "$@" >&2; }
13die () { e2 "$@"; exit 1; }13die () { e2 "$@"; exit 1; }
14usage () { e2; e2 Usage: $0 $cc "$@"; die; }14usage () { e2; e2 Usage: m2vmp2cut '(file|dir)' $cc "$@"; die; }
15needvar () { [ x"$1" = x ] && { shift 1; "$@"; }; }15needvar () { [ x"$1" = x ] && { shift 1; "$@"; }; }
16
17x () { echo + "$@"; "$@"; }
1618
17M2VMP2CUT_CMD_PATH=`cd \`dirname "$0"\`; pwd`19M2VMP2CUT_CMD_PATH=`cd \`dirname "$0"\`; pwd`
18case $M2VMP2CUT_CMD_PATH in20case $M2VMP2CUT_CMD_PATH in
2123
22#echo $M2VMP2CUT_CMD_PATH24#echo $M2VMP2CUT_CMD_PATH
2325
26# no interactive behaviour in batch mode...
27case $1 in --batch) batch=1; shift ;; *) batch= ;; esac
28
29case $1 in ''|h|he|hel|help|vermatch) ;;
30 e|ex|exa|exam|examp|exampl|example) ;;
31 lve|lvev|lvev6|lvev6f|lvev6fr|lvev6fra|lvev6fram|lvev6frame|lvev6frames) ;;
32 *) if test -f "$1"
33 then
34 dn=`dirname "$1"`; basename=`basename "$1"`
35 od=`echo $basename | sed 's/\.[^.]*$//'`.d
36 file=$1 dir=$dn/$od
37 elif test -d "$1"
38 then
39 file= dir=$1
40 else
41 die "'$1': not a file or directory"
42 fi
43 shift ;;
44esac
45
24# do not show this in command list46# do not show this in command list
25cmd_vermatch ()47cmd_vermatch ()
26{48{
27 case $1 in 4) exit 0;; *) exit 1 ;; esac49 case $1 in 5) exit 0;; *) exit 1 ;; esac
28}50}
2951
30cmd_lvev6frames () # Legacy m2vmp2cut support; dig cutpoints from ~/.lve/* file52cmd_lvev6frames () # Legacy m2vmp2cut support; dig cutpoints from ~/.lve/* file
32 $M2VMP2CUT_CMD_PATH/lvev6frames.pl54 $M2VMP2CUT_CMD_PATH/lvev6frames.pl
33}55}
3456
35chkvideoindex()57chkindexes ()
36{58{
37 test -f "$1/video.index" \59 test -f "$1/video.index" \
38 || $M2VMP2CUT_CMD_PATH/m2vscan "$1/video.m2v" "$1/video.index"60 || $M2VMP2CUT_CMD_PATH/m2vscan "$1/video.m2v" "$1/video.index"
61 test -f "$1/audio.scan" \
62 || $M2VMP2CUT_CMD_PATH/mp2cutpoints \
63 --scan "$1/audio.mp2" "$1/audio.scan"
39}64}
4065
41cmd_demux () # Demux mpeg2 file with ProjectX for further editing...66cmd_demux () # Demux mpeg2 file with ProjectX for further editing...
42{67{
43 needvar "$1" usage '<filename>'68 case $file in '')
44 test -f "$1" || die "'$1': not a file"69 die "No file to demux given" ;;
70 esac
45 test -h $M2VMP2CUT_CMD_PATH/ProjectX.jar || { \71 test -h $M2VMP2CUT_CMD_PATH/ProjectX.jar || { \
46 e2 Symbolic link \'$M2VMP2CUT_CMD_PATH/ProjectX.jar\' does not exist72 e2 Symbolic link \'$M2VMP2CUT_CMD_PATH/ProjectX.jar\' does not exist
47 die Please provide link and try again73 die Please provide link and try again
51 e2 ProjectX jar file \'$pjxjar\' does not exist77 e2 ProjectX jar file \'$pjxjar\' does not exist
52 die Fix this or it\'s symbolic link reference \'$M2VMP2CUT_CMD_PATH/ProjectX.j78 die Fix this or it\'s symbolic link reference \'$M2VMP2CUT_CMD_PATH/ProjectX.j
ar\'ar\'
53 }79 }
54 set -x
55 dn=`dirname "$1"`; bn=`basename "$1"`
56 od=`echo $bn | sed 's/\.[^.]*$//'`.d
57 test -d "$dn/$od/" && die "Directory '$dn/$od' is on the way".80 test -d "$dir" && die "Directory '$dir' is on the way (demuxed already)?"
58 mkdir "$dn/$od/"81 mkdir "$dir"
59 ln -s "../$bn" "$dn/$od/$bn"82 ln -s "../$basename" "$dir/$basename"
60 java -jar "$pjxjar" "$dn/$od/$bn"83 x java -jar "$pjxjar" -ini /dev/null "$dir/$basename"
61 cd "$dn/$od/"84 cd "$dir"
62 ln -s *.m2v video.m2v85 ln -s *.m2v video.m2v
63 ln -s *.mp2 audio.mp286 ln -s *.mp2 audio.mp2
64 chkvideoindex .87 chkindexes .
65}88}
6689
67cmd_cut () # Cut video with a graphical tool90cmd_select () # Select parts from video with a graphical tool
68{91{
69 needvar "$1" usage '<directory>'
70 test -f "$1/video.m2v" || die "'$1/video.m2v' does not exist"92 test -f "$dir/video.m2v" || die "'$dir/video.m2v' does not exist"
71 chkvideoindex "$1"93 chkindexes "$dir"
72 $M2VMP2CUT_CMD_PATH/m2vcut-gui \94 x $M2VMP2CUT_CMD_PATH/m2vcut-gui \
73 "$1/video.index" "$1/video.m2v" "$1/cutpoints"95 "$dir/video.index" "$dir/video.m2v" "$dir/cutpoints"
74 test -f "$1/cutpoints.1" && { case `wc "$1/cutpoints"` in96 test -f "$dir/cutpoints.1" && { case `wc "$dir/cutpoints"` in
75 *' '1' '*) cat "$1/cutpoints.1" >> "$1/cutpoints";; esac; }97 *' '1' '*) cat "$dir/cutpoints.1" >> "$dir/cutpoints";; esac; }
76}98}
7799
78cmd_run () # Run m2vmp2cut.pl to do the work...100cmd_cut () # Cut using m2vmp2cut.pl for the work...
79{101{
80 $M2VMP2CUT_CMD_PATH/m2vmp2cut.pl "$@"102 x $M2VMP2CUT_CMD_PATH/m2vmp2cut.pl --dir="$dir" "$@"
103}
104
105cmd_play () # Play resulting file with mplayer
106{
107 f="$dir"/m2vmp2cut-work/out.mpg
108 test -f "$f" || die "'$f' does not exist"
109 x mplayer "$@" "$f"
110}
111
112cmd_move () # Move final file to a new location (and name)
113{
114 needvar "$1" usage '<destfile>'
115 f="$dir"/m2vmp2cut-work/out.mpg
116 test -f "$f" || die "'$f' does not exist"
117 x mv "$f" "$1"
81}118}
82119
83cmd_help () # Help of all or some of the commands above120cmd_help () # Help of all or some of the commands above
84{121{
122 echo
85 sed -n "s|^#h $1[^:]*:||p" "$0"123 sed -n "s|^#h $1[^:]*:||p" "$0"
86}124}
87125
126cmd_example () # simple example commands
127{
128 cut -d: -f 2- >&2 <<.
129 :
130 : Simple example commands. In select/cut/play '<dir>' can be used.
131 : (<file> is for user convenience...)
132 :
133 : m2vmp2cut <file> demux
134 : m2vmp2cut <file> select
135 : m2vmp2cut <file> cut
136 : m2vmp2cut <file> play
137 :
138 : In above, there was basic workflow. 'cut' gui provides a test
139 : option -- but if you want to re-test, run these.
140 :
141 : m2vmp2cut <file> cut --test=200
142 : m2vmp2cut <file> play
143 :
144.
145}
146
88# ---147# ---
89148
90[ x"$1" = x ] && {149[ x"$1" = x ] && {
91 echo150 echo
92 echo Usage: $0 ' <command> [args]'151 echo Usage: m2vmp2cut '[-batch] (file|dir) <command> [args]'
93 echo152 echo
94 echo $0 commands available:153 echo m2vmp2cut commands available:
95 echo154 echo
96 sed -n '/^cmd_/ { s/cmd_/ /; s/ () [ -#]*/ /155 sed -n '/^cmd_/ { s/cmd_/ /; s/ () [ -#]*/ /
97 s/\(.\{15\}\) */\1/p; }' $0156 s/\(.\{15\}\) */\1/p; }' $0
127186
128# fixme: move these to separate doc file (w/ locale extension)187# fixme: move these to separate doc file (w/ locale extension)
129188
130#h lvev6frames:
131#h lvev6frames: lvev6frames (no options)189#h lvev6frames: lvev6frames (no options)
132#h lvev6frames:190#h lvev6frames:
133#h lvev6frames: Old versions of m2vmp2cut supported using lve-generated191#h lvev6frames: Old versions of m2vmp2cut supported using lve-generated
135#h lvev6frames: these old edits can be used with this m2vmp2cut version193#h lvev6frames: these old edits can be used with this m2vmp2cut version
136#h lvev6frames:194#h lvev6frames:
137195
138#h demux:
139#h demux: demux <filename>196#h demux: <filename> demux
140#h demux:197#h demux:
141#h demux: m2vmp2cut reguires mpeg files to be demuxed to elementary streams198#h demux: m2vmp2cut reguires mpeg files to be demuxed to elementary streams
142#h demux: before cutting. This command uses ProjectX to do the demuxing.199#h demux: before cutting. This command uses ProjectX to do the demuxing.
145#h demux: source file.202#h demux: source file.
146#h demux:203#h demux:
147204
205#h select: <directory> select
206#h select:
207#h select: This command uses new m2vcut-gui graphical utility for searching
208#h select: cutpoints. This work is done frame-accurately.
209#h select:
210
211#h cut: <directory> cut [options] ...
148#h cut:212#h cut:
149#h cut: cut <directory>213#h cut: This command is wrapper to m2vmp2cut.pl (which used to be the frontend
214#h cut: of m2vmp2cut in old versions). This command has extensive help of
215#h cut: it's own. Note that this (again) adds one third of disk usage so far
216#h cut: when this creates final output file.
150#h cut:217#h cut:
151#h cut: This command uses new m2vcut-gui graphical utility for searching
152#h cut: cutpoints. This work is done frame-accurately.
153#h cut:
154218
155#h run:219#h play: <directory> play [options]
156#h run: run [options] <directory> ...220#h play:
157#h run:221#h play: This command runs mplayer for the file created with cut command
158#h run: This command is wrapper to m2vmp2cut.pl (which used to be the frontend222#h play:
159#h run: of m2vmp2cut in old versions). This command has extensive help of
160#h run: it's own. Note that this (again) adds one third of disk usage so far
161#h run: when this creates final output file.
162#h run:
163
164
165

m2vmp2cut-0.65-dev/bin/wrapper.sh m2vmp2cut-0.67-dev/bin/wrapper.sh
7# All rights reserved7# All rights reserved
8#8#
9# Created: Tue Apr 22 19:10:35 EEST 2008 too9# Created: Tue Apr 22 19:10:35 EEST 2008 too
10# Last modified: Wed May 14 17:35:56 EEST 2008 too10# Last modified: Fri Jul 25 15:26:08 EEST 2008 too
1111
12eae () { echo; echo Press ENTER to close this window '' | tr -d \\012; read _; exit $1; 12eae () { echo; echo Press ENTER to close this window '' | tr -d \\012
}
13 read _; exit $1; }
1314
14die () { exec 1>&2; echo; echo "$@"; eae 1; }15die () { exec 1>&2; echo; echo "$@"; eae 1; }
1516
1819
19numtune () {20numtune () {
20 echo $1 | sed 's/\(...\)$/ \1/; s/\(...\) / \1 /; s/\(...\) / \1 /'21 echo $1 | sed 's/\(...\)$/ \1/; s/\(...\) / \1 /; s/\(...\) / \1 /'
22}
23
24#secstoday () { eval expr `date '+ 3600 \* %H + 60 \* %M + %S'`; }
25
26# feh does not grok proper -geometry string. need to make warpxpointer find...
27#warp_to_m2vcutgui () {
28# eval `xwininfo -all -name M2vCut \
29# | awk ' /Abs.*upp.*X:/ { x = $4 } /Width:/ { w = $2 }
30# /Abs.*upp.*Y:/ { y = $4 } /Height:/ { h = $2 }
31# END { print "x=" x + w / 2, "y=" y + h / 2 }'`
32#
33# "`dirname $0`"/warpxpointer $x $y
34#}
35
36m2vcut_warp_exit ()
37{
38 "`dirname $0`"/warpxpointer -name M2vCut c c
39 exit 0
21}40}
2241
23exec_xterm () {42exec_xterm () {
3150
32case $1 in51case $1 in
33 m2vcut_help)52 m2vcut_help)
34 exec_xterm 76x28-0+0 'M2vCut Help' m2vcut_outputhelp53 exec_xterm 76x35-0+0 'M2vCut Help' m2vcut_outputhelp
35 ;;54 ;;
36 m2vcut_outputhelp)55 m2vcut_outputhelp)
37 f=`echo $LANG |sed 's/[^A-Za-z_].*//'`56 f=`echo $LANG |sed 's/[^A-Za-z_].*//'`
83 exec_xterm 76x28-0+0 'M2vCut Test' m2vcut_runtest "$@"102 exec_xterm 76x28-0+0 'M2vCut Test' m2vcut_runtest "$@"
84 ;;103 ;;
85 m2vcut_runtest)104 m2vcut_runtest)
86 range=105 vd=`dirname "$5"`
87 case $2 in '') ;;106 test -f "$vd"/m2vcut-test/$2-$3 -a -f "$vd"/m2vcut-test/out.mpg || {
107 rm -rf "$vd"/m2vcut-test
108 to=--test=0
109 case $2 in '') range= rx= to= ;;
88 *) rs=`expr $2 - 200`; test $rs -lt 0 && rs=0; range=$rs-$2 ;; esac110 *) rs=`expr $2 - 200`; test $rs -lt 0 && rs=0; range=$rs-$2 rx=, ;; esac
89 case $3 in '') ;; *) range="$range,$3-`expr $3 + 200`";; esac111 case $3 in '') to= ;; *) range="$range$rx$3-`expr $3 + 200`" ;; esac
112
113 cwd=`cd \`dirname "$0"\`/; pwd`
114 "$cwd"/m2vmp2cut.pl $to "$vd" -r $range -v "$5" -d m2vcut-test
115 touch "$vd"/m2vcut-test/$2-$3
116 }
117 sleep 3 &
118 set -x
119 test -f "$vd"/m2vcut-test/out.mpg && mplayer "$vd"/m2vcut-test/out.mpg
120 wait
121 ;;
122 m2vcut_agraph)
123 shift
124 exec_xterm 76x28-0+0 'M2vCut Test' m2vcut_runagraph "$@"
125 ;;
126 m2vcut_runagraph)
127 shift
128 vd=`dirname "$1"`
129 eval `xdpyinfo | awk '/dimensions:/ { sub("x", " h=", $2); print "w=" $2; exit }
'`
130 case $w in '') die Can not resolve x display width ;; esac
131 case $h in '') die Can not resolve x display height ;; esac
132 test $w -ge 400 || die X display width too small
133 test $h -ge 300 || die X display height too small
134 w=`expr $w - 48`; h=100
135 ms2timecode () { awk 'BEGIN { ms='"$1"'; printf "%02d:%02d:%02d.%03d",
136 int(ms / 1000 / 60 / 60),
137 int(ms / 1000 / 60) % 60,
138 int(ms / 1000) % 60, (ms % 1000) }'; }
139 ms=`expr $2 \* 40`; l=`expr $3 \* 40`
140 s=`expr $ms - 1000`; test $s -lt 0 && s=0
141 e=`expr $ms + 1000`; test $e -gt $l && e=$l
142 ss=`expr $ms - $s`; ee=`expr $e - $s`
143 ss=`expr $ss \* $w`; m=`expr $ss / $ee`
144 #
145 ss=`ms2timecode $s`; ee=`ms2timecode $e`
146 #echo $s $e $ss, $ee
90 cwd=`cd \`dirname "$0"\`/; pwd`147 cwd=`cd \`dirname "$0"\`/; pwd`
91 vd=`dirname "$5"`148 byterange=`"$cwd"/mp2cutpoints "$ss-$ee" "$vd"/audio.mp2 /dev/null "$vd"/audio.s
can`
92 "$cwd"/m2vmp2cut.pl "$vd" -r $range -v "$5" -d m2vcut-test149 dd="$vd"/m2vcut-test
93 while :; do150 test -d "$dd" && rm -rf "$dd"
94 mplayer "$vd"/m2vcut-test/out.mpg151 mkdir "$dd" || die Can not create directory "$dd"
95 echo try again ?152 set -x
96 read line153 "$cwd"/fileparts $byterange "$vd"/audio.mp2 > "$dd"/audio.mp2
97 case $line in *yes*) ;; *) exit 0 ;; esac154 mplayer -vo null -vc null -ao pcm:file="$dd"/audio.wav "$dd"/audio.mp2
98 done155 "$cwd"/wavgraph "$dd"/audio.wav "$dd"/audio.xpm $w $h $m 25 1
156 case `env which feh 2>/dev/null` in /*)
157 :; : Press 'q' to close graph window ;:
158 "$cwd"/warpxpointer -trysecs 4 -name feh c c &
159 feh "$dd"/audio.xpm ; wait; m2vcut_warp_exit ;; esac
160 case `env which display 2>/dev/null` in /*)
161 :; : Press 'q' to close graph window ;:
162 "$cwd"/warpxpointer -trysecs 4 -name ImageMagick c c &
163 display "$dd"/audio.xpm ; wait; m2vcut_warp_exit ;; esac
164 set +x
165 die "Can not find image viewer. Install 'feh' or 'display' (or tune this script)
".
99 ;;166 ;;
100 die)167 die)
101 exec zenity --error --title "Fatal Error!" --text "$2"168 exec zenity --error --title "Fatal Error!" --text "$2"

m2vmp2cut-0.65-dev/doc/m2vcut_help-default m2vmp2cut-0.67-dev/doc/m2vcut_help-default
14(*) Changing Page Up/Down "direction", first time continue 25 gop.14(*) Changing Page Up/Down "direction", first time continue 25 gop.
15 jumps; after second change, go back to 5 gop jumps.15 jumps; after second change, go back to 5 gop jumps.
1616
171, 2 ... 9, 0: Jump to position 5%, 15% ... 85%, 95%.
1718
18TAB: Mark cutpoint to current position.19TAB: Mark cutpoint to current position.
19BackSpace: Delete cutpoint under current position (if any).20BackSpace: Delete cutpoint under current position (if any).
2021
21, (comma): Go to previous cutpoint from current location.22, (comma): Go to previous cutpoint from current location.
22. (period): Go to next cutpoint from current location.23. (period): Go to next cutpoint from current location.
2324
2425
25q: Quit, Saving cutpoints to file.26qq: Quit, Saving cutpoints to file.
2627
27t: Test output around current/closest cutpoint.28t: Test output around current/closest cutpoint.
29
30a: Show audio graph around current position.
2831
29i: information (about estimated final file size).32i: information (about estimated final file size).
3033

m2vmp2cut-0.65-dev/doc/m2vcut_help-fi_FI m2vmp2cut-0.67-dev/doc/m2vcut_help-fi_FI
13(*) Vaihtaessa Page Up/Down -suuntaa, ensimmäisellä kerralla jatka 2513(*) Vaihtaessa Page Up/Down -suuntaa, ensimmäisellä kerralla jatka 25
14 gopin hyppyjä; toisen suunnan vaihdon jälkeen palaa 5 gopin hyppyihin.14 gopin hyppyjä; toisen suunnan vaihdon jälkeen palaa 5 gopin hyppyihin.
1515
161, 2 ... 9, 0: Hyppää kohtaan 5%, 15% ... 85%, 95%.
17
16TAB: Merkitse leikkauspiste tämänhetkiseen kohtaan.18TAB: Merkitse leikkauspiste tämänhetkiseen kohtaan.
17BackSpace: Poista leikkauspiste mikäli ollaan leikkauspisteen "päällä".19BackSpace: Poista leikkauspiste mikäli ollaan leikkauspisteen "päällä".
1820
19, (pilkku): Siirry edelliseen leikkauspisteeseen nykypaikasta.21, (pilkku): Siirry edelliseen leikkauspisteeseen nykypaikasta.
20. (piste): Siirry seuraavaan leikkauspisteeseen nykypaikasta.22. (piste): Siirry seuraavaan leikkauspisteeseen nykypaikasta.
2123
22q: Lopeta, tallentaen leikkauspisteet tiedostoon.24qq: Lopeta, tallentaen leikkauspisteet tiedostoon.
2325
24t: Testaa tulos lähimmän leikkauspisteen kohdalta.26t: Testaa tulos lähimmän leikkauspisteen kohdalta.
27
28a: Näytä äänigraafi nykyisen sijainnin ympärillä.
2529
26i: tietoa (lopullisesta tiedostokoosta).30i: tietoa (lopullisesta tiedostokoosta).
2731

m2vmp2cut-0.65-dev/m2vmp2cut m2vmp2cut-0.67-dev/m2vmp2cut
7# All rights reserved7# All rights reserved
8#8#
9# Created: Wed Apr 23 19:56:14 EEST 2008 too9# Created: Wed Apr 23 19:56:14 EEST 2008 too
10# Last modified: Thu Apr 24 16:53:20 EEST 2008 too10# Last modified: Mon Jul 21 15:43:46 EEST 2008 too
1111
12ver=devel12ver=0.67-dev
13
14case $1 in '') echo; echo m2vmp2cut version $ver ;; esac
1315
14dn=`dirname "$0"`16dn=`dirname "$0"`
1517

m2vmp2cut-0.65-dev/src/Makefile m2vmp2cut-0.67-dev/src/Makefile
4# XXX mixed code from old & new system. to be fixed later (maybe)4# XXX mixed code from old & new system. to be fixed later (maybe)
55
6MSRCS= m2vscan.c m2vfilter.c fileparts.c mp2cutpoints.c \6MSRCS= m2vscan.c m2vfilter.c fileparts.c mp2cutpoints.c \
7 zzob.c filerotate.c bufwrite.c x.c subprog.c7 zzob.c filerotate.c bufwrite.c x.c
88
9SRCS= $(MSRCS) #embeds.c9SRCS= $(MSRCS) #embeds.c
1010
17EGHDRS=$(TOCCODE:%=ghdrs/%.h)17EGHDRS=$(TOCCODE:%=ghdrs/%.h)
1818
19BINARIES= ../bin/m2vscan ../bin/m2vfilter ../bin/fileparts ../bin/filerotate \19BINARIES= ../bin/m2vscan ../bin/m2vfilter ../bin/fileparts ../bin/filerotate \
20 ../bin/mp2cutpoints ../bin/m2vcut-gui ../bin/m2vtoyuv20 ../bin/mp2cutpoints ../bin/m2vcut-gui ../bin/m2vtoyuv ../bin/wavgraph \
21 ../bin/warpxpointer
2122
22all: $(BINARIES)23all: $(BINARIES)
2324
87 $(CC) -o $@ obj_b/filerotate.o obj_b/x.o88 $(CC) -o $@ obj_b/filerotate.o obj_b/x.o
8889
89../bin/m2vcut-gui: m2vcut-gui.c config/mpeg2.conf90../bin/m2vcut-gui: m2vcut-gui.c config/mpeg2.conf
90 sh m2vcut-gui.c; mv m2vcut-gui ../bin91 sh m2vcut-gui.c && mv m2vcut-gui ../bin
91 #$(CC) $(CFLAGS) -c $< -o $@92 #$(CC) $(CFLAGS) -c $< -o $@
9293
94../bin/wavgraph: wavgraph.c obj_b/x.o
95 sh wavgraph.c && mv wavgraph ../bin
96
93../bin/m2vtoyuv: m2vtoyuv.c config/mpeg2.conf97../bin/m2vtoyuv: m2vtoyuv.c config/mpeg2.conf
94 sh m2vtoyuv.c; mv m2vtoyuv ../bin98 sh m2vtoyuv.c && mv m2vtoyuv ../bin
9599
100../bin/warpxpointer: warpxpointer.c
101 sh warpxpointer.c && mv warpxpointer ../bin
102
96config/mpeg2.conf: ../tools/chksyslibmpeg.sh ../tools/buildlibmpeg.sh103config/mpeg2.conf: ../tools/chksyslibmpeg.sh ../tools/chklibmpeg-051.sh
97 ../tools/chksyslibmpeg.sh || ../tools/buildlibmpeg.sh .104 ../tools/chksyslibmpeg.sh || ../tools/chklibmpeg-051.sh ..
98105
99ghdrs/%_priv.h: %.c106ghdrs/%_priv.h: %.c
100 perl -x Makefile $< > $@107 perl -x Makefile $< > $@

m2vmp2cut-0.65-dev/src/m2vcut-gui.c m2vmp2cut-0.67-dev/src/m2vcut-gui.c
21 * All rights reserved21 * All rights reserved
22 *22 *
23 * Created: Sun Dec 30 14:17:12 EET 2007 too23 * Created: Sun Dec 30 14:17:12 EET 2007 too
24 * Last modified: Mon May 26 20:54:27 EEST 2008 too24 * Last modified: Fri Jun 13 21:49:32 EEST 2008 too
25 */25 */
2626
27// later (maybe?) test, undo, append-cut/merge to file (w/htonl()))27// later (maybe?) test, undo, append-cut/merge to file (w/htonl()))
1604 show_iframe(n);1604 show_iframe(n);
1605}1605}
16061606
1607void goto_percent(int pc)
1608{
1609 int n = G.lastindex * pc / 100;
1610 show_iframe(n);
1611}
1612
1607void goto_cutpoint(int cutpoint)1613void goto_cutpoint(int cutpoint)
1608{1614{
1609 int i = cutpoint;1615 int i = cutpoint;
1670 int dist2 = fn1 - G.currentframe;1676 int dist2 = fn1 - G.currentframe;
16711677
1672 if (dist1 < dist2)1678 if (dist1 < dist2)
1673 sprintf(framearg1, "%d", fn0);1679 sprintf(framearg2, "%d", fn0);
1674 else1680 else
1675 sprintf(framearg2, "%d", fn1);1681 sprintf(framearg1, "%d", fn1);
1676}1682}
16771683
1678static void test_cutpoint(void)1684static void test_cutpoint(void)
17601766
1761 run_command(m2vmp2cut_command("wrapper.sh"), "m2vcut_info",1767 run_command(m2vmp2cut_command("wrapper.sh"), "m2vcut_info",
1762 M.mpeg2filename, afp, gfp, allframes, greenframes, null);1768 M.mpeg2filename, afp, gfp, allframes, greenframes, null);
1769}
1770
1771static void show_agraph(void)
1772{
1773 char cfs[12], lfs[12];
1774 sprintf(cfs, "%d", G.currentframe);
1775 sprintf(lfs, "%d", G.lastframe);
1776 run_command(m2vmp2cut_command("wrapper.sh"), "m2vcut_agraph",
1777 M.mpeg2filename, cfs, lfs, null);
1763}1778}
17641779
1765gboolean main_window_delete_event(void * w, void * e, void * d)1780gboolean main_window_delete_event(void * w, void * e, void * d)
1840 case GDK_h: show_help(); break;1855 case GDK_h: show_help(); break;
1841 case GDK_i: show_info(); break;1856 case GDK_i: show_info(); break;
1842 case GDK_t: test_cutpoint(); break;1857 case GDK_t: test_cutpoint(); break;
1858 case GDK_a: show_agraph(); break;
18431859
1860 case GDK_q:
1861 if (prevkey == GDK_q)
1844 case GDK_q: main_window_delete_event(null,null,null);1862 main_window_delete_event(null,null,null);
1863 break;
18451864
1865 case GDK_1: case GDK_2: case GDK_3:
1866 case GDK_4: case GDK_5: case GDK_6:
1867 case GDK_7: case GDK_8: case GDK_9:
1868 goto_percent((k->keyval - GDK_0) * 10 - 5);
1869 break;
1870 case GDK_0: goto_percent(95);
1871 break;
1846 }1872 }
1847 prevkey = k->keyval;1873 prevkey = k->keyval;
1848 return true;1874 return true;

m2vmp2cut-0.65-dev/src/mp2cutpoints.c m2vmp2cut-0.67-dev/src/mp2cutpoints.c
1#if 0 /*1#if 0 /*
2 LF_OPTS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'2 LF_OPTS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'
3 set -x3 set -x
4 exec ${CC:-gcc} -Wall -DTESTING $LF_OPTS -o `basename $0 .c` $0 x.c; */4 exec ${CC:-gcc} -Wall -ggdb $LF_OPTS -o `basename $0 .c` $0 x.c; */
5#endif5#endif
6/*6/*
7 * mp2cutpoints.c $7 * mp2cutpoints.c $
12 * All rights reserved12 * All rights reserved
13 *13 *
14 * Created: Thu Oct 20 19:32:21 EEST 2005 too14 * Created: Thu Oct 20 19:32:21 EEST 2005 too
15 * Last modified: Mon May 05 17:12:00 EEST 2008 too15 * Last modified: Tue Jun 03 22:51:36 EEST 2008 too
16 *16 *
17 * This program is licensed under the GPL v2. See file COPYING for details.17 * This program is licensed under the GPL v2. See file COPYING for details.
18 */18 */
1919
20#include <unistd.h>
20#include <stdio.h>21#include <stdio.h>
21#include <string.h>22#include <string.h>
22#include <stdlib.h>23#include <stdlib.h>
23#include <fcntl.h>24#include <fcntl.h>
25#include <sys/types.h>
26#include <sys/stat.h>
2427
25#define DBGS 028#define DBGS 0
26#include "x.h"29#include "x.h"
27#include "bufwrite.h"30#include "bufwrite.h"
2831
32/* ((1 << (8 * sizeof (v) - 1)) - 1) */
33#define MAXINTVAL(v) ((((1 << (8 * sizeof (v) - 2)) - 1) << 1) | 1)
34
2935
30/* hand-converted python->c, with few modifications */36/* hand-converted python->c, with few modifications */
31
32
33/* mpeg1 layer 2 bitrate indexes */
34static const int biarr[] =
35/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
36 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 };
37
38/* mpeg1 sampling rate indexes */
39static const int siarr[] = { 44100, 48000, 32000 };
40
4137
42typedef struct _simplefilebuf simplefilebuf;38typedef struct _simplefilebuf simplefilebuf;
43struct _simplefilebuf39struct _simplefilebuf
57 self->offset = self->len = self->gone = 0;53 self->offset = self->len = self->gone = 0;
58}54}
5955
56void simplefilebuf_seekset(simplefilebuf * self, unsigned int pos)
57{
58 if (lseek(self->fd, pos, SEEK_SET) < 0)
59 xerrf("Seek failed:");
60 self->offset = self->len = 0;
61 self->gone = pos;
62}
63
60bool simplefilebuf_fillbuf(simplefilebuf * self, unsigned int rest)64bool simplefilebuf_fillbuf(simplefilebuf * self, unsigned int rest)
61{65{
62 int l;66 int l;
128 if (! simplefilebuf_fillbuf(self, 0))132 if (! simplefilebuf_fillbuf(self, 0))
129 return -1;133 return -1;
130 }134 }
135}
136
137/* mpeg1 layer 2 bitrate indexes */
138static const int biarr[] =
139/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
140 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 };
141
142/* mpeg1 sampling rate indexes */
143static const int siarr[] = { 44100, 48000, 32000 };
144
145/* 84218421 84218421 84218421 84218421
146 * 76543210 76543210 76543210 76543210
147 * Mpeg audio header: AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
148 */
149
150typedef unsigned char u8;
151typedef struct
152{
153 u8 id; /* B above (mpeg audio version id) */
154 u8 ld; /* C above (layer description) */
155
156 u8 bi; /* E above (bitrate index) */
157 u8 si; /* F above (sampling rate frequency index) */
158 u8 pad; /* G above (padding bit) */
159 int afn;
160 int ms;
161 int bitrate;
162 int samplerate;
163 simplefilebuf * sfb;
164} Mp2Info;
165
166static int mp2get(Mp2Info * m2i)
167{
168 char * p;
169 int flib;
170
171 p = (char *)simplefilebuf_needbytes(m2i->sfb, 3);
172 if (p == NULL)
173 xerrf("XXX ERROR XXX.\n");
174
175 /* Check that we have header (frame sync: 11 bits set (A above).) */
176 if ((p[0] & 0xe0) != 0xe0)
177 return 0;
178
179 m2i->id = p[0] & 0x18; /* B above (mpeg audio version id) */
180 m2i->ld = p[0] & 0x06; /* C above (layer description) */
181 /*u8 pb = p[0] & 0x01; / * D above (Protection bit) */
182
183 m2i->bi = p[1] & 0xf0; /* E above (bitrate index) */
184 m2i->si = p[1] & 0x0c; /* F above (sampling rate frequency index) */
185 m2i->pad= p[1] & 0x02; /* G above (padding bit) */
186
187 m2i->bitrate = biarr[m2i->bi >> 4];
188 m2i->samplerate = siarr[m2i->si >> 2];
189
190 m2i->afn++;
191
192 if (m2i->id != 0x18)
193 xerrf("Frame %d (pos %d) not mpeg version 1.\n", m2i->afn,
194 simplefilebuf_filepos(m2i->sfb) - 4);
195 if (m2i->ld != 0x04)
196 xerrf("Frame %d (pos %d) not mpeg layer 2.\n", m2i->afn,
197 simplefilebuf_filepos(m2i->sfb) - 4);
198
199 flib = 144000 * m2i->bitrate / m2i->samplerate + (m2i->pad >> 1);
200 m2i->ms = flib * 8 / m2i->bitrate;
201
202 (void)simplefilebuf_needbytes(m2i->sfb, flib - 4);
203
204 return flib;
205}
206
207static const char * ms2tcode(int ms)
208{
209 static char buf[32];
210
211 sprintf(buf, "%02d:%02d:%02d.%03d",
212 ms / 1000/60/60, (ms / 1000/60) % 60, (ms / 1000) % 60, ms % 1000);
213 return buf;
131}214}
132215
133static int tcode2ms(char * val)216static int tcode2ms(char * val)
166 }249 }
167}250}
168251
169int main(int argc, char ** argv)252static int wopen(char * ofile)
253{
254 int ofd = open(ofile, O_WRONLY|O_CREAT|O_TRUNC, 0644);
255 if (ofd < 0)
256 xerrf("Opening file '%s' for writing failed:", ofile);
257 return ofd;
258}
259
260static int filesize(int fd)
261{
262 struct stat st;
263 if (fstat(fd, &st) < 0)
264 xerrf("stat failed:");
265 return st.st_size;
266}
267
268void scan(char * ifile, char * sfile)
269{
270 int sfd = wopen(sfile);
271 simplefilebuf sfb;
272 Mp2Info m2i;
273 int fsize;
274
275 int totaltime = 0, prevtotal = 0;
276 int position = 0, prevposx = 0;
277 int cpc, ppc = 0;
278 int pbr = 0, psr = 0;
279
280 memset(&m2i, 0, sizeof m2i);
281 simplefilebuf_init(&sfb, ifile);
282 m2i.sfb = &sfb;
283 fsize = filesize(sfb.fd);
284
285 fdprintf(sfd, "#offset msec fnum brate srate - time\n");
286
287 while (true)
288 {
289 int skipped = simplefilebuf_dumpto(&sfb, '\377');
290 if (skipped < 0)
291 {
292 fdprintf(sfd,
293 "#File ended: audio frames: %d Total time: %d ms (%s).\n",
294 m2i.afn, totaltime, ms2tcode(totaltime));
295 fdprintf(0, "\r- Scanning audio at %d of %d bytes (100%%).\n",
296 fsize, fsize);
297 exit(0);
298 }
299
300 if (skipped > 0)
301 {
302 fprintf(stderr, "Skipped %d bytes of garbage before audio frame %d.",
303 skipped, m2i.afn + 1);
304 skipped = 0;
305 }
306 cpc = position / (fsize / 100);
307 if (ppc != cpc)
308 {
309 fdprintf(0, "\r- Scanning audio at %d of %d bytes (%d%%)",
310 position, fsize, cpc);
311 ppc = cpc;
312 }
313
314 position = simplefilebuf_filepos(&sfb) - 1;
315
316 if (mp2get(&m2i) > 0)
317 {
318 if (m2i.bitrate != pbr || m2i.samplerate != psr)
319 {
320 fdprintf(0, "\rFrame %d (pos %d): bitrate %d, samplerate %d.\n",
321 m2i.afn, position, m2i.bitrate, m2i.samplerate);
322 pbr = m2i.bitrate; psr = m2i.samplerate;
323
324 fdprintf(sfd, "%d %d %d %d %d - %s \n", position, totaltime,
325 m2i.afn, pbr, psr, ms2tcode(totaltime));
326#define OFFDIST (2 * 1000 * 1000)
327 prevposx = position / OFFDIST;
328 }
329 else if (position / OFFDIST != prevposx) {
330 fdprintf(sfd, "%d %d %d %d %d - %s\n", position, totaltime,
331 m2i.afn, pbr, psr, ms2tcode(totaltime));
332 prevposx = position / OFFDIST;
333 }
334 prevtotal = totaltime;
335 totaltime += m2i.ms;
336 }
337 else
338 simplefilebuf_unusedbytes(&sfb, 3);
339 }
340}
341
342void cutpoints(char * timespec, char * ifile, char * ofile, char * sfile)
170{343{
171 int timev[512];344 int timev[512];
172 char * times[512];345 char * times[512];
175 char * p, *q, *r;348 char * p, *q, *r;
176349
177 int lasttime, lastindex;350 int lasttime, lastindex;
178 int afn = 0;
179 int stime;351 int stime;
180 int totaltime = 0;352 int totaltime = 0;
181 int prevtotal = 0;353 int prevtotal = 0;
183 int cpc, ppc = 0;355 int cpc, ppc = 0;
184 int pbr = 0, psr = 0;356 int pbr = 0, psr = 0;
185357
358 struct { int pos; int time; int afn; } prevscan, currscan;
359
186 int ofd;360 int ofd;
361 FILE * sfh;
187 simplefilebuf sfb;362 simplefilebuf sfb;
363 Mp2Info m2i;
188364
189 if (argc < 4)365 memset(&m2i, 0, sizeof m2i);
190 xerrf("argc < 4\n");366 m2i.sfb = &sfb;
191367
192 q = argv[1];368 memset(&prevscan, 0 , sizeof prevscan);
369 memset(&currscan, 0 , sizeof currscan);
370
371 if (sfile) {
372 sfh = fopen(sfile, "r");
373 if (sfh == NULL)
374 xerrf("Opening '%s' failed:", sfile);
375 }
376 else {
377 currscan.time = MAXINTVAL(currscan.time);
378 sfh = NULL;
379 }
380
381 q = timespec;
193 for (i = 0; i < 510; i += 2)382 for (i = 0; i < 510; i += 2)
194 {383 {
195 p = strchr(q, ',');384 p = strchr(q, ',');
210 if (i == 510)399 if (i == 510)
211 xerrf("Too long timecode arg string.\n");400 xerrf("Too long timecode arg string.\n");
212 lastindex = i + 2;401 lastindex = i + 2;
213 ofd = open(argv[3], O_WRONLY|O_CREAT|O_TRUNC, 0644);
214 if (ofd < 0)
215 xerrf("Opening file %s for writing failed:", argv[3]);
216402
403 ofd = wopen(ofile);
217 simplefilebuf_init(&sfb, argv[2]);404 simplefilebuf_init(&sfb, ifile);
218405
219 stime = timev[0];406 stime = timev[0];
220 i = 0;407 i = 0;
221 while (true)408 while (true)
222 {409 {
410 int skipped;
411
412 if (stime >= currscan.time) {
413 char linebuf[128];
414 while (true) {
415 int offset, msec, afn, brate, srate;
416 if (fgets(linebuf, sizeof linebuf, sfh) == NULL) {
417 if (prevscan.pos > position) {
418 simplefilebuf_seekset(&sfb, prevscan.pos);
419 m2i.afn = prevscan.afn;
420 position = prevscan.pos; totaltime = prevscan.time;
421 }
422 currscan.time = MAXINTVAL(currscan.time);
423 break;
424 }
425 if (sscanf(linebuf, "%d %d %d %d %d",
426 &offset, &msec, &afn, &brate, &srate) == 5) {
427 if (brate != pbr || psr != psr) {
428 fdprintf(0, "\rFrame %d (pos %d): bitrate %d, samplerate %d.\n",
429 afn, offset, brate, srate);
430 pbr = brate; psr = srate;
431 /* XXX better handling (and error message) below */
432 if (i & 1)
433 xerrf("Audio rate change in output is problematic ! "
434 "exiting.");
435 }
436 }
437 else
438 continue;
439 currscan.time = msec;
440 currscan.pos = offset;
441 currscan.afn = afn;
442 if (currscan.time > stime) {
443 if (prevscan.pos > position) {
444 simplefilebuf_seekset(&sfb, prevscan.pos);
445 m2i.afn = prevscan.afn;
446 position = prevscan.pos; totaltime = prevscan.time;
447 }
448 break;
449 }
450 prevscan = currscan;
451 }
452 }
453
223 int skipped = simplefilebuf_dumpto(&sfb, '\377');454 skipped = simplefilebuf_dumpto(&sfb, '\377');
224 if (skipped < 0)455 if (skipped < 0)
225 {456 {
226 fdprintf(ofd, "cut %s: %s filepos: %d sync: #EOF!\n",457 fdprintf(ofd, "cut %s: %s filepos: %d sync: #EOF!\n",
227 i & 1? "out": "in ", times[i], simplefilebuf_filepos(&sfb));458 i & 1? "out": "in ", times[i], simplefilebuf_filepos(&sfb));
459 fdprintf(ofd,
228 fdprintf(ofd, "File ended: audio frames: %d Total time: %s ms.\n");460 "File ended: audio frames: %d Total time: %d ms (%s).\n",
461 m2i.afn, totaltime, ms2tcode(totaltime));
229 fdprintf(0, "\r-Scanning audio at %d ms of /d ms (100%%).",462 fdprintf(0, "\r- Scanning audio at %d ms of %d ms (100%%).\n",
230 lasttime, lasttime);463 lasttime, lasttime);
231 printpositions(positions, i);464 printpositions(positions, i);
232 exit(0);465 exit(0);
235 if (skipped > 0)468 if (skipped > 0)
236 {469 {
237 fprintf(stderr, "Skipped %d bytes of garbage before audio frame %d.",470 fprintf(stderr, "Skipped %d bytes of garbage before audio frame %d.",
238 skipped, afn + 1);471 skipped, m2i.afn + 1);
239 skipped = 0;472 skipped = 0;
240 }473 }
241 cpc = totaltime * 100 / lasttime;474 cpc = totaltime / (lasttime / 100);
242 if (ppc != cpc)475 if (ppc != cpc || totaltime == lasttime)
243 {476 {
244 fdprintf(0, "\r- Scanning audio at %d ms of %d ms (%d%%)'",477 fdprintf(0, "\r- Scanning audio at %d ms of %d ms (%d%%)",
245 totaltime, lasttime, cpc);478 totaltime, lasttime, cpc);
246 ppc = cpc;479 ppc = cpc;
247 }480 }
274 }507 }
275 position = simplefilebuf_filepos(&sfb) - 1;508 position = simplefilebuf_filepos(&sfb) - 1;
276509
277 p = (char *)simplefilebuf_needbytes(&sfb, 3);510 if (mp2get(&m2i) > 0)
278 if (p == NULL)
279 xerrf("XXX ERROR XXX.\n");
280
281 /* 84218421 84218421 84218421 84218421
282 * 76543210 76543210 76543210 76543210
283 * Mpeg audio header: AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
284 *511 {
285 * Check that we have header (frame sync: 11 bits set (A above).)
286 */
287 if ((p[0] & 0xe0) == 0xe0)
288 {
289 typedef unsigned char u8;
290 u8 id = p[0] & 0x18; /* B above (mpeg audio version id) */
291 u8 ld = p[0] & 0x06; /* C above (layer description) */
292 /*u8 pb = p[0] & 0x01; / * D above (Protection bit) */
293
294 u8 bi = p[1] & 0xf0; /* E above (bitrate index) */
295 u8 si = p[1] & 0x0c; /* F above (sampling rate frequency index) */
296 u8 pad= p[1] & 0x02; /* G above (padding bit) */
297 /*u8 pri= p[1] & 0x01; / * H above (private bit) */
298
299 /*u8 cm = p[2] & 0xc0; / * I above (channel mode) */
300 /*u8 me = p[2] & 0x30; / * J above (mode extension) */
301 /*u8 c = p[2] & 0x08; / * K above (copyright) */
302 /*u8 o = p[2] & 0x04; / * L above (original) */
303 /*u8 e = p[2] & 0x03; / * M above (emphasis) */
304 int flib, ms;
305
306 int bitrate = biarr[bi >> 4];
307 int samplerate = siarr[si >> 2];
308
309 afn += 1;
310
311 if (id != 0x18)
312 xerrf("Frame %d (pos %d) not mpeg version 1.\n", afn, position);
313 if (ld != 0x04)
314 xerrf("Frame %d (pos %d) not mpeg layer 2.\n", afn, position);
315
316 if (bitrate != pbr || samplerate != psr)512 if (m2i.bitrate != pbr || m2i.samplerate != psr)
317 {513 {
318 fdprintf(0, "\rFrame %d (pos %d): bitrate %d, samplerate %d.\n",514 fdprintf(0, "\rFrame %d (pos %d): bitrate %d, samplerate %d.\n",
319 afn, position, bitrate, samplerate);515 m2i.afn, position, m2i.bitrate, m2i.samplerate);
320 pbr = bitrate; psr = samplerate;516 pbr = m2i.bitrate; psr = m2i.samplerate;
321517
322 /* XXX better handling (and error message) below */518 /* XXX better handling (and error message) below */
323 if (i & 1)519 if (i & 1)
324 xerrf("Audio rate change in output is problematic ! exiting.");520 xerrf("Audio rate change in output is problematic ! exiting.");
325 }521 }
326522
327 flib = 144000 * bitrate / samplerate + (pad >> 1);
328 ms = flib * 8 / bitrate;
329
330 prevtotal = totaltime;523 prevtotal = totaltime;
331 totaltime += ms;524 totaltime += m2i.ms;
332
333 if (simplefilebuf_needbytes(&sfb, flib - 4) == NULL)
334 {
335 fdprintf(ofd, "File ended: audio frames: %d "
336 "Total time %d ms.\n", afn, totaltime);
337 fdprintf(ofd, "Last frame: %d bytes.\n", sfb.len + 4);
338 exit(0);
339 }
340 }525 }
341 else526 else
342 simplefilebuf_unusedbytes(&sfb, 3);527 simplefilebuf_unusedbytes(&sfb, 3);
343 }528 }
529}
530
531int main(int argc, char ** argv)
532{
533 if (argc < 4)
534 xerrf("Usage: %s (--scan|timespec) ifile ofile [sfile]\n", argv[0]);
535
536 if (strcmp(argv[1], "--scan") == 0)
537 scan(argv[2], argv[3]);
538 else
539 cutpoints(argv[1], argv[2], argv[3], argv[4]);
344 return 0;540 return 0;
345}541}
346542

Only in m2vmp2cut-0.67-dev/src: warpxpointer.c

Only in m2vmp2cut-0.67-dev/src: wavgraph.c

Only in m2vmp2cut-0.67-dev/tools: buildlibmpeg-051.sh

Only in m2vmp2cut-0.65-dev/tools: buildlibmpeg.sh

Only in m2vmp2cut-0.67-dev/tools: chklibmpeg-051.sh

Only in m2vmp2cut-0.65-dev/tools: xdist.pl