| 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 controlled | 2 | # This file is not version controlled |
| 3 | | 3 | |
| | 4 | ------------------------------------------------------------------------ |
| | 5 | r2169 | too | 2008-07-25 15:53:35 +0300 (Fri, 25 Jul 2008) | 1 line |
| | 6 | Changed 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 | |
| | 12 | Version 0.67-dev |
| | 13 | ------------------------------------------------------------------------ |
| | 14 | r2168 | too | 2008-07-25 15:27:52 +0300 (Fri, 25 Jul 2008) | 1 line |
| | 15 | Changed paths: |
| | 16 | M /main/projects/m2vmp2cut/bin/wrapper.sh |
| | 17 | |
| | 18 | m2vcut-gui test: check existence of .../out.mpg, for better output error msgs |
| | 19 | ------------------------------------------------------------------------ |
| | 20 | r2167 | too | 2008-07-25 11:57:56 +0300 (Fri, 25 Jul 2008) | 1 line |
| | 21 | Changed paths: |
| | 22 | M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh |
| | 23 | |
| | 24 | --disable-shared |
| | 25 | ------------------------------------------------------------------------ |
| | 26 | r2165 | too | 2008-07-23 12:46:35 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 27 | Changed paths: |
| | 28 | M /main/projects/m2vmp2cut/Makefile |
| | 29 | |
| | 30 | use snapshot version in installation. |
| | 31 | ------------------------------------------------------------------------ |
| | 32 | r2164 | too | 2008-07-23 12:31:07 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 33 | Changed paths: |
| | 34 | M /main/projects/m2vmp2cut/Makefile |
| | 35 | |
| | 36 | snapshot installable again. |
| | 37 | ------------------------------------------------------------------------ |
| | 38 | r2163 | too | 2008-07-23 12:20:55 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 39 | Changed paths: |
| | 40 | M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh |
| | 41 | M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh |
| | 42 | |
| | 43 | path to libmpeg2-0.5.1.tar.gz given as arg for building. |
| | 44 | ------------------------------------------------------------------------ |
| | 45 | r2162 | too | 2008-07-23 12:20:15 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 46 | Changed paths: |
| | 47 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 48 | |
| | 49 | suppress m2vmp2cut path in messages... |
| | 50 | ------------------------------------------------------------------------ |
| | 51 | r2161 | too | 2008-07-23 11:46:17 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 52 | Changed paths: |
| | 53 | M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh |
| | 54 | |
| | 55 | small message clarification tune. |
| | 56 | ------------------------------------------------------------------------ |
| | 57 | r2158 | too | 2008-07-23 11:39:41 +0300 (Wed, 23 Jul 2008) | 1 line |
| | 58 | Changed paths: |
| | 59 | M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh |
| | 60 | M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh |
| | 61 | |
| | 62 | 2 missing x propsets |
| | 63 | ------------------------------------------------------------------------ |
| | 64 | r2157 | too | 2008-07-21 16:18:31 +0300 (Mon, 21 Jul 2008) | 1 line |
| | 65 | Changed paths: |
| | 66 | M /main/projects/m2vmp2cut/Makefile |
| | 67 | |
| | 68 | Fix version at '_dist' target (no more at 'install' target) |
| | 69 | ------------------------------------------------------------------------ |
| | 70 | r2156 | too | 2008-07-21 15:49:35 +0300 (Mon, 21 Jul 2008) | 1 line |
| | 71 | Changed paths: |
| | 72 | M /main/projects/m2vmp2cut/m2vmp2cut |
| | 73 | |
| | 74 | show version if no args given |
| | 75 | ------------------------------------------------------------------------ |
| | 76 | r2155 | too | 2008-07-21 15:33:41 +0300 (Mon, 21 Jul 2008) | 1 line |
| | 77 | Changed paths: |
| | 78 | M /main/projects/m2vmp2cut/Makefile |
| | 79 | M /main/projects/m2vmp2cut/VERSION |
| | 80 | M /main/projects/m2vmp2cut/tools/buildlibmpeg-051.sh |
| | 81 | |
| | 82 | Source & makefile ready for 0.67(-dev) -- docs + testing todo |
| | 83 | ------------------------------------------------------------------------ |
| | 84 | r2154 | too | 2008-07-21 15:20:06 +0300 (Mon, 21 Jul 2008) | 1 line |
| | 85 | Changed paths: |
| | 86 | M /main/projects/m2vmp2cut/src/Makefile |
| | 87 | M /main/projects/m2vmp2cut/tools/chklibmpeg-051.sh |
| | 88 | |
| | 89 | better libmpeg2 requirement message. subprog.o removed... |
| | 90 | ------------------------------------------------------------------------ |
| | 91 | r2152 | too | 2008-07-20 20:56:09 +0300 (Sun, 20 Jul 2008) | 1 line |
| | 92 | Changed 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 | |
| | 97 | check and use libmpeg2 0.5.1. |
| | 98 | ------------------------------------------------------------------------ |
| | 99 | r2151 | too | 2008-07-20 18:47:58 +0300 (Sun, 20 Jul 2008) | 1 line |
| | 100 | Changed 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 | |
| | 105 | buildlibmpeg scripts for 0.5.1 and trunk builds |
| | 106 | ------------------------------------------------------------------------ |
| | 107 | r2138 | too | 2008-06-14 08:52:25 +0300 (Sat, 14 Jun 2008) | 1 line |
| | 108 | Changed paths: |
| | 109 | M /main/projects/m2vmp2cut/src/wavgraph.c |
| | 110 | |
| | 111 | proper structure initialization (c99 style) |
| | 112 | ------------------------------------------------------------------------ |
| | 113 | r2137 | too | 2008-06-13 22:14:59 +0300 (Fri, 13 Jun 2008) | 5 lines |
| | 114 | Changed 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 | |
| | 121 | m2vcut-gui: Key Q -> qq to exit. keys 1234567890 jumps to 5-95% in video file |
| | 122 | wavgraph: Show 1 pixel dots at video frame egdes. Color changes |
| | 123 | m2vcut_help-*: Add number key doc. Q -> qq |
| | 124 | wrapper.sh: Add '25 1' args to wavgraph command line (video frame rate info) |
| | 125 | ------------------------------------------------------------------------ |
| | 126 | r2136 | too | 2008-06-12 21:41:09 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 127 | Changed 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 | ------------------------------------------------------------------------ |
| | 133 | r2135 | too | 2008-06-12 21:27:49 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 134 | Changed paths: |
| | 135 | M /main/projects/m2vmp2cut/src/warpxpointer.c |
| | 136 | |
| | 137 | sleep time reduced from 2 sec to 500 msec. tries val internally doubled... |
| | 138 | ------------------------------------------------------------------------ |
| | 139 | r2134 | too | 2008-06-12 21:22:08 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 140 | Changed paths: |
| | 141 | M /main/projects/m2vmp2cut/bin/wrapper.sh |
| | 142 | |
| | 143 | use warpxpointer in wrapper.sh, in agraph. |
| | 144 | ------------------------------------------------------------------------ |
| | 145 | r2133 | too | 2008-06-12 21:11:48 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 146 | Changed paths: |
| | 147 | M /main/projects/m2vmp2cut/src/warpxpointer.c |
| | 148 | |
| | 149 | warpxpointer: removed daemon, replaced with tries |
| | 150 | ------------------------------------------------------------------------ |
| | 151 | r2132 | too | 2008-06-12 21:01:57 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 152 | Changed paths: |
| | 153 | M /main/projects/m2vmp2cut/src/warpxpointer.c |
| | 154 | |
| | 155 | warpxpointer can now take daemon and name args. |
| | 156 | ------------------------------------------------------------------------ |
| | 157 | r2131 | too | 2008-06-12 19:57:00 +0300 (Thu, 12 Jun 2008) | 1 line |
| | 158 | Changed 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 | |
| | 163 | added warpxpointer, not useful yet (because of 'feh') |
| | 164 | ------------------------------------------------------------------------ |
| | 165 | r2130 | too | 2008-06-11 23:19:45 +0300 (Wed, 11 Jun 2008) | 2 lines |
| | 166 | Changed 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 | |
| | 172 | Q quits m2vcut-gui. 'a' added to help texts. |
| | 173 | use 'feh' or 'display' to show agraph (or print error) |
| | 174 | ------------------------------------------------------------------------ |
| | 175 | r2129 | too | 2008-06-11 23:06:07 +0300 (Wed, 11 Jun 2008) | 1 line |
| | 176 | Changed paths: |
| | 177 | M /main/projects/m2vmp2cut/bin/wrapper.sh |
| | 178 | M /main/projects/m2vmp2cut/src/wavgraph.c |
| | 179 | |
| | 180 | current position in agraph |
| | 181 | ------------------------------------------------------------------------ |
| | 182 | r2128 | too | 2008-06-11 20:36:24 +0300 (Wed, 11 Jun 2008) | 1 line |
| | 183 | Changed 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 | |
| | 189 | agraph scaling and integration |
| | 190 | ------------------------------------------------------------------------ |
| | 191 | r2127 | too | 2008-06-11 18:37:21 +0300 (Wed, 11 Jun 2008) | 1 line |
| | 192 | Changed paths: |
| | 193 | M /main/projects/m2vmp2cut/src/wavgraph.c |
| | 194 | |
| | 195 | first graphs! |
| | 196 | ------------------------------------------------------------------------ |
| | 197 | r2126 | too | 2008-06-11 16:31:19 +0300 (Wed, 11 Jun 2008) | 1 line |
| | 198 | Changed 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 | ------------------------------------------------------------------------ |
| | 204 | r2124 | too | 2008-06-09 22:21:37 +0300 (Mon, 09 Jun 2008) | 1 line |
| | 205 | Changed paths: |
| | 206 | M /main/projects/m2vmp2cut/bin/wrapper.sh |
| | 207 | M /main/projects/m2vmp2cut/src/wavgraph.c |
| | 208 | |
| | 209 | some progress in audio visualizing code |
| | 210 | ------------------------------------------------------------------------ |
| | 211 | r2123 | too | 2008-06-07 18:44:35 +0300 (Sat, 07 Jun 2008) | 1 line |
| | 212 | Changed paths: |
| | 213 | A /main/projects/m2vmp2cut/src/wavgraph.c |
| | 214 | |
| | 215 | beginnings of 'wavgraph' (work name) |
| | 216 | ------------------------------------------------------------------------ |
| | 217 | r2122 | too | 2008-06-04 22:12:21 +0300 (Wed, 04 Jun 2008) | 1 line |
| | 218 | Changed paths: |
| | 219 | M /main/projects/m2vmp2cut/bin/wrapper.sh |
| | 220 | |
| | 221 | most adata code on wrapper.sh |
| | 222 | ------------------------------------------------------------------------ |
| | 223 | r2121 | too | 2008-06-03 22:54:32 +0300 (Tue, 03 Jun 2008) | 1 line |
| | 224 | Changed 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 | |
| | 230 | move command. mp2cutpoints seek accelerator bugfix. tunes. |
| | 231 | ------------------------------------------------------------------------ |
| | 232 | r2120 | too | 2008-06-01 23:39:23 +0300 (Sun, 01 Jun 2008) | 1 line |
| | 233 | Changed paths: |
| | 234 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl |
| | 235 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 236 | |
| | 237 | cosmic. |
| | 238 | ------------------------------------------------------------------------ |
| | 239 | r2119 | too | 2008-06-01 23:29:22 +0300 (Sun, 01 Jun 2008) | 1 line |
| | 240 | Changed paths: |
| | 241 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 242 | |
| | 243 | tunes |
| | 244 | ------------------------------------------------------------------------ |
| | 245 | r2118 | too | 2008-06-01 22:33:35 +0300 (Sun, 01 Jun 2008) | 1 line |
| | 246 | Changed 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 | |
| | 251 | scan. speedup. fixes. |
| | 252 | ------------------------------------------------------------------------ |
| | 253 | r2117 | too | 2008-05-31 17:09:20 +0300 (Sat, 31 May 2008) | 1 line |
| | 254 | Changed paths: |
| | 255 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl |
| | 256 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 257 | |
| | 258 | m2vmp2cut.sh: commands arg reorg. |
| | 259 | ------------------------------------------------------------------------ |
| | 260 | r2116 | too | 2008-05-31 13:58:18 +0300 (Sat, 31 May 2008) | 1 line |
| | 261 | Changed paths: |
| | 262 | M /main/projects/m2vmp2cut/src/mp2cutpoints.c |
| | 263 | |
| | 264 | scan percentage fixes... |
| | 265 | ------------------------------------------------------------------------ |
| | 266 | r2115 | too | 2008-05-31 13:13:07 +0300 (Sat, 31 May 2008) | 1 line |
| | 267 | Changed paths: |
| | 268 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl |
| | 269 | |
| | 270 | s/audio.info/audio.cuts/ |
| | 271 | ------------------------------------------------------------------------ |
| | 272 | r2114 | too | 2008-05-31 12:55:10 +0300 (Sat, 31 May 2008) | 1 line |
| | 273 | Changed paths: |
| | 274 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl |
| | 275 | |
| | 276 | audio.scan added to (2nd) mp2cutpoints command line |
| | 277 | ------------------------------------------------------------------------ |
| | 278 | r2113 | too | 2008-05-31 12:16:54 +0300 (Sat, 31 May 2008) | 1 line |
| | 279 | Changed paths: |
| | 280 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.pl |
| | 281 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 282 | |
| | 283 | more of video.index and audio.scan creation |
| | 284 | ------------------------------------------------------------------------ |
| | 285 | r2111 | too | 2008-05-31 10:45:14 +0300 (Sat, 31 May 2008) | 1 line |
| | 286 | Changed 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 | |
| | 292 | tunes and future preparation. |
| | 293 | ------------------------------------------------------------------------ |
| | 294 | r2110 | too | 2008-05-31 10:24:35 +0300 (Sat, 31 May 2008) | 1 line |
| | 295 | Changed paths: |
| | 296 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 297 | |
| | 298 | insufficient testing :( |
| | 299 | ------------------------------------------------------------------------ |
| | 300 | r2109 | too | 2008-05-31 10:22:43 +0300 (Sat, 31 May 2008) | 1 line |
| | 301 | Changed paths: |
| | 302 | M /main/projects/m2vmp2cut/src/mp2cutpoints.c |
| | 303 | |
| | 304 | --scan option done, not used yet. |
| | 305 | ------------------------------------------------------------------------ |
| | 306 | r2108 | too | 2008-05-28 22:12:26 +0300 (Wed, 28 May 2008) | 1 line |
| | 307 | Changed 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 | ------------------------------------------------------------------------ |
| | 314 | r2107 | too | 2008-05-28 13:01:55 +0300 (Wed, 28 May 2008) | 1 line |
| | 315 | Changed paths: |
| | 316 | M /main/projects/m2vmp2cut/bin/m2vmp2cut.sh |
| | 317 | |
| | 318 | -c /dev/null |
| 4 | ------------------------------------------------------------------------ | 319 | ------------------------------------------------------------------------ |
| 5 | r2101 | too | 2008-05-26 22:57:03 +0300 (Mon, 26 May 2008) | 1 line | 320 | r2101 | too | 2008-05-26 22:57:03 +0300 (Mon, 26 May 2008) | 1 line |
| 6 | Changed paths: | 321 | Changed paths: |
| m2vmp2cut-0.65-dev/bin/m2vmp2cut.pl | | m2vmp2cut-0.67-dev/bin/m2vmp2cut.pl |
| 6 | # All rights reserved | 6 | # All rights reserved |
| 7 | # | 7 | # |
| 8 | # Created: Sun Sep 05 11:12:24 EEST 2004 too | 8 | # Created: Sun Sep 05 11:12:24 EEST 2004 too |
| 9 | # Last modified: Mon May 26 19:57:49 EEST 2008 too | 9 | # 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. |
| 12 | | 12 | |
| 55 | my $aonly = 0; | 55 | my $aonly = 0; |
| 56 | my $stop = 0; | 56 | my $stop = 0; |
| 57 | my $sync = 0; | 57 | my $sync = 0; |
| 58 | my $test = 0; | 58 | my $test = -1; |
| 59 | my $last = 0; | 59 | my $last = 0; |
| 60 | my $evbr = 0; | 60 | my $evbr = 0; |
| 61 | my $requant = 0.0; | 61 | my $requant = 0.0; |
| 62 | my $mplexopts = '-M -f 8'; | 62 | my $mplexopts = '-M -f 8'; |
| 63 | | 63 | |
| | 64 | my $dir = undef; |
| 64 | while (defined $ARGV[0] && $ARGV[0] =~ /^--/) | 65 | while (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/); |
| 86 | | 88 | |
| 87 | $nomux = 1 if ($aonly); | 89 | $nomux = 1 if ($aonly); |
| 88 | | 90 | |
| | 91 | unless (defined $dir) { |
| 89 | showdoc 1, 'Usage' if (@ARGV < 1); | 92 | showdoc 1, 'Usage' if (@ARGV < 1); |
| 90 | | | |
| 91 | die "$ARGV[0]: not a directory.\n", unless -d $ARGV[0]; | | |
| 92 | | | |
| 93 | my $dir = shift @ARGV; | 93 | $dir = shift @ARGV; |
| | 94 | } |
| | 95 | |
| | 96 | die "$dir: not a directory.\n", unless -d $dir; |
| 94 | | 97 | |
| 95 | # XXX add parsing of -v, -a, -s, -c, -i... | 98 | # XXX add parsing of -v, -a, -s, -c, -i... |
| 96 | # symlinks... | 99 | # symlinks... |
| 99 | my $sfile = 0; # "$dir/subtitles..."; | 102 | my $sfile = 0; # "$dir/subtitles..."; |
| 100 | my $cfile = "$dir/cutpoints"; | 103 | my $cfile = "$dir/cutpoints"; |
| 101 | my $ifile = "$dir/video.index"; | 104 | my $ifile = "$dir/video.index"; |
| | 105 | my $jfile = "$dir/audio.scan"; |
| 102 | my $range = 0; | 106 | my $range = 0; |
| 103 | my $workdir = "m2vmp2cut-work"; | 107 | my $workdir = "m2vmp2cut-work"; |
| 104 | | 108 | |
| 112 | | 116 | |
| 113 | # XXX some cmdline error handling... | 117 | # XXX some cmdline error handling... |
| 114 | | 118 | |
| 115 | foreach ($vfile, $afile, $sfile, $cfile, $ifile) { | 119 | foreach ($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 |
| | 125 | print("Creating $ifile...\n"), system $m2vscan, $vfile, $ifile |
| | 126 | unless -r $ifile; |
| | 127 | print("Creating $jfile...\n"), system $mp2cutpoints, '--scan', $afile, $jfile |
| | 128 | unless -r $jfile; |
| 118 | | 129 | |
| 119 | if ($range) { | 130 | if ($range) { |
| 120 | $_ = $range; | 131 | $_ = $range; |
| 144 | $framelist = "@tlist"; | 155 | $framelist = "@tlist"; |
| 145 | } | 156 | } |
| 146 | | 157 | |
| 147 | if ($test) | 158 | if ($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); } | | |
| 151 | | 161 | |
| 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 | } |
| 161 | | 176 | |
| 162 | my @ranges; | 177 | my @ranges; |
| 227 | | 242 | |
| 228 | seek(I, 0, 0) || die "Seek failed: $!.\n"; | 243 | seek(I, 0, 0) || die "Seek failed: $!.\n"; |
| 229 | | 244 | |
| | 245 | my $estimate; |
| | 246 | if ($test < 0) { |
| 230 | my ($vsize, $asize) = ((stat $vfile)[7], (stat $afile)[7]); | 247 | my ($vsize, $asize) = ((stat $vfile)[7], (stat $afile)[7]); |
| 231 | my $estimate = int(($vsize + $asize) * $frames / $allframes * 1.033); | 248 | $estimate = int(($vsize + $asize) * $frames / $allframes * 1.033); |
| 232 | undef $vsize; undef $asize; | 249 | } |
| 233 | | 250 | |
| 234 | open SH, '>', "$wd/do.sh" || die "Can not create job script: $!\n"; | 251 | open SH, '>', "$wd/do.sh" || die "Can not create job script: $!\n"; |
| 235 | chmod 0755, "$wd/do.sh"; | 252 | chmod 0755, "$wd/do.sh"; |
| 273 | mainpid=\$\$ | 290 | mainpid=\$\$ |
| 274 | trap 'kill -USR1 0' 0 | 291 | trap 'kill -USR1 0' 0 |
| 275 | | 292 | |
| 276 | '$m2vmp2cut_sh' vermatch 4 \\\n\t|| die 'Tool version mismatch. Rerun!'; | 293 | '$m2vmp2cut_sh' vermatch 5 \\\n\t|| die 'Tool version mismatch. Rerun!'; |
| 277 | | 294 | |
| 278 | EOF | 295 | EOF |
| 279 | | 296 | |
| 299 | } else { | 316 | } else { |
| 300 | $evbr = $avbr; | 317 | $evbr = $avbr; |
| 301 | } | 318 | } |
| | 319 | my $met = ''; |
| | 320 | $met = "-4 4 -2 4", $evbr = int($evbr * 1.2) if ($test >= 0); |
| 302 | | 321 | |
| 303 | print STDERR "video frames: @ranges.\n"; | 322 | print STDERR "video frames: @ranges.\n"; |
| 304 | print SH "# video frames: @ranges\n"; | 323 | print 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" |
| 361 | | 380 | |
| 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>&1 | 384 | >> "$wd/mpeg2enc.out" 2>&1 |
| 366 | | 385 | |
| 387 | | 406 | |
| 388 | $copystart = $nextgoppos; | 407 | $copystart = $nextgoppos; |
| 389 | | 408 | |
| | 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 | } |
| 392 | | 416 | |
| 393 | sub endcut($) | 417 | sub 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); |
| 417 | | 441 | |
| 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 | |
| | 452 | die "aonly and test mutually exclusive\n" if ($aonly && $test >= 0); |
| 427 | | 453 | |
| 428 | my @timecodes; | 454 | my @timecodes; |
| 429 | $" = ' '; | 455 | $" = ' '; |
| 431 | foreach (@ranges) | 457 | foreach (@ranges) |
| 432 | { | 458 | { |
| 433 | ($s, $e) = split('-'); | 459 | ($s, $e) = split('-'); |
| | 460 | my ($ts, $te); |
| 434 | | 461 | |
| 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); |
| 441 | | 469 | |
| 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)); |
| 448 | | 481 | |
| 449 | push @timecodes, "$ts-$te"; | 482 | push @timecodes, "$ts-$te"; |
| 450 | } | 483 | } |
| 451 | | 484 | |
| 452 | print SH "# ++++++++ $prevgopff $currgopff ($e) $nextgopff ", | 485 | print SH "# ++++++++ $prevgopff $currgopff ($e) $nextgopff ", |
| 453 | "-- $prevgoppos $currgoppos $nextgoppos\n"; | 486 | "-- $prevgoppos $currgoppos $nextgoppos\n"; |
| | 487 | if ($test >= 0 && ($test++ & 1)) { |
| | 488 | $frames -= $encframes; |
| | 489 | } |
| | 490 | else { |
| 454 | enccmdblk("@m2v2yuvrange", $encframes, $enccopystart) unless ($aonly); | 491 | enccmdblk("@m2v2yuvrange", $encframes, $enccopystart) unless ($aonly); |
| | 492 | } |
| 455 | undef $s; undef $e; | 493 | undef $s; undef $e; |
| 456 | $" = ','; | 494 | $" = ','; |
| 457 | | 495 | |
| 483 | | 521 | |
| 484 | undef $maxasrval; undef $maxasr; undef $counter; | 522 | undef $maxasrval; undef $maxasr; undef $counter; |
| 485 | | 523 | |
| 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); |
| 489 | | 526 | |
| 494 | } | 531 | } |
| 495 | | 532 | |
| 496 | print STDERR "Scanning audio for cut points.\n"; | 533 | print STDERR "Scanning audio for cut points.\n"; |
| 497 | my $audiocutfilepos | 534 | my $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; |
| 500 | | 537 | |
| 501 | chomp($audiocutfilepos); | 538 | chomp($audiocutfilepos); |
| 526 | ls -lrtac "$wd" | 563 | ls -lrtac "$wd" |
| 527 | date | 564 | date |
| 528 | EOF | 565 | EOF |
| 529 | if (! $nomux) { | 566 | if (! $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 | } |
| 563 | | 600 | |
| 564 | print "\nDone, Result (if any) in '$wd/", | 601 | print "\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 reserved | 7 | # All rights reserved |
| 8 | # | 8 | # |
| 9 | # Created: Wed Apr 23 21:40:17 EEST 2008 too | 9 | # Created: Wed Apr 23 21:40:17 EEST 2008 too |
| 10 | # Last modified: Mon May 19 18:37:22 EEST 2008 too | 10 | # Last modified: Wed Jul 23 12:03:42 EEST 2008 too |
| 11 | | 11 | |
| 12 | e2 () { echo "$@" >&2; } | 12 | e2 () { echo "$@" >&2; } |
| 13 | die () { e2 "$@"; exit 1; } | 13 | die () { e2 "$@"; exit 1; } |
| 14 | usage () { e2; e2 Usage: $0 $cc "$@"; die; } | 14 | usage () { e2; e2 Usage: m2vmp2cut '(file|dir)' $cc "$@"; die; } |
| 15 | needvar () { [ x"$1" = x ] && { shift 1; "$@"; }; } | 15 | needvar () { [ x"$1" = x ] && { shift 1; "$@"; }; } |
| | 16 | |
| | 17 | x () { echo + "$@"; "$@"; } |
| 16 | | 18 | |
| 17 | M2VMP2CUT_CMD_PATH=`cd \`dirname "$0"\`; pwd` | 19 | M2VMP2CUT_CMD_PATH=`cd \`dirname "$0"\`; pwd` |
| 18 | case $M2VMP2CUT_CMD_PATH in | 20 | case $M2VMP2CUT_CMD_PATH in |
| 21 | | 23 | |
| 22 | #echo $M2VMP2CUT_CMD_PATH | 24 | #echo $M2VMP2CUT_CMD_PATH |
| 23 | | 25 | |
| | 26 | # no interactive behaviour in batch mode... |
| | 27 | case $1 in --batch) batch=1; shift ;; *) batch= ;; esac |
| | 28 | |
| | 29 | case $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 ;; |
| | 44 | esac |
| | 45 | |
| 24 | # do not show this in command list | 46 | # do not show this in command list |
| 25 | cmd_vermatch () | 47 | cmd_vermatch () |
| 26 | { | 48 | { |
| 27 | case $1 in 4) exit 0;; *) exit 1 ;; esac | 49 | case $1 in 5) exit 0;; *) exit 1 ;; esac |
| 28 | } | 50 | } |
| 29 | | 51 | |
| 30 | cmd_lvev6frames () # Legacy m2vmp2cut support; dig cutpoints from ~/.lve/* file | 52 | cmd_lvev6frames () # Legacy m2vmp2cut support; dig cutpoints from ~/.lve/* file |
| 32 | $M2VMP2CUT_CMD_PATH/lvev6frames.pl | 54 | $M2VMP2CUT_CMD_PATH/lvev6frames.pl |
| 33 | } | 55 | } |
| 34 | | 56 | |
| 35 | chkvideoindex() | 57 | chkindexes () |
| 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 | } |
| 40 | | 65 | |
| 41 | cmd_demux () # Demux mpeg2 file with ProjectX for further editing... | 66 | cmd_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 exist | 72 | e2 Symbolic link \'$M2VMP2CUT_CMD_PATH/ProjectX.jar\' does not exist |
| 47 | die Please provide link and try again | 73 | die Please provide link and try again |
| 51 | e2 ProjectX jar file \'$pjxjar\' does not exist | 77 | e2 ProjectX jar file \'$pjxjar\' does not exist |
| 52 | die Fix this or it\'s symbolic link reference \'$M2VMP2CUT_CMD_PATH/ProjectX.j | 78 | 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.m2v | 85 | ln -s *.m2v video.m2v |
| 63 | ln -s *.mp2 audio.mp2 | 86 | ln -s *.mp2 audio.mp2 |
| 64 | chkvideoindex . | 87 | chkindexes . |
| 65 | } | 88 | } |
| 66 | | 89 | |
| 67 | cmd_cut () # Cut video with a graphical tool | 90 | cmd_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"` in | 96 | 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 | } |
| 77 | | 99 | |
| 78 | cmd_run () # Run m2vmp2cut.pl to do the work... | 100 | cmd_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 | |
| | 105 | cmd_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 | |
| | 112 | cmd_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 | } |
| 82 | | 119 | |
| 83 | cmd_help () # Help of all or some of the commands above | 120 | cmd_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 | } |
| 87 | | 125 | |
| | 126 | cmd_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 | # --- |
| 89 | | 148 | |
| 90 | [ x"$1" = x ] && { | 149 | [ x"$1" = x ] && { |
| 91 | echo | 150 | echo |
| 92 | echo Usage: $0 ' <command> [args]' | 151 | echo Usage: m2vmp2cut '[-batch] (file|dir) <command> [args]' |
| 93 | echo | 152 | echo |
| 94 | echo $0 commands available: | 153 | echo m2vmp2cut commands available: |
| 95 | echo | 154 | echo |
| 96 | sed -n '/^cmd_/ { s/cmd_/ /; s/ () [ -#]*/ / | 155 | sed -n '/^cmd_/ { s/cmd_/ /; s/ () [ -#]*/ / |
| 97 | s/\(.\{15\}\) */\1/p; }' $0 | 156 | s/\(.\{15\}\) */\1/p; }' $0 |
| 127 | | 186 | |
| 128 | # fixme: move these to separate doc file (w/ locale extension) | 187 | # fixme: move these to separate doc file (w/ locale extension) |
| 129 | | 188 | |
| 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-generated | 191 | #h lvev6frames: Old versions of m2vmp2cut supported using lve-generated |
| 135 | #h lvev6frames: these old edits can be used with this m2vmp2cut version | 193 | #h lvev6frames: these old edits can be used with this m2vmp2cut version |
| 136 | #h lvev6frames: | 194 | #h lvev6frames: |
| 137 | | 195 | |
| 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 streams | 198 | #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: |
| 147 | | 204 | |
| | 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: | | |
| 154 | | 218 | |
| 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 frontend | 222 | #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 reserved | 7 | # All rights reserved |
| 8 | # | 8 | # |
| 9 | # Created: Tue Apr 22 19:10:35 EEST 2008 too | 9 | # Created: Tue Apr 22 19:10:35 EEST 2008 too |
| 10 | # Last modified: Wed May 14 17:35:56 EEST 2008 too | 10 | # Last modified: Fri Jul 25 15:26:08 EEST 2008 too |
| 11 | | 11 | |
| 12 | eae () { echo; echo Press ENTER to close this window '' | tr -d \\012; read _; exit $1; | 12 | eae () { echo; echo Press ENTER to close this window '' | tr -d \\012 |
| } | | |
| | 13 | read _; exit $1; } |
| 13 | | 14 | |
| 14 | die () { exec 1>&2; echo; echo "$@"; eae 1; } | 15 | die () { exec 1>&2; echo; echo "$@"; eae 1; } |
| 15 | | 16 | |
| 18 | | 19 | |
| 19 | numtune () { | 20 | numtune () { |
| 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 | |
| | 36 | m2vcut_warp_exit () |
| | 37 | { |
| | 38 | "`dirname $0`"/warpxpointer -name M2vCut c c |
| | 39 | exit 0 |
| 21 | } | 40 | } |
| 22 | | 41 | |
| 23 | exec_xterm () { | 42 | exec_xterm () { |
| 31 | | 50 | |
| 32 | case $1 in | 51 | case $1 in |
| 33 | m2vcut_help) | 52 | m2vcut_help) |
| 34 | exec_xterm 76x28-0+0 'M2vCut Help' m2vcut_outputhelp | 53 | 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 ;; esac | 110 | *) 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`";; esac | 111 | 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-test | 149 | dd="$vd"/m2vcut-test |
| 93 | while :; do | 150 | test -d "$dd" && rm -rf "$dd" |
| 94 | mplayer "$vd"/m2vcut-test/out.mpg | 151 | mkdir "$dd" || die Can not create directory "$dd" |
| 95 | echo try again ? | 152 | set -x |
| 96 | read line | 153 | "$cwd"/fileparts $byterange "$vd"/audio.mp2 > "$dd"/audio.mp2 |
| 97 | case $line in *yes*) ;; *) exit 0 ;; esac | 154 | mplayer -vo null -vc null -ao pcm:file="$dd"/audio.wav "$dd"/audio.mp2 |
| 98 | done | 155 | "$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/src/m2vcut-gui.c | | m2vmp2cut-0.67-dev/src/m2vcut-gui.c |
| 21 | * All rights reserved | 21 | * All rights reserved |
| 22 | * | 22 | * |
| 23 | * Created: Sun Dec 30 14:17:12 EET 2007 too | 23 | * Created: Sun Dec 30 14:17:12 EET 2007 too |
| 24 | * Last modified: Mon May 26 20:54:27 EEST 2008 too | 24 | * Last modified: Fri Jun 13 21:49:32 EEST 2008 too |
| 25 | */ | 25 | */ |
| 26 | | 26 | |
| 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 | } |
| 1606 | | 1606 | |
| | 1607 | void goto_percent(int pc) |
| | 1608 | { |
| | 1609 | int n = G.lastindex * pc / 100; |
| | 1610 | show_iframe(n); |
| | 1611 | } |
| | 1612 | |
| 1607 | void goto_cutpoint(int cutpoint) | 1613 | void 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; |
| 1671 | | 1677 | |
| 1672 | if (dist1 < dist2) | 1678 | if (dist1 < dist2) |
| 1673 | sprintf(framearg1, "%d", fn0); | 1679 | sprintf(framearg2, "%d", fn0); |
| 1674 | else | 1680 | else |
| 1675 | sprintf(framearg2, "%d", fn1); | 1681 | sprintf(framearg1, "%d", fn1); |
| 1676 | } | 1682 | } |
| 1677 | | 1683 | |
| 1678 | static void test_cutpoint(void) | 1684 | static void test_cutpoint(void) |
| 1760 | | 1766 | |
| 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 | |
| | 1771 | static 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 | } |
| 1764 | | 1779 | |
| 1765 | gboolean main_window_delete_event(void * w, void * e, void * d) | 1780 | gboolean 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; |
| 1843 | | 1859 | |
| | 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; |
| 1845 | | 1864 | |
| | 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 -x | 3 | 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 | #endif | 5 | #endif |
| 6 | /* | 6 | /* |
| 7 | * mp2cutpoints.c $ | 7 | * mp2cutpoints.c $ |
| 12 | * All rights reserved | 12 | * All rights reserved |
| 13 | * | 13 | * |
| 14 | * Created: Thu Oct 20 19:32:21 EEST 2005 too | 14 | * Created: Thu Oct 20 19:32:21 EEST 2005 too |
| 15 | * Last modified: Mon May 05 17:12:00 EEST 2008 too | 15 | * 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 | */ |
| 19 | | 19 | |
| | 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> |
| 24 | | 27 | |
| 25 | #define DBGS 0 | 28 | #define DBGS 0 |
| 26 | #include "x.h" | 29 | #include "x.h" |
| 27 | #include "bufwrite.h" | 30 | #include "bufwrite.h" |
| 28 | | 31 | |
| | 32 | /* ((1 << (8 * sizeof (v) - 1)) - 1) */ |
| | 33 | #define MAXINTVAL(v) ((((1 << (8 * sizeof (v) - 2)) - 1) << 1) | 1) |
| | 34 | |
| 29 | | 35 | |
| 30 | /* hand-converted python->c, with few modifications */ | 36 | /* hand-converted python->c, with few modifications */ |
| 31 | | | |
| 32 | | | |
| 33 | /* mpeg1 layer 2 bitrate indexes */ | | |
| 34 | static 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 */ | | |
| 39 | static const int siarr[] = { 44100, 48000, 32000 }; | | |
| 40 | | | |
| 41 | | 37 | |
| 42 | typedef struct _simplefilebuf simplefilebuf; | 38 | typedef struct _simplefilebuf simplefilebuf; |
| 43 | struct _simplefilebuf | 39 | struct _simplefilebuf |
| 57 | self->offset = self->len = self->gone = 0; | 53 | self->offset = self->len = self->gone = 0; |
| 58 | } | 54 | } |
| 59 | | 55 | |
| | 56 | void 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 | |
| 60 | bool simplefilebuf_fillbuf(simplefilebuf * self, unsigned int rest) | 64 | bool 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 */ |
| | 138 | static 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 */ |
| | 143 | static 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 | |
| | 150 | typedef unsigned char u8; |
| | 151 | typedef 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 | |
| | 166 | static 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 | |
| | 207 | static 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 | } |
| 132 | | 215 | |
| 133 | static int tcode2ms(char * val) | 216 | static int tcode2ms(char * val) |
| 166 | } | 249 | } |
| 167 | } | 250 | } |
| 168 | | 251 | |
| 169 | int main(int argc, char ** argv) | 252 | static 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 | |
| | 260 | static 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 | |
| | 268 | void 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 | |
| | 342 | void 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; |
| 176 | | 349 | |
| 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; |
| 185 | | 357 | |
| | 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; |
| 188 | | 364 | |
| 189 | if (argc < 4) | 365 | memset(&m2i, 0, sizeof m2i); |
| 190 | xerrf("argc < 4\n"); | 366 | m2i.sfb = &sfb; |
| 191 | | 367 | |
| 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]); | | |
| 216 | | 402 | |
| | 403 | ofd = wopen(ofile); |
| 217 | simplefilebuf_init(&sfb, argv[2]); | 404 | simplefilebuf_init(&sfb, ifile); |
| 218 | | 405 | |
| 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; |
| 276 | | 509 | |
| 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; |
| 321 | | 517 | |
| 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 | } |
| 326 | | 522 | |
| 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 | else | 526 | else |
| 342 | simplefilebuf_unusedbytes(&sfb, 3); | 527 | simplefilebuf_unusedbytes(&sfb, 3); |
| 343 | } | 528 | } |
| | 529 | } |
| | 530 | |
| | 531 | int 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 | } |
| 346 | | 542 | |