Mercurial > mplayer.hg
annotate TOOLS/encode2mpeglight @ 17507:c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
author | nicodvb |
---|---|
date | Sun, 29 Jan 2006 20:42:34 +0000 |
parents | |
children | 36589811e5d0 |
rev | line source |
---|---|
17507
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1 #!/bin/bash |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
2 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
3 # Version: 0.5.5 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
4 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
5 # Licence: GPL |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
6 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
7 # 2004-05-22 Giacomo Comes <encode2mpeg at users.sourceforge.net> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
8 # 2006-01-14 <encode2mpeg at katamail.com> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
9 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
10 # Pourpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
11 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
12 # This program is free software; you can redistribute it and/or modify |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
13 # it under the terms of the GNU General Public License as published by |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
14 # the Free Software Foundation; either version 2 of the License. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
15 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
16 # This program is distributed in the hope that it will be useful, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
19 # GNU General Public License for more details. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
20 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
21 # You should have received a copy of the GNU General Public License |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
22 # along with this program; if not, write to the Free Software |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
24 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
25 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
26 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
27 # encode2mpeglight is a program that can create VCD/SVCD/DVD mpegs |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
28 # and eventually extract VobSub subtitles from a DVD using only |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
29 # MEncoder/MPlayer. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
30 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
31 # encode2mpeglight is a stripped release of encode2mpeg and therefore the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
32 # code is redundant in several places, with many variables defined and |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
33 # used for no apparent reason. This cannot be avoided easily. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
34 # A command line like: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
35 # encode2mpeglight <encode2mpeglight options> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
36 # will produce almost the same results as: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
37 # encode2mpeg -mpeg -mpegonly <encode2mpeglight options> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
38 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
39 # If you need more features like: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
40 # - two or more audio streams, chapters, subtitles, menu |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
41 # - creation, burn and verification of the disk image |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
42 # - creation of MPEG-4 avi and subtitles for a hardware player |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
43 # and more, consider to use the full release (http://encode2mpeg.sf.net) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
44 # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
45 # encode2mpeglight is mainly tested with the stable release of MPlayer, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
46 # I try to make it work with CVS too, but due to the "instable" nature of |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
47 # CVS, bugs may suddenly appear. If you find any, please report it to me. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
48 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
49 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
50 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
51 #### start |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
52 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
53 export LC_ALL=POSIX |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
54 set -B +f |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
55 shopt -u xpg_echo nullglob |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
56 PROGNAME=${0##*/} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
57 PROGFILE=$(type -p "$0") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
58 VERSION=$(awk '$2=="Version:"{print $3;exit}' <"$PROGFILE") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
59 BROWSER= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
60 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
61 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
62 #### some functions |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
63 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
64 OptionsText () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
65 echo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
66 echo "Arguments enclosed in [ ] are optional" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
67 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
68 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
69 ModeText () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
70 echo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
71 echo -e "$PROGNAME defaults to encode2mpeg's Mpeg Mode, the others mode are not" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
72 echo -e "available" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
73 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
74 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
75 usage () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
76 echo -e "Usage: $PROGNAME options source\nOptions:" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
77 sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/,/#-/!d;s/)$//;s/) *#/ /;s/#-/# /;s/ *#L.$//;s/#//;p' "$PROGFILE" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
78 ModeText |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
79 OptionsText |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
80 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
81 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
82 shortusage () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
83 echo -e "\n$PROGNAME v. $VERSION Copyright (C) 2004-2006 Giacomo Comes\n" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
84 echo "This is free software; see the source for copying conditions. There is NO" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
85 echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE," |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
86 echo "to the extent permitted by law." |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
87 echo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
88 echo "Usage: $PROGNAME options source" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
89 echo "Options:" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
90 sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/!d;s/)$//;s/) *#/ /;s/ *#L.$//;p' "$PROGFILE" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
91 OptionsText |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
92 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
93 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
94 mp_identify () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
95 mplayer -identify -vo null -ao null -nocache "$@" -frames 0 2>/dev/null |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
96 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
97 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
98 get_aspect () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
99 mplayer -vo null -ao null -nocache -frames 4 "$@" 2>/dev/null | sed '/^Movie-Aspect is/!d;s/.*Movie-Aspect is //;s/:.*//' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
100 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
101 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
102 mlistopt () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
103 mplayer -list-options 2>&1 | awk '$1=="Name"{m=1}{if(m&&$1!="Name"&&$1!=""&&$1!="Total:")print "\""$1"\""}' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
104 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
105 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
106 pre_log () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
107 echo "$1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
108 WARN="$WARN${WARN:+\n}$1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
109 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
110 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
111 isarg () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
112 if [[ ${2:0:1} = - || ! $2 || $2 = help ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
113 [[ ${2:0:1} = - ]] && echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
114 [[ ! $2 ]] && echo "**ERROR: [$PROGNAME] invalid null argument for option '$1'" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
115 "$PROGFILE" -norc -l | sed '/^ '$1'$/,/^ -/!d' | sed '$d' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
116 "$PROGFILE" -norc -l | sed '/^ '$1'[ |]/,/^ -/!d' | sed '$d' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
117 exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
118 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
119 if [[ $2 = doc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
120 show_html ${3:+$3.html} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
121 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
122 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
123 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
124 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
125 pr_date () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
126 echo "[$(date '+%Y-%m-%d %H:%M:%S')]" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
127 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
128 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
129 pr_time () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
130 date '+%j %H %M %S' | awk '{print $1*86400+$2*3600+$3*60+$4}' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
131 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
132 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
133 get_abr () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
134 local INFO ABR |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
135 INFO=$(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
136 ABR=$(echo "$INFO" | grep '^ID_AUDIO_BITRATE' | cut -f2 -d=) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
137 case $(echo "$INFO" | grep '^ID_AUDIO_CODEC' | cut -f2 -d=) in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
138 dvdpcm) abr=$((abr+ABR/1024)) ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
139 *) abr=$((abr+ABR/1000)) ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
140 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
141 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
142 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
143 get_pwd () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
144 pushd &>/dev/null "$1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
145 echo "$PWD/$2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
146 popd &>/dev/null |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
147 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
148 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
149 show_html () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
150 local i LIST HTML PREFIX OPTION INSTDOCDIR SRCDOCDIR |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
151 INSTDOCDIR=${PROGFILE%/bin/$PROGNAME}/share/doc/encode2mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
152 SRCDOCDIR=${PROGFILE%/$PROGNAME}/doc |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
153 if [[ -f $INSTDOCDIR/encode2mpeg.html ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
154 HTML=$(get_pwd "$INSTDOCDIR" encode2mpeg.html) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
155 elif [[ -f $SRCDOCDIR/encode2mpeg.html ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
156 HTML=$(get_pwd "$SRCDOCDIR" encode2mpeg.html) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
157 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
158 HTML="http://encode2mpeg.sourceforge.net" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
159 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
160 if [[ -f $INSTDOCDIR/html/$1 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
161 HTML=$(get_pwd "$INSTDOCDIR/html" $1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
162 elif [[ -f $SRCDOCDIR/html/$1 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
163 HTML=$(get_pwd "$SRCDOCDIR/html" $1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
164 elif [[ $1 && ! -d $INSTDOCDIR/html && ! -d $SRCDOCDIR/html ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
165 HTML="http://encode2mpeg.sourceforge.net/html/$1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
166 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
167 LIST=(mozilla firefox) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
168 [[ ${HTML:0:1} = / ]] && PREFIX=file:// || PREFIX= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
169 for ((i=0;i<${#LIST[*]};i++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
170 type ${LIST[i]} &>/dev/null && ${LIST[i]} -remote 'openURL('"$PREFIX$HTML"',new-tab)' 2>/dev/null && return |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
171 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
172 LIST=(mozilla firefox opera konqueror epiphany galeon) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
173 if [[ $BROWSER ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
174 type "$BROWSER" &>/dev/null && LIST=("$BROWSER") || echo "++ WARN: default browser '$BROWSER' not found, using builtin browser list" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
175 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
176 for ((i=0;i<${#LIST[*]};i++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
177 if type "${LIST[i]}" &>/dev/null; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
178 case ${LIST[i]} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
179 opera) OPTION=--newpage ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
180 epiphany|galeon) OPTION=--new-tab ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
181 *) OPTION= ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
182 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
183 "${LIST[i]}" $OPTION "$HTML" & |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
184 return |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
185 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
186 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
187 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
188 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
189 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
190 #### variables initialization |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
191 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
192 abr=;asr=;vbr=;vfr=;videonorm=;frameformat=;output=;audioformat=;mp1=;mp2=;mp3=;ac3=;dts=;lpcm=;normalize=;volume=;multiaudio=;mpegchannels=;quiet=;resume=;blank=;encode=;ofps=;mono=;usesbr=;sbr=;clear=;keep=;frames=;avisplit=;channels=;vcustom=;acustom=;cpu=;interlaced=;mpegaspect=;intra_matrix=;inter_matrix=;fixavi=;mpeg=;crop=;audioid=;dvdaudiolang=;bframes=;firstchap=;lastchap=;dvdtrack=;addchapter=;cdi=;mpegfixaspect=;nowait=;vf=;frameres=;trick=;autocrop=;ac=;afm=;cache=;removecache=;turbo=;dvddev=;srate=;endpos=;fourcc=;menu=;menubg=;dvdtitle=;rotate=;menuvtsbg=;autosync=;telecine=;AFMT=;telesrc=;vcodec=;vrfyumnt=;burniso=;verify=;fixasync=;removedir=;MPGRES=;GOP=;TXTSUBOPT=;usespeed=;testmca=;chconf=;noodml=;pictsrc=;slideaudio=;audioonly=;norc= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
193 unset encsid encsdx encsla addsub addsdx addsla savecache txtsub txtsubopts |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
194 zoom=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
195 scale=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
196 fast=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
197 MAXSTEP=6 # burn is the default |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
198 step=$MAXSTEP |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
199 split=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
200 vbitrate=16000 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
201 mpegmbr=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
202 overscan=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
203 iter=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
204 bakiter=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
205 hispeed=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
206 BGTITLE=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
207 TANIM=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
208 TFMT=png |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
209 TMODE=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
210 TKFRM=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
211 TSECS=5 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
212 TPART=4 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
213 TPARTSEC=15 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
214 TFONTSIZE=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
215 TFONTBG=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
216 TLINES=2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
217 TCPR=2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
218 MENUERR=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
219 DVDPLAY=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
220 MENUOS=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
221 TSETB=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
222 DVDFS=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
223 VTSMBG=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
224 menufix=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
225 cdburndevice=0,0,0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
226 dvdburndevice=/dev/cdrecorder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
227 fsize=;fint=;ffrac=;fpre=;audiosize=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
228 ASPECT=(1 1 4/3 16/9 2.21) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
229 CH6LIST=(l r ls rs c lfe) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
230 TOOL= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
231 MPEG2ENCOPT=;YUVSCALEROPT=;YUVDENOISE=;MPLEXOPT=;VCDIMAGEROPT=;DVDAUTHOROPT=;CDRDAOOPT=;GROWISOFSOPT=;MUSICINOPT= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
232 unset MPLAYEROPT MPLEXSTREAM MENCODEROPT |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
233 LPCMPAR= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
234 SUBLANG= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
235 unset SUBTEXT AUDIOTEXT CHAPTERTEXT TITLESET EXTWAV PROFILE MSRC |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
236 unset CLEAN |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
237 DEBUG=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
238 LAVC= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
239 WARN= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
240 LOG= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
241 MAXFIX=20 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
242 timelen=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
243 ocrsub=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
244 slidefps=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
245 default_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
246 default_intra=$default_intra,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
247 default_inter=16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
248 default_inter=$default_inter,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
249 hires_intra=8,16,18,20,24,25,26,30,16,16,20,23,25,26,30,30,18,20,22,24,26,28,29,31,20,21,23,24,26,28,31,31,21,23,24 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
250 hires_intra=$hires_intra,25,28,30,30,33,23,24,25,28,30,30,33,36,24,25,26,29,29,31,34,38,25,26,28,29,31,34,38,42 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
251 hires_inter=$default_inter |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
252 kvcd_intra=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
253 kvcd_intra=$kvcd_intra,36,39,38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
254 kvcd_inter=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
255 kvcd_inter=$kvcd_inter,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
256 tmpgenc_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
257 tmpgenc_intra=$tmpgenc_intra,29,32,35,40,48,26,27,29,32,35,40,40,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
258 tmpgenc_inter=16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
259 tmpgenc_inter=$tmpgenc_inter,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
260 TXTSUBDEF=( languageId nolang delay 0 font arial.ttf size 28 bottom-margin 30 characterset ISO8859-1 movie-height-reduction 0 fps default ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
261 AVISUBDEF=( format SubViewer name-extension null fileformat unix version-number off delay 0 fps default suffix default ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
262 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
263 #### encode2mpeglight defauls |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
264 mpeg=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
265 encode=7:2:2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
266 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
267 (($#)) || ! shortusage || exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
268 CMD=( "$@" ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
269 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
270 #### options array |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
271 MOPT=( $(mlistopt | grep -v -e : -e '*') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
272 $(mlistopt | sed -n '/:/s/:.*/"/p' | uniq) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
273 $(mplayer -vfhelp 2>&1 | awk '/vf-/{printf("\"%s\"\n",$1)}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
274 $(mplayer -vophelp 2>&1 | awk '/vop-/{printf("\"%s\"\n",$1)}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
275 $(mplayer -zrhelp 2>/dev/null | awk '$1~/^-zr/{printf("\"%s\"\n",substr($1,2))}') ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
276 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
277 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
278 #### check rc file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
279 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
280 if [[ -s ~/.encode2mpegrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
281 for ((i=0;i<${#CMD[*]};i++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
282 [[ ${CMD[i]} = -norc ]] && norc=1 && break |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
283 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
284 if [[ ! $norc ]] && ! awk '{if($1~"^#")exit 1}' ~/.encode2mpegrc ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
285 WARN="$WARN${WARN:+\n}++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
286 norc=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
287 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
288 [[ ! $norc ]] && set -- $(<~/.encode2mpegrc) "$@" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
289 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
290 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
291 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
292 #### arguments parsing |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
293 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
294 while (($#)) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
295 #### PARSING |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
296 case $1 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
297 -h|-help) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
298 #-list the available options |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
299 [[ $2 = doc || $2 = help ]] && isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
300 shortusage |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
301 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
302 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
303 -l|-longhelp) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
304 #-print this help page |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
305 [[ $2 = doc || $2 = help ]] && isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
306 usage |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
307 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
308 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
309 -doc|-documentation) #[[<browser>:][<html page>]] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
310 #-show the html documentation |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
311 [[ $2 = doc || $2 = help ]] && isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
312 [[ ${2%:*} != $2 ]] && BROWSER=${2%:*} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
313 show_html ${2#*:} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
314 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
315 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
316 -noshowlog) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
317 #-do not show the log file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
318 [[ $2 = doc || $2 = help ]] && isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
319 quiet=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
320 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
321 -o|-output) #<filename> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
322 #-filename of the output stream |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
323 echo "$2" | grep -q '/' && [[ ! -d ${2%/*} ]] && echo "**ERROR: [$PROGNAME] directory ${2%/*} argument of '$1' not found" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
324 output=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
325 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
326 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
327 -a) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
328 # aspect ratio VCD SVCD DVD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
329 # 1 - 1:1 x * x x = mpeg2enc and mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
330 # 2 - 4:3 x x x * = mencoder only |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
331 # 3 - 16:9 x x x |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
332 #- 4 - 2.21:1 * x |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
333 MPEG2ENCOPT="$MPEG2ENCOPT -a $2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
334 [[ $2 -eq 0 ]] && MPEG2ENCOPT="${MPEG2ENCOPT% ${2}} 1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
335 mpegaspect=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
336 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
337 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
338 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
339 -mpegfixaspect) #[pad|crop] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
340 # force the aspect ratio of the source video to match the one |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
341 # specified with -a; this can be done padding the video with |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
342 #-black lines or cropping the video; the default is padding |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
343 [[ $2 = doc || $2 = help ]] && isarg $1 $2 aspect |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
344 mpegfixaspect=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
345 if [[ $2 = pad || $2 = crop ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
346 [[ $2 = crop ]] && mpegfixaspect=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
347 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
348 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
349 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
350 -rotate) #<0-3> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
351 # rotate the source video by 90 degrees; set -mpegfixaspect; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
352 # 0 rotate clockwise and flip, 1 rotate clockwise |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
353 #-2 rotate counterclockwise, 3 rotate counterclockwise and flip |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
354 rotate=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
355 echo "$2" | grep -q '^[0-3]$' && rotate=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
356 isarg $1 "$2" aspect |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
357 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
358 : ${mpegfixaspect:=0} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
359 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
360 -overscan) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
361 # shrink the video of n% and surround it with black borders, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
362 # n can be 1-99, using 10 should make visible on a TV the full video |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
363 # image; if n is negative, the result is a magnification of the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
364 # central part of the image; n>0 set -mpegfixaspect pad, n<0 set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
365 #--mpegfixaspect crop; in Avi Mode n can only be positive |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
366 echo "$2" | grep -qE '^-?[0-9]?[0-9]$' && overscan=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
367 [[ ${2:0:1} = - ]] && mpegfixaspect=1 || mpegfixaspect=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
368 isarg $1 "${2#-}" $( ((step==1)) && echo Avi || echo aspect) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
369 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
370 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
371 -abr) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
372 #-audio bit rate of the VCD/SVCD/DVD [MP2:224,MP3:128,AC3:448] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
373 if [[ $2 = list ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
374 sed '/^check_abr/,/case/!d;/'"$audioformat"':/!d;/[^0-9]'"$asr"'/!d;s/[^)]*)//;s/ */ /g;s/^/'"$audioformat $asr"'/' "$PROGFILE" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
375 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
376 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
377 abr=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
378 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
379 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
380 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
381 -asr) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
382 #-audio sample rate of the VCD/SVCD/DVD [MP2/MP3:44100,AC3:48000] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
383 asr=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
384 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
385 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
386 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
387 -vbr) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
388 #-video bit rate of the VCD/SVCD/DVD [VCD:1152,SVCD:2500,DVD:7500] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
389 vbr=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
390 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
391 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
392 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
393 -vfr) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
394 # video frame rate of the output stream |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
395 # [NTSC/VCD:4,NTSC/SVCD-DVD:1,PAL:3,AVI:2] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
396 # 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
397 # 2 - 24.0 (NATIVE FILM) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
398 # 3 - 25.0 (PAL/SECAM VIDEO / converted FILM) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
399 # 4 - 30000.0/1001.0 (NTSC VIDEO) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
400 # 5 - 30.0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
401 # 6 - 50.0 (PAL FIELD RATE) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
402 # 7 - 60000.0/1001.0 (NTSC FIELD RATE) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
403 #- 8 - 60.0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
404 vfr=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
405 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
406 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
407 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
408 -n|-video-norm) #<n|p|s> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
409 #-set the video norm of the VCD/SVCD/DVD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
410 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
411 n|N|ntsc|NTSC) videonorm=n ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
412 p|P|pal|PAL) videonorm=p ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
413 s|S|secam|SECAM) videonorm=s ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
414 doc|help) isarg $1 $2 direct ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
415 *) echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'" ; "$PROGFILE" -norc $1 help ; exit 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
416 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
417 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
418 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
419 -p|-pulldown|-telecine) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
420 # set a flag in the output stream of the SVCD/DVD that tell the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
421 # decoder to play the movie as NTSC video using "3:2 pull-down" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
422 #-instead of "-vfr 4" use "-vfr 1 -p" (smaller output stream) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
423 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
424 telecine=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
425 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
426 -res) #<1-7> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
427 # force one of the following video resolutios: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
428 # PAL NTSC |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
429 # 1 352x288 352x240 (VCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
430 # 2 352x576 352x480 (CVD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
431 # 3 480x576 480x480 (SVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
432 # 4 528x576 528x480 (KVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
433 # 5 544x576 544x480 (KVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
434 # 6 704x576 704x480 (DVB) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
435 #- 7 720x576 720x480 (DVD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
436 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
437 echo "$2" | grep -q '^[1-7]$' && MPGRES=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
438 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
439 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
440 -gop) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
441 # set the number of pictures per GOP; the default value is the one |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
442 #-required by the standard |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
443 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
444 GOP=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
445 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
446 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
447 -kvcd) #<1-4> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
448 # generate KVCD (www.kvcd.net) compliant frames on output; the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
449 # following resolutions are possible: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
450 # PAL NTSC GOP |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
451 # 1 528x576 528x480 24 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
452 # 2 528x576 528x480 def |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
453 # 3 544x576 544x480 24 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
454 #- 4 544x576 544x480 def |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
455 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
456 a=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
457 echo "$2" | grep -q '^[1-4]$' && a=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
458 shift 2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
459 set -- " " -qmatrix kvcd -res $((3+(a+1)/2)) $([[ $a == [13] ]] && echo "-gop 24") "$@" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
460 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
461 -vcd) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
462 #-generate VCD compliant frames on output (default) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
463 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
464 frameformat=VCD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
465 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
466 -svcd) #[1-2] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
467 # generate SVCD compliant frames on output; the following resolutions |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
468 # are possible: PAL NTSC |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
469 # 1 480x576 480x480 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
470 # 2 352x288 352x240 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
471 #-default is 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
472 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
473 frameformat=SVCD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
474 frameres=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
475 echo "$2" | grep -q '^[1-2]$' && frameres=$2 && shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
476 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
477 -svcdht) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
478 # enable the VCD header trick; this trick could allow to play SVCD on |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
479 # DVD player that does not support SVCD. For more details see: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
480 #-http://www.videohelp.com/svcd |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
481 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
482 trick=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
483 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
484 -dvd) #[1-5] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
485 # generate DVD compliant frames on output; the following resolutions |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
486 # are possible: PAL NTSC |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
487 # 1 720x576 720x480 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
488 # 2 704x576 704x480 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
489 # 3 480x576 480x480 (non standard DVD-SVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
490 # 4 352x576 352x480 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
491 # 5 352x288 352x240 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
492 #-default is 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
493 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
494 frameformat=DVD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
495 frameres=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
496 echo "$2" | grep -q '^[1-5]$' && frameres=$2 && shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
497 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
498 -vcodec) #<mpeg1|mpeg2|mpeg4> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
499 #-force the selected video codec [VCD:mpeg1,SVCD-DVD:mpeg2,AVI:mpeg4] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
500 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
501 [[ $2 == mpeg[124] ]] && vcodec=$2 && [[ ${vcodec:4:1} == [12] ]] && vcodec=${vcodec}video |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
502 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
503 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
504 -qmatrix) #<kvcd|tmpgenc|default|hi-res> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
505 # mpeg2enc custom quantization matrices: kvcd produce a smaller |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
506 #-output stream, hi-res is good for hi-quality source material |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
507 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
508 kvcd|tmpgenc|default|hi-res) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
509 MPEG2ENCOPT="$MPEG2ENCOPT -K $2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
510 intra_matrix=$(eval echo \$${2/-}_intra) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
511 inter_matrix=$(eval echo \$${2/-}_inter) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
512 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
513 *) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
514 MPEG2ENCOPT="$MPEG2ENCOPT -K default" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
515 intra_matrix= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
516 inter_matrix= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
517 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
518 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
519 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
520 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
521 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
522 -mpeg1vbr) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
523 # produce a VCD/MPEG-1 variable bit rate stream, the output stream |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
524 # is smaller and a complete movie could fit in one VCD; check if |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
525 #-your hardware player support variable bit rate VCD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
526 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
527 MPEG2ENCOPT="$MPEG2ENCOPT -q 8" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
528 LAVC=":vrc_buf_size=327" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
529 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
530 -mpegmbr) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
531 # set the maximum video bit rate; the default is the value of vbr; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
532 #-a value of 0 remove the limit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
533 mpegmbr=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
534 [[ $2 -eq 0 ]] && mpegmbr= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
535 isarg $1 "$2" mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
536 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
537 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
538 -mpegchannels) #<1-6> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
539 # number of channels of the mpeg audio stream, 1-6 for ac3 and lpcm; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
540 # 1-2 for mp1, mp2 and mp3; 3-6 for mp2 Multichannel Audio; for the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
541 #-avi audio stream use MPlayer's option -channels |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
542 mpegchannels=2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
543 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
544 echo "$2" | grep -q '^[1-6]$' && mpegchannels=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
545 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
546 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
547 -normalize) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
548 #-normalize to the audio stream(s) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
549 [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $encode ]] && echo Avi || echo direct) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
550 normalize=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
551 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
552 -volume) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
553 # change amplitude of the audio stream; less than 1.0 decreases, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
554 #-greater than 1.0 increases (float) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
555 volume=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
556 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
557 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
558 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
559 -noscale) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
560 # encode2mpeg automatically scales the video according to the mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
561 # profile chosen, this option disable this feature; used mainly |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
562 #-for debug purpose |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
563 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
564 scale= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
565 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
566 -monochrome) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
567 #-create B/W video or avoid color artifacts in B/W source streams |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
568 [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
569 YUVSCALEROPT="$YUVSCALEROPT -O MONOCHROME" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
570 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
571 -split) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
572 #-split the resulting mpeg stream in <n> MB chunks. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
573 split=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
574 isarg $1 "$2" direct |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
575 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
577 -encode) #<n:m:i[,b]> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
578 # the parameter n:m:i selects the audio codec, video codec options |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
579 # and number of pass for mencoder, possible values are: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
580 # n m i |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
581 # 0 copy 0 copy 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
582 # 1 pcm 1 libavcodec/mpeg 2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
583 # 2 mp3lame/fast 2 as 1 + mbd=2 3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
584 # 3 mp3lame/standard 3 as 1 + compression opts |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
585 # 4 libavcodec/mp2 4 as 1 + quality opts |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
586 # 5 libavcodec/mp3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
587 # 6 libavcodec/ac3 for m=[2-4] and i>1 turbo is on |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
588 # 7 toolame/mp2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
589 #- with n=[3-7] b specify the audio bit rate |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
590 encode=5:3:2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
591 echo "$2" | grep -qE '^[0-7]:[0-4]:[1-9](,[0-9]+)?$' && encode=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
592 isarg $1 "$2" $([[ $mpeg ]] && echo mpeg || echo Avi) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
593 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
594 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
595 -telecinesrc) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
596 # if you use -encode n:0:i in Mpeg Mode, encode2mpeg needs to know |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
597 # if the source NTSC mpeg is telecined, otherwise the stream copy may |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
598 # not work properly; normally encode2mpeg is able to detect telecined |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
599 # sources, but, if the source mpeg is mixed, part not telecined and |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
600 # part telecined, encode2mpeg may fail to detect it. In such case, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
601 #-you can use this option to specify a telecined source. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
602 [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
603 telesrc=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
604 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
605 -turbo) #<0-1> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
606 # disable (0) or force (1) turbo mode for the first pass of N pass |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
607 #-encoding (N>1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
608 echo "$2" | grep -q '^[0-1]$' && turbo=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
609 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
610 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
611 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
612 -hispeed) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
613 # increase the encoding speed of 25-50% (with -encode n:1:1); the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
614 # output video stream will be bigger and can have poor quality; this |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
615 # option is mainly intented for testing, but it can be used if you |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
616 #-want to create more quickly an mpeg4/avi or a DVD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
617 [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
618 hispeed=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
619 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
620 -bframes) #<0-4> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
621 # specify the number of B frames; if -encode is n:3:i the default 2, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
622 #-otherwise the default is no B frames; for VCD the default is 2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
623 echo "$2" | grep -q '^[0-4]$' && bframes=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
624 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
625 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
626 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
627 -vcustom) #<libavcodec options> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
628 # specify a custom set of video options for libavcodec, use with |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
629 #--encode n:1:i |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
630 vcustom=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
631 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
632 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
633 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
634 -acustom) #<mp3lame options> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
635 #-specify a custom set of lame options, use with -encode 2:m:i |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
636 acustom=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
637 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
638 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
639 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
640 -encsid) #<sid0,sid1,...> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
641 #-dump the DVD vobsub, sid is the number you give the -sid option |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
642 # of MPlayer. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
643 encsid=( ${2//,/ } ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
644 isarg $1 "$2" subtitle |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
645 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
646 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
647 -encsdx) #<sid0,sid1,...> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
648 # if you dump subtitle 2 and 4 and you want them to have id 0 and 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
649 #-use -encsid 2,4 -encsdx 0,1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
650 encsdx=( ${2//,/ } ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
651 isarg $1 "$2" subtitle |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
652 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
653 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
654 -encsla) #<sla0,sla1,...> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
655 #-see doc/html/subtitle.html |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
656 encsla=( ${2//,/ } ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
657 isarg $1 "$2" subtitle |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
658 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
659 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
660 -usespeed) # |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
661 # do frame rate conversion changing the playback speed; this option |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
662 # can be used if you are converting from NTSC 24fps, with or without |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
663 # telecine, to PAL 25fps and viceversa; during normal frame rate |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
664 # conversion, frames are skipped or duplicated as needed; with this |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
665 #-option all the frames are encoded |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
666 [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
667 usespeed=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
668 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
669 -usesbr) #[1-6|>100] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
670 # use the suggested video bitrate to set the output stream size |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
671 # 1 - for 650MB CD 4 - for 2 x 650MB CD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
672 # 2 - for 700MB CD (default) 5 - for 2 x 700MB CD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
673 # 3 - for 800MB CD 6 - for 2 x 800MB CD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
674 # n where n > 100 will set the file size to n MB |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
675 #-with -multiaudio you must to set the streamsize in MB |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
676 usesbr=2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
677 SBR=(650 700 800 "2 x 650" "2 x 700" "2 x 800") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
678 echo "$2" | grep -q '^[1-6]$' && usesbr=$2 && shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
679 echo "$2" | grep -qE '^[1-9][0-9]{2,}$' && usesbr=$2 && shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
680 [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
681 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
682 -cpu) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
683 #-number of cpu to use, default all the cpu present in the system |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
684 cpu=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
685 echo "$2" | grep -q '^[1-8]$' && cpu=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
686 isarg $1 "$2" Avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
687 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
688 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
689 -interlaced) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
690 #-turn on optimization for interlaced source video. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
691 [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $mpeg ]] && echo mpeg || echo Avi) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
692 interlaced=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
693 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
694 -slidefps) #<n> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
695 # fps to use when creating video from pictures, default is 1; if |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
696 # there is a audio file associated with a picture, the duration of |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
697 #-the audio file is used |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
698 slidefps=$(awk -v a=$2 'BEGIN{printf("%.3f",1/a)}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
699 isarg $1 "$2" images |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
700 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
701 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
702 -slideaudio) #<audio file> |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
703 # use the content of <audio file> as audio stream when creating video |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
704 #-from pictures; it works correctly only if used with mf://singlepic |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
705 slideaudio=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
706 if [[ ! -f $2 && $2 != /dev/null ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
707 [[ $2 = doc || $2 = help || ! $2 ]] && isarg $1 "$2" images || ! echo "**ERROR: [$PROGNAME] slide audio file '$2' not found" || exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
708 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
709 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
710 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
711 -norc) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
712 #-do not use the settings in the file $HOME/.encode2mpegrc |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
713 [[ $2 = doc || $2 = help ]] && isarg $1 $2 rc |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
714 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
715 -debug) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
716 # make a more verbose log file and creates a debug file; if you are |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
717 # submitting a bug report, use this option and compress and send the |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
718 #-log file and the debug file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
719 [[ $2 = doc || $2 = help ]] && isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
720 ((DEBUG)) && DEBUG=2 || DEBUG=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
721 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
722 (-frames) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
723 frames=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
724 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
725 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
726 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
727 (-channels) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
728 channels=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
729 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
730 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
731 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
732 (-srate) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
733 MPLAYEROPT=( "${MPLAYEROPT[@]}" -srate $2 -af-adv force=1 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
734 srate=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
735 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
736 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
737 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
738 (-endpos) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
739 endpos=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
740 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
741 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
742 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
743 (-hr-edl-seek) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
744 MENCODEROPT=( "${MENCODEROPT[@]}" $1 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
745 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
746 (-vf) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
747 vf="-vf $2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
748 MPLAYEROPT=( "${MPLAYEROPT[@]}" $vf ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
749 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
750 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
751 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
752 (-dvd-device) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
753 dvddev=$2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
754 isarg $1 $2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
755 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
756 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
757 (mf://*) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
758 MPLAYEROPT[${#MPLAYEROPT[*]}]=$1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
759 pictsrc=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
760 a=$IFS |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
761 IFS=, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
762 PICTSRC=( ${1#mf://} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
763 IFS=$a |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
764 srate=48000 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
765 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
766 (-mpeg|-mpegonly|-nosplit) ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
767 *) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
768 if [[ ! $TOOL ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
769 [[ ${1:0:1} = - ]] && ! echo "${MOPT[@]}" | grep -q "\"${1#-}\"" && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
770 echo -e "Unknown option $1\nIf this is a valid MPlayer option add '-toolopts mplayer' in front of it" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
771 MPLAYEROPT[${#MPLAYEROPT[*]}]=$1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
772 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
773 case $TOOL in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
774 *) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
775 MPLAYEROPT[${#MPLAYEROPT[*]}]=$1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
776 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
777 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
778 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
779 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
780 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
781 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
782 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
783 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
784 [[ -s ~/.encode2mpegrc && ! $norc ]] && pre_log " INFO: [$PROGNAME] using .encode2mpegrc settings: '$(<~/.encode2mpegrc)'" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
785 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
786 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
787 #### redirect stdout and stderr to the debug file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
788 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
789 if ((DEBUG)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
790 exec 3>&1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
791 rm -f "$output".debug.fifo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
792 mkfifo "$output".debug.fifo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
793 tee "$output".debug <"$output".debug.fifo >&3 & |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
794 PROCTEE=$! |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
795 exec &>"$output".debug.fifo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
796 ((DEBUG==2)) && set -x |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
797 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
798 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
799 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
800 #### ERROR if some options conflict is detected part 1/2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
801 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
802 #### mplayer/mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
803 for a in mplayer mencoder ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
804 type $a &>/dev/null || ! echo "**ERROR: [$PROGNAME] $a missing, install $(echo ${a:0:2} | tr '[:lower:]' '[:upper:]')${a:2}" || exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
805 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
806 #### output stream name check |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
807 [[ ! $output ]] && echo "**ERROR: [$PROGNAME] name of the output stream missing (-o name)" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
808 #### unspecified video norm |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
809 [[ ! $videonorm && step -gt 1 && ! ( $mpeg && ${encode%,*} == ?:0:? && ! $menu ) ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
810 echo "**ERROR: [$PROGNAME] you must specify a video norm (-n n|p|s)" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
811 #### pictsrc |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
812 if [[ $pictsrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
813 [[ $slideaudio != /dev/null && ${encode%,*} == 0:?:? && $mpeg ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
814 echo "**ERROR: [$PROGNAME] -encode 0:m:i is not compatible with mf:// in Mpeg Mode" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
815 [[ $audioonly ]] && echo "**ERROR: [$PROGNAME] -audioonly does not work with mf://" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
816 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
817 #### -encode 1:m:i is not allowed |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
818 [[ ${encode%,*} == 1:?:? ]] && echo "**ERROR: [$PROGNAME] do not use -encode 1:m:i" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
819 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
820 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
821 #### WARN if some options conflict is detected |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
822 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
823 #### missing toolame support |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
824 if [[ ${encode%,*} == 7:?:? ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
825 if ! mencoder -oac help 2>/dev/null | grep -q toolame ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
826 encode=4:${encode#?:} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
827 pre_log "++ WARN: [$PROGNAME] missing toolame support in mencoder, setting -encode $encode" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
828 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
829 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
830 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
831 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
832 #### set default values for unspecified parameters |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
833 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
834 if [[ ! $multiaudio ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
835 audiostream=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
836 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
837 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
838 if [[ $encode ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
839 case ${encode%%:*} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
840 0) [[ ! $pictsrc ]] && |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
841 AFMT=acopy ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
842 2|3|5) AFMT=mp3 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
843 4|7) AFMT=mp2 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
844 6) AFMT=ac3 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
845 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
846 [[ $AFMT ]] && eval : ${audioformat:-\${$AFMT:=copy}} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
847 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
848 : ${frameformat:=VCD} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
849 : ${audioformat:=${AFMT:-mp2}} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
850 : ${mp1:=mp2enc} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
851 ((${mpegchannels:-2}>2)) && : ${mp2:=musicin} || : ${mp2:=mp2enc} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
852 : ${mp3:=lame} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
853 : ${ac3:=mencoder} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
854 : ${dts:=copy} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
855 case $audioformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
856 mp1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
857 case ${mpegchannels:-2} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
858 1) : ${abr:=192} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
859 2) : ${abr:=384} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
860 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
861 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
862 mp2) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
863 case ${mpegchannels:-2} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
864 1) : ${abr:=112} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
865 2) : ${abr:=224} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
866 [3-6]) : ${abr:=384} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
867 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
868 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
869 mp3) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
870 case ${mpegchannels:-2} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
871 1) : ${abr:=64} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
872 2) : ${abr:=128} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
873 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
874 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
875 ac3) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
876 case ${mpegchannels:-2} in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
877 1) : ${abr:=96} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
878 2) : ${abr:=192} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
879 3) : ${abr:=320} ;; # to verify |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
880 4) : ${abr:=384} ;; # to verify |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
881 5) : ${abr:=448} ;; # to verify |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
882 6) : ${abr:=448} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
883 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
884 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
885 #### mplex fails with asr != 48000 for lpcm |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
886 lpcm) : ${asr:=48000} ${abr:=$((asr*16*${mpegchannels:-2}/1024))} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
887 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
888 if [[ ${encode%,*} == 0:?:? && ${!audioformat} = copy ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
889 abr=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
890 if [[ ! $multiaudio ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
891 get_abr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
892 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
893 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
894 [[ $mpeg && ${encode%,*} == ?:0:? ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
895 vbr=$(($(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_VIDEO_BITRATE' | cut -f2 -d=)/1000)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
896 case $frameformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
897 DVD) : ${asr:=48000} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
898 *) : ${asr:=44100} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
899 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
900 case $videonorm in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
901 p|s) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
902 : ${vfr:=3} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
903 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
904 n) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
905 #FIXME remove the encode 3 check once the mpeg muxer is fixed |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
906 [[ $frameformat != VCD && ! $vfr && $hispeed -eq 0 && ! $testmca && ${encode%,*} != ?:3:? ]] && vfr=1 && telecine=1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
907 : ${vfr:=4} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
908 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
909 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
910 [[ $encode ]] && : ${vfr:=2} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
911 if [[ ! $ofps ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
912 case $vfr in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
913 1) ofps=24000/1001 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
914 2) ofps=24 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
915 3) ofps=25 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
916 4) ofps=30000/1001 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
917 5) ofps=30 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
918 6) ofps=50 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
919 7) ofps=60000/1001 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
920 8) ofps=60 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
921 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
922 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
923 if [[ $split && $split -eq 0 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
924 [[ $mpeg ]] && split= || split=800 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
925 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
926 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
927 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
928 #### get MPlayer version |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
929 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
930 mver=$(mencoder 2>/dev/null | awk '$1=="MEncoder"{print $2;exit}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
931 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
932 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
933 #### threads check |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
934 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
935 if [[ ! $cpu && -f /proc/cpuinfo ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
936 cpu=$(grep -c ^processor /proc/cpuinfo) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
937 #### if there are 2 logical cpu but 1 physical (hyperthreading) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
938 #### use only one thread. With kernel 2.4.x it is more efficent. |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
939 ((cpu==2)) && [[ $(uname -r | cut -f 1-2 -d .) = 2.4 ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
940 [[ $(grep ^siblings /proc/cpuinfo | uniq | wc -l) -eq 1 ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
941 cpu=$((cpu/$(grep ^siblings /proc/cpuinfo | uniq | awk 'END{print $NF}'))) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
942 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
943 ((cpu<2)) && cpu= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
944 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
945 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
946 #### -ao pcm arguments |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
947 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
948 PCM=(pcm:waveheader:file="$output".wav) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
949 PCMTMP=(pcm:waveheader:file="$output".tmp) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
950 PCMNOWYUV=(pcm:nowaveheader:file=/dev/fd/4) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
951 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
952 [[ $dvddev ]] && MPLAYEROPT=( "${MPLAYEROPT[@]}" -dvd-device "$dvddev" ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
953 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
954 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
955 #### mplayer/mencoder/mjpegtools options |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
956 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
957 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
958 #### mencoder output suffix |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
959 if [[ $encode ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
960 [[ $mpeg ]] && SUF=mpeg || SUF=avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
961 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
962 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
963 #### MPLAYERINFO is used for [info] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
964 MPLAYERINFO=( "${MPLAYEROPT[@]}" ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
965 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
966 #### mf:// case |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
967 if [[ $pictsrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
968 if [[ $slideaudio && $slideaudio != /dev/null ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
969 [[ $(mp_identify "$slideaudio" | grep ID_AUDIO_RATE | cut -f2 -d=) != $asr ]] && SRATE="-srate $asr -af-adv force=1" || SRATE= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
970 CLEAN[${#CLEAN[*]}]="$output".wav |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
971 mplayer "$slideaudio" $SRATE -vo null -vc dummy -ao "${PCM[@]}" $VOL $ac $afm ${mpegchannels:+-channels $mpegchannels -af channels=$mpegchannels} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
972 MPLAYEROPT=( "${MPLAYEROPT[@]}" -fps 1/$(mp_identify "$output".wav | sed -n '/^ID_LENGTH=/s/.*=//p') -audiofile "$output".wav ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
973 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
974 if [[ $slideaudio == /dev/null ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
975 MPLAYEROPT=( "${MPLAYEROPT[@]}" -fps $slidefps ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
976 encode=0:${encode#?:} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
977 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
978 MPLAYEROPT=( "${MPLAYEROPT[@]}" -fps $slidefps -audiofile /dev/zero -audio-demuxer 20 -rawaudio format=0x1:rate=48000 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
979 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
980 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
981 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
982 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
983 #### MENCODERARG is used for mencoding, vobsub dumping |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
984 MENCODERARG=( "${MPLAYEROPT[@]}" ${frames:+-frames $frames} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
985 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
986 MENCODERARG=( "${MENCODERARG[@]}" "${MENCODEROPT[@]}" ${endpos:+-endpos $endpos} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
987 if [[ $mpeg && $mpegchannels ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
988 MENCODERARG=( "${MENCODERARG[@]}" -channels $mpegchannels ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
989 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
990 MENCODERARG=( "${MENCODERARG[@]}" ${channels:+-channels $channels} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
991 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
992 #### if video copy then no ofps |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
993 [[ ${encode%,*} != ?:0:? ]] && MENCODERARG=( "${MENCODERARG[@]}" ${ofps:+-ofps $ofps} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
994 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
995 YUVSCALEROPT="-v 1 -n $videonorm ${scale:+-O $frameformat} $YUVSCALEROPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
996 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
997 MPEG2ENCOPT="${cpu:+-M $cpu }-v 1 -S ${split:-50000} -n $videonorm -F $vfr -s -r 16 ${telecine:+-p} $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
998 case $vfr in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
999 1|2) MPEG2ENCOPT="-g 6 -G ${GOP:-12} $MPEG2ENCOPT" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1000 3|6) MPEG2ENCOPT="-g 6 -G ${GOP:-15} $MPEG2ENCOPT" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1001 4|5|7|8) MPEG2ENCOPT="-g 9 -G ${GOP:-18} $MPEG2ENCOPT" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1002 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1003 [[ $frameformat = VCD ]] && MPEG2ENCOPT="-R 2 $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1004 echo "$MPEG2ENCOPT" | grep -q -e '-K hi-res' && YUVSCALEROPT="-M BICUBIC $YUVSCALEROPT" && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1005 MPEG2ENCOPT="-4 1 -2 1 $MPEG2ENCOPT" || MPEG2ENCOPT="-4 2 -2 1 $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1006 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1007 case $frameformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1008 VCD) MPGRES=${MPGRES:-1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1009 SVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1010 case $frameres in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1011 1) MPGRES=${MPGRES:-3} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1012 2) MPGRES=${MPGRES:-1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1013 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1014 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1015 DVD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1016 case $frameres in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1017 1) MPGRES=${MPGRES:-7} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1018 2) MPGRES=${MPGRES:-6} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1019 3) MPGRES=${MPGRES:-3} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1020 4) MPGRES=${MPGRES:-2} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1021 5) MPGRES=${MPGRES:-1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1022 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1023 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1024 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1025 case $MPGRES in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1026 1) H_RES=352 ; [[ $videonorm = n ]] && V_RES=240 || V_RES=288 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1027 2) H_RES=352 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1028 3) H_RES=480 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1029 4) H_RES=528 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1030 5) H_RES=544 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1031 6) H_RES=704 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1032 7) H_RES=720 ; [[ $videonorm = n ]] && V_RES=480 || V_RES=576 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1033 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1034 case $frameformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1035 VCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1036 : ${vbr:=1152} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1037 MPEG2ENCOPT="-f 2 -b $vbr -V 46 -B $(((abr*audiostream*101875-vbr*2819+3980000)/100000)) $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1038 MPLEXOPT="-f 2 -V -b 46 -r $(((abr*audiostream+vbr)*4)) $MPLEXOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1039 VCDIMAGEROPT="-t vcd2 $VCDIMAGEROPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1040 H_STILL=704 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1041 [[ $videonorm = n ]] && V_STILL=480 || V_STILL=576 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1042 ((MPGRES!=1)) && YUVSCALEROPT="-O SIZE_${H_RES}x${V_RES} ${YUVSCALEROPT/ -O $frameformat}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1043 MAXBR=1394 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1044 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1045 SVCD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1046 : ${vbr:=2500} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1047 MPEG2ENCOPT="-f 5 -b $vbr -V 113 -B $(((abr*audiostream*101250+vbr*742+1665400)/100000)) $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1048 MPLEXOPT="-V -b 113 -r $(((abr*audiostream+vbr)*4)) $MPLEXOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1049 if [[ $trick ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1050 MPLEXOPT="-f 2 $MPLEXOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1051 VCDIMAGEROPT="-t vcd2 $VCDIMAGEROPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1052 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1053 MPLEXOPT="-f 5 $MPLEXOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1054 VCDIMAGEROPT="-t svcd $VCDIMAGEROPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1055 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1056 H_STILL=704 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1057 [[ $videonorm = n ]] && V_STILL=480 || V_STILL=576 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1058 ((frameres>1||MPGRES!=3)) && YUVSCALEROPT="-O SIZE_${H_RES}x${V_RES} ${YUVSCALEROPT/ -O $frameformat}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1059 MAXBR=2778 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1060 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1061 DVD) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1062 : ${vbr:=7500} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1063 MPEG2ENCOPT="-f 8 -b $vbr -V 230 -B $(((abr*audiostream*101250+vbr*742+1665400)/100000)) $MPEG2ENCOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1064 MPLEXOPT="-f 8 -V -b 230 -r $(((abr*audiostream+vbr)*4)) $MPLEXOPT" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1065 H_STILL=720 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1066 [[ $videonorm = n ]] && V_STILL=480 || V_STILL=576 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1067 ((frameres>1||MPGRES!=7)) && YUVSCALEROPT="-O SIZE_${H_RES}x${V_RES} ${YUVSCALEROPT/ -O $frameformat}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1068 MAXBR=10080 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1069 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1070 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1071 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1072 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1073 #### mencoder audio/video/pass options |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1074 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1075 if [[ $encode ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1076 OPTIONS="-noskiplimit -sws $((hispeed?1:7))" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1077 if [[ $mpeg ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1078 # mencoder can put in the mpeg container: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1079 # video: mpeg1, mpeg2, mpeg4 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1080 # audio: mp1, mp2, mp3, ac3, aac (not yet: lpcm, dts) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1081 [[ ${encode%,*} != ?:0:? ]] && : ${mpegaspect:=2} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1082 #MUX="-mpegopts ${mpegaspect:+vaspect=${ASPECT[mpegaspect]}:}:vbitrate=${vbr}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1083 MUX="-mpegopts ${mpegaspect:+vaspect=${ASPECT[mpegaspect]}:}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1084 MUX2="${telecine:+:telecine}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1085 case $frameformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1086 VCD) MUX="${MUX}format=xvcd" LAVC="vcodec=${vcodec:-mpeg1video}${LAVC:-:vrc_buf_size=327:vrc_minrate=${vbr}:vrc_maxrate=${vbr}}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1087 SVCD) if [[ $trick ]]; then MUX="${MUX}format=xvcd" ; else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1088 MUX="${MUX}format=xsvcd" ; fi ; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1089 LAVC="vcodec=${vcodec:-mpeg2video}:vrc_buf_size=917" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1090 DVD) MUX="${MUX}format=dvd" LAVC="vcodec=${vcodec:-mpeg2video}:vrc_buf_size=1835" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1091 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1092 case $vfr in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1093 1|2) LAVC="$LAVC:keyint=$((hispeed?1:${GOP:-12}))" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1094 3|6) LAVC="$LAVC:keyint=$((hispeed?1:${GOP:-15}))" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1095 4|5|7|8) LAVC="$LAVC:keyint=$((hispeed?1:${GOP:-18}))" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1096 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1097 [[ $frameformat = VCD && ! $bframes ]] && LAVC="$LAVC:vmax_b_frames=2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1098 [[ $mpegmbr ]] && [[ $mpegmbr -lt $vbr ]] && mpegmbr=$vbr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1099 #### -a 1 really means aspect undefined (do not scale), not aspect 1:1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1100 [[ $vcodec != mpeg4 || $mpegaspect != 1 ]] && LAVC="${LAVC}:aspect=${ASPECT[mpegaspect]}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1101 LAVC="${LAVC}${mpegmbr:+:vrc_maxrate=$mpegmbr}${inter_matrix:+:inter_matrix=${inter_matrix}}${intra_matrix:+:intra_matrix=${intra_matrix}}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1102 OF="-of mpeg" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1103 NOSKIP=-noskip |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1104 vbitrate=$vbr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1105 if [[ ${encode%,*} != ?:0:? ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1106 for ((a=0;a<${#MENCODERARG[*]};a++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1107 while [[ ${MENCODERARG[a]} = -vf ]]; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1108 unset MENCODERARG[a] MENCODERARG[a+1] |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1109 MENCODERARG=( "${MENCODERARG[@]}" ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1110 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1111 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1112 MENCODERARG=( "${MENCODERARG[@]}" ${vf:--vf }${vf:+,}${scale:+scale=${H_RES}:${V_RES}${interlaced:+:1},}harddup ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1113 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1114 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1115 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1116 BASIC="$LAVC:vbitrate=${vbitrate}${cpu:+:threads=$cpu}${bframes:+:vmax_b_frames=$bframes}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1117 ((hispeed)) && BASIC="$BASIC:vme=0" || BASIC="$BASIC:psnr" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1118 [[ $mpeg && $frameformat = VCD ]] || BASIC="$BASIC${interlaced:+:ildct:ilme}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1119 echo "$YUVSCALEROPT" | grep -q -e '-O MONOCHROME' && BASIC="$BASIC:gray" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1120 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1121 HQ="${BASIC}:mbd=2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1122 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1123 if [[ $mpeg ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1124 #### dia=6 could be added |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1125 BESTSIZE="${BASIC}:mbd=1:loop:mv0:vlelim=-4:vcelim=7:trell:precmp=1:cmp=1:subcmp=1" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1126 [[ ! $bframes ]] && BESTSIZE="$BESTSIZE:vmax_b_frames=2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1127 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1128 #### last_pred=1-2 could be added |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1129 BESTQUALITY="${BASIC}:mbd=2:mv0:precmp=6:cmp=6:subcmp=6" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1130 [[ $vbitrate -ge 3500 && $frameformat != VCD && $vcodec != mpeg1video ]] && BESTQUALITY="$BESTQUALITY:dc=9" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1131 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1132 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1133 case $encode in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1134 0:?:?|0:?:?,*) AUDIOPASS="-oac copy" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1135 1:?:?|1:?:?,*) AUDIOPASS="-oac pcm" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1136 2:?:?|2:?:?,*) AUDIOPASS="-oac mp3lame -lameopts ${acustom:-fast}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1137 3:?:?) AUDIOPASS="-oac mp3lame -lameopts preset=standard" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1138 4:?:?) AUDIOPASS="-oac lavc -lavcopts acodec=mp2:abitrate=$abr" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1139 5:?:?) AUDIOPASS="-oac lavc -lavcopts acodec=mp3:abitrate=$abr" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1140 6:?:?) AUDIOPASS="-oac lavc -lavcopts acodec=ac3:abitrate=$abr" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1141 7:?:?) AUDIOPASS="-oac toolame -toolameopts br=$abr" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1142 3:?:?,*) AUDIOPASS="-oac mp3lame -lameopts preset=${encode#*,}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1143 4:?:?,*) AUDIOPASS="-oac lavc -lavcopts acodec=mp2:abitrate=${encode#*,}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1144 5:?:?,*) AUDIOPASS="-oac lavc -lavcopts acodec=mp3:abitrate=${encode#*,}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1145 6:?:?,*) AUDIOPASS="-oac lavc -lavcopts acodec=ac3:abitrate=${encode#*,}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1146 7:?:?,*) AUDIOPASS="-oac toolame -toolameopts br=${encode#*,}" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1147 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1148 encode=${encode%,*} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1149 case $encode in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1150 ?:0:?) VIDEOPASS="$OF $MUX -ovc copy $NOSKIP" ; encode=${encode%%:*}:0:1 ; turbo=0 ;; # copy uses only one pass |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1151 ?:1:?) VIDEOPASS="$OF $MUX$MUX2 -ovc lavc -lavcopts ${BASIC}${vcustom:+:$vcustom}" ; : ${turbo:=0} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1152 ?:2:?) VIDEOPASS="$OF $MUX$MUX2 -ovc lavc -lavcopts ${HQ}" ; : ${turbo:=1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1153 ?:3:?) VIDEOPASS="$OF $MUX$MUX2 -ovc lavc -lavcopts ${BESTSIZE}" ; : ${turbo:=1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1154 ?:4:?) VIDEOPASS="$OF $MUX$MUX2 -ovc lavc -lavcopts ${BESTQUALITY}" ; : ${turbo:=1} ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1155 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1156 ((turbo)) && turbo=:turbo || turbo= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1157 PASS=${encode##*:} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1158 [[ $normalize && $encode != 0:?:? ]] && AUDIOPASS="-af volnorm $AUDIOPASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1159 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1160 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1161 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1162 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1163 #### more functions |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1164 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1165 status_bit () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1166 local a |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1167 case $1 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1168 avi) bit=0 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1169 mpv) bit=1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1170 mpa) bit=2 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1171 mpg) bit=3 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1172 img) bit=4 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1173 sub) bit=5 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1174 ach) bit=6 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1175 fno) bit=7 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1176 ch0) bit=8 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1177 sbm) bit=9 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1178 spl) bit=10 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1179 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1180 if [[ $2 = set ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1181 skip=$((skip|1<<bit)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1182 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1183 return $(((skip&1<<bit) && 1)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1184 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1185 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1186 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1187 file_size () { #fsize,fint,ffrac,fpre |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1188 local -a PRE=([1]=K M G T) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1189 local i=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1190 fsize=$(ls -l "$1" | awk '{print $5}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1191 fint=$fsize |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1192 ffrac=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1193 while ((fint>=1024)) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1194 ((fint/1024 < 1024)) && fint=$((fint+51)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1195 i=$((++i)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1196 ffrac=$((fint%1024)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1197 fint=$((fint/1024)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1198 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1199 ffrac=$((ffrac*10/1024)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1200 fpre=${PRE[i]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1201 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1202 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1203 show_file_info () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1204 file_size "$2" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1205 echo " $1: $2 is $fsize bytes, $fint.$ffrac ${fpre}B" >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1206 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1207 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1208 show_finalvideo_info () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1209 local codec TYPE i VIDEO OUT ASPECT |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1210 VIDEO="$(mplayer -nocache -frames 0 -vo null -nosound "$2" 2>/dev/null | grep "^VIDEO:")" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1211 if [[ ! $VIDEO ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1212 # mpegs with mpeg4 video do not show all the video informations in one line, |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1213 # assebmling the informations (kbps is missing): |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1214 OUT="$(mplayer -nocache -frames 1 -vo null -nosound -v "$2" 2>/dev/null)" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1215 if echo "$OUT" | grep -q '^\[V].*fourcc:0x10000004' ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1216 VIDEO="VIDEO: MPEG4 $(echo "$OUT" | awk '$1=="VO:"&&$2=="[null]"{print $3}')" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1217 ASPECT=$(echo "$OUT" | awk '$1=="Movie-Aspect"{print $3}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1218 case $ASPECT in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1219 undefined) VIDEO="$VIDEO (aspect 1)" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1220 1.33:1) VIDEO="$VIDEO (aspect 2)" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1221 1.78:1) VIDEO="$VIDEO (aspect 3)" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1222 2.21:1) VIDEO="$VIDEO (aspect 4)" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1223 *) VIDEO="$VIDEO (aspect $ASPECT)" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1224 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1225 VIDEO="$VIDEO $(echo "$OUT" | awk '$1=="[V]"{print $5}')" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1226 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1227 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1228 echo " $1: $VIDEO" >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1229 #### removed -vc dummy |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1230 for i in $(mplayer -vo null -ao null -nocache -frames 1 -v "$2" 2>/dev/null | awk '/==> Found audio str/{print $NF}' | sort -n) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1231 echo -n " $1: AUDIO[$i]: " >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1232 codec=$(mplayer -ac mp3, -nocache -frames 0 -v -ao null -vo null "$2" -aid $i 2>/dev/null | sed '/Selected audio codec:/!d;s/[^(]*(//;s/).*//;s/.* //') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1233 mplayer -ac mp3, -nocache -frames 0 -v -ao null -vo null "$2" -aid $i 2>/dev/null | sed '/^Opening audio decode/,/^AUDIO:/!d;s/\r//g' | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1234 grep -e '^AC3:' -e '^MPEG' -e '^AUDIO:' | sed 's/AUDIO/'"$codec"'/;q' >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1235 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1236 TYPE=$1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1237 shift |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1238 for i ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1239 show_file_info "$TYPE" "$i" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1240 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1241 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1242 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1243 video_duration () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1244 mencoder "$@" -ovc copy -nosound -o /dev/null -quiet 2>&1 | awk '/^Video stream:/{print $10+$10/$12}' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1245 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1246 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1247 job_exit () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1248 EXIT=$? |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1249 status_bit mpg || [[ ! -f ${output}.mpg && ! -f ${output}01.mpg ]] || show_finalvideo_info "MPEG" "${output}"*.mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1250 sec=$(($(pr_time)-STARTTIME)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1251 echo " JOBEND: $output $(pr_date) ($((sec/3600))h$((sec/60%60))m$((sec%60))s)" >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1252 rm -f "${CLEAN[@]}" psnr_??????.log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1253 ((DEBUG)) && exec >&1- >&2- && exec >&3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1254 if [[ -f $output.yuvscaler.log || -f $output.mpeg2enc.log ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1255 echo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1256 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1257 ((!EXIT)) && [[ ! $quiet ]] && cat "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1258 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1259 ((DEBUG)) && rm -f "$output".debug.fifo && kill $PROCTEE |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1260 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1261 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1262 mplayer_log () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1263 tee -a /dev/stderr | sed 's/.*\r//' | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1264 awk '/^PSNR:|^M[EP][ln]|^There are |^\[open]|^==> |^Recommended video bitrate/{sub(/^/," INFO: ['"$1"'] ");print}' >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1265 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1266 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1267 mp_single_log () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1268 tee -a /dev/stderr | sed 's/.*\r//;/'"$2"'/!d;s/^/ INFO: ['$1'] /' >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1269 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1270 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1271 check_abr () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1272 # abr permitted: |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1273 # ac3: ( 8000/11025/12000) 8 16 24 32 40 48 56 64 80 96 112 128 144 160 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1274 # ac3: (16000/22050/24000) 16 24 32 40 48 56 64 80 96 112 128 160 192 224 256 288 320 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1275 # ac3: (32000/44100/48000) 32 40 48 56 64 80 96 112 128 160 192 224 256 320 384 448 512 576 640 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1276 # mp3: ( 8000/11025/12000) 8 16 24 32 40 48 56 64 80 96 112 128 144 160 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1277 # mp3: (16000/22050/24000) 8 16 24 32 40 48 56 64 80 96 112 128 144 160 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1278 # mp3: (32000/44100/48000) 32 40 48 56 64 80 96 112 128 160 192 224 256 320 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1279 # mp2: ( 8000/11025/12000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1280 # mp2: (16000/22050/24000) 8 16 24 32 40 48 56 64 80 96 112 128 144 160 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1281 # mp2: (32000/44100/48000) 32 48 56 64 80 96 112 128 160 192 224 256 320 384 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1282 # mp1: ( 8000/11025/12000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1283 # mp1: (16000/22050/24000) 32 48 56 64 80 96 112 128 144 160 176 192 224 256 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1284 # mp1: (32000/44100/48000) 32 64 96 128 160 192 224 256 288 320 352 384 416 448 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1285 case $1 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1286 ac3) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1287 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1288 8000|11025|12000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1289 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1290 8|16|24|32|40|48|56|64|80|96|112|128|144|160) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1291 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1292 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1293 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1294 16000|22050|24000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1295 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1296 16|24|32|40|48|56|64|80|96|112|128|160|192|224|256|288|320) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1297 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1298 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1299 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1300 32000|44100|48000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1301 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1302 32|40|48|56|64|80|96|112|128|160|192|224|256|320|384|448|512|576|640) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1303 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1304 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1305 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1306 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1307 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1308 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1309 mp3) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1310 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1311 8000|11025|12000|16000|22050|24000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1312 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1313 8|16|24|32|40|48|56|64|80|96|112|128|144|160) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1314 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1315 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1316 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1317 32000|44100|48000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1318 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1319 32|40|48|56|64|80|96|112|128|160|192|224|256|320) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1320 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1321 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1322 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1323 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1324 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1325 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1326 mp2) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1327 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1328 16000|22050|24000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1329 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1330 8|16|24|32|40|48|56|64|80|96|112|128|144|160) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1331 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1332 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1333 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1334 32000|44100|48000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1335 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1336 32|48|56|64|80|96|112|128|160|192|224|256|320|384) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1337 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1338 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1339 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1340 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1341 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1342 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1343 mp1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1344 case $2 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1345 16000|22050|24000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1346 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1347 32|48|56|64|80|96|112|128|144|160|176|192|224|256) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1348 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1349 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1350 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1351 32000|44100|48000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1352 case $3 in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1353 32|64|96|128|160|192|224|256|288|320|352|384|416|448) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1354 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1355 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1356 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1357 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1358 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1359 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1360 *) return 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1361 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1362 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1363 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1364 debug_line () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1365 echo "--DEBUG: [$PROGNAME] $2($1) $(eval echo $(sed -n $1p "$PROGFILE" | sed 's/ |.*//;s/.>.*//;s/</\\\</'))" >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1366 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1367 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1368 check_mencoder_abr () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1369 local codec lib ASR |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1370 codec=([4]=mp2 mp3 ac3 mp2) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1371 lib=([4]=libavcodec libavcodec libavcodec libtoolame) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1372 ASR=${encode%%:*} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1373 check_abr ${codec[ASR]} $1 $2 || ! echo "**ERROR: [$PROGNAME] ${lib[ASR]} does not support $2 kbps / $1 Hz for ${codec[ASR]}" || exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1374 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1375 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1376 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1377 #### ERROR if some options conflict is detected part 2/2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1378 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1379 #### libavcodec codec/asr/abr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1380 #### libtoolame asr/abr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1381 #### libmp3lame asr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1382 #### no check is done on the other channel in case of multiaudio |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1383 if [[ $encode == [2-7]:?:? ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1384 if [[ $srate ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1385 r=$srate |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1386 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1387 r=$(mp_identify "${MPLAYERINFO[@]}" | sed -n '/^ID_AUDIO_RATE=/s/.*=//p') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1388 if [[ $mpeg && ! $usespeed ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1389 case $frameformat in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1390 *VCD) ((r != 44100)) && pre_log "++ WARN: [$PROGNAME] $frameformat standard requires 44100kHz audio, add -srate 44100" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1391 DVD) ((r != 48000)) && pre_log "++ WARN: [$PROGNAME] $frameformat standard requires 48000kHz audio, add -srate 48000" ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1392 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1393 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1394 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1395 if [[ $encode == [4-7]:?:? ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1396 check_mencoder_abr $r ${AUDIOPASS##*=} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1397 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1398 case $r in |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1399 8000|11025|12000|16000|22050|24000|32000|44100|48000) : ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1400 *) echo "**ERROR: [$PROGNAME] libmp3lame does not support $r Hz sample rate" ; exit 1 ;; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1401 esac |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1402 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1403 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1404 #### copy of non mpeg audio in a VCD |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1405 if [[ $step -gt 1 && $frameformat = VCD && $encode == 0:?:? && ( $mpeg || ${!audioformat} = copy ) && ! $testmca && ! $pictsrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1406 a=$(mp_identify "${MPLAYERINFO[@]}" | sed -n '/^ID_AUDIO_CODEC=/s/.*=//p') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1407 [[ $a != mp3 ]] && echo "**ERROR: [$PROGNAME] you cannot copy $a audio in a $frameformat" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1408 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1409 #### mpegchannels > 2 only with ac3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1410 [[ $mpeg && ${mpegchannels:-2} -gt 2 && $encode == [2-57]:?:? ]] && CODEC=([2]=mp3 mp3 mp2 mp3 [7]=mp2) && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1411 echo "**ERROR: [$PROGNAME] audio codec ${CODEC[${encode%%:*}]} selected with -encode $encode do not support more than 2 audio channels" && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1412 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1413 #### set cleanup |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1414 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1415 trap 'job_exit' 0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1416 CLEAN[${#CLEAN[*]}]="$output".fifo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1417 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1418 skip=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1419 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1420 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1421 #### start the log file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1422 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1423 if [[ ! $resume ]] ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1424 { if [[ $LOG ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1425 echo "$LOG" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1426 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1427 STARTTIME=$(pr_time) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1428 echo "### LOG: $output $(pr_date)" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1429 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1430 echo -n " INFO: [$PROGNAME] version $VERSION running in " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1431 if ((${#TITLESET[*]})); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1432 echo -n "Titleset Mode" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1433 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1434 if [[ $mpeg ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1435 [[ $testmca ]] && echo -n "Testmca Mode" || echo -n "Mpeg Mode" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1436 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1437 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1438 echo "${cpu:+ (cpu=$cpu)}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1439 echo " INFO: [$PROGNAME] command line: '${CMD[@]}'" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1440 } >"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1441 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1442 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1443 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1444 #### WARNING if some requested tools are missing and can be replaced |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1445 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1446 #### WARN |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1447 if [[ $WARN ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1448 echo -e "$WARN" >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1449 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1450 #### volume and audio copy |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1451 if [[ $volume ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1452 [[ $encode == 0:?:? && ( ${!audioformat} = copy || $step -eq 1 || $mpeg ) || ${!audioformat} = copy && ! $encode ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1453 echo "++ WARN: [$PROGNAME] you cannot modify the volume of the output audio stream if you are making a copy the input audio stream" | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1454 tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1455 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1456 #### cpu and bframes |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1457 if [[ $cpu && $bframes ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1458 ((bframes)) && echo "++ WARN: [$PROGNAME] with bframes>0 the encoding will be faster with cpu=1" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1459 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1460 #### -usespeed |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1461 if [[ $usespeed && ( $encode == 0:?:? || $encode == ?:0:? ) ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1462 echo -en "++ WARN: [$PROGNAME] -usespeed may not work if you do not encode both audio and video.\nPress return to proceed" | tee -a "$output".log && read |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1463 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1464 #### total br |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1465 [[ $encode != ?:0:? ]] && ((step>1&&abr*audiostream*1024/1000+vbr>MAXBR)) && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1466 echo "++ WARN: [$PROGNAME] total video+audio bitrate ($vbr+$((abr*audiostream*1024/1000))kbps) exceed $frameformat specifications (${MAXBR}kbps)" | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1467 tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1468 #### -slideaudio/single picture |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1469 if [[ $slideaudio && $slideaudio != /dev/null && $pictsrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1470 ((${#PICTSRC[*]}!=1||$(ls ${PICTSRC[0]} | wc -l)!=1)) && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1471 echo "++ WARN: [$PROGNAME] you should use only one source image if you use the option -slideaudio" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1472 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1473 #FIXME remove once the mpeg muxer is fixed |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1474 #### NTSC telecined with B-frames |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1475 if [[ $mpeg && $telecine && $videonorm = n && ( $frameformat = DVD || $frameformat = SVCD ) && ( $bframes -gt 0 || ! $bframes && $encode == ?:3:? ) ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1476 echo "++ WARN: [$PROGNAME] mpeg telecined and with B-frames are not created correctly by mencoder, do not use telecine or do not use B-frames" | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1477 tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1478 echo -n "Press return to proceed" && read |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1479 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1480 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1481 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1482 #### dump some info in the log file |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1483 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1484 { VARS=(frameformat ${split:+split} vfr vbr abr asr ${mpegchannels:+mpegchannels} ${GOP:+GOP} audioformat) # audioformat must be the last |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1485 VARS[${#VARS[*]}]=${!VARS[${#VARS[*]}-1]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1486 [[ $volume && ! $encode ]] && VARS[${#VARS[*]}]=volume |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1487 echo -n " MPEG: " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1488 for ((i=0;i<${#VARS[*]};i++)) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1489 echo -n "${VARS[i]}:${!VARS[i]} " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1490 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1491 echo -n "${multiaudio:+multiaudio:${multiaudio// /,} }" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1492 echo -n "mpegencoder:$([ $mpeg ] && echo mencoder || echo mpeg2enc)" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1493 [[ $mpegaspect ]] && echo -n " aspect:${ASPECT[mpegaspect]}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1494 [[ $cdi && $frameformat = VCD ]] && echo -n " CD-i" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1495 [[ $telecine ]] && echo -n " telecine" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1496 echo |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1497 VARS=(encode ${vcodec:+vcodec} ${volume:+volume} ${usesbr:+usesbr} ${avisplit:+avisplit} ${channels:+channels} AUDIOPASS VIDEOPASS PASS) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1498 if [[ $encode ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1499 echo -n " $([ $mpeg ] && echo MPEG || echo \ AVI): " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1500 for ((i=0;i<${#VARS[*]};i++)) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1501 echo -n "${VARS[i]}:${!VARS[i]} " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1502 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1503 if ((PASS>1)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1504 [[ $turbo ]] && echo -n "TURBO:on " || echo -n "TURBO:off " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1505 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1506 txt= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1507 [[ $(echo $encode | cut -f 2 -d:) = 1 && $vcustom ]] && txt="libavcodec" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1508 [[ ${encode%%:*} = 2 && $acustom ]] && txt=${txt:+${txt} and} && txt="$txt lame" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1509 txt=${txt:+(custom ${txt} options)} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1510 echo $txt |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1511 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1512 [[ ! $resume ]] && { [[ $audioonly ]] && mp_identify "$audioonly" || mp_identify "${MPLAYERINFO[@]}" ; } | sed -n '/^ID_/s/^/ INFO: [identify] /p' | uniq |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1513 VARS=(${encode:+MENCODERARG} MPLAYERYUVOPT) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1514 VARS=(${encode:+MENCODERARG}) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1515 for ((i=0;i<${#VARS[*]};i++)) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1516 s="INFO: [${VARS[i]}] \${${VARS[i]}[*]}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1517 eval echo "\ \ \ $s" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1518 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1519 } >>"$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1520 h_res=$(grep ID_VIDEO_WIDTH "$output".log | tail -1 | cut -f2 -d=) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1521 v_res=$(grep ID_VIDEO_HEIGHT "$output".log | tail -1 | cut -f2 -d=) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1522 if [[ $pictsrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1523 v_res=$(mplayer -vo null "${MPLAYERINFO[@]}" -frames 1 2>/dev/null | awk '/^VO:/{print $3}' | head -n 1) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1524 h_res=${v_res%x*} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1525 v_res=${v_res#*x} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1526 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1527 [[ $mpeg && ${encode%,*} == ?:0:? ]] && H_RES=$h_res && V_RES=$v_res |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1528 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1529 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1530 #### put the volume in DB |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1531 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1532 [[ $volume ]] && volume="-af volume=$(awk -v a=$volume 'BEGIN{if(a>0) print 20*log(a)/log(10) ; else print 0}')" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1533 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1534 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1535 #### NTSC telecined mpeg copy/speed encoding change |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1536 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1537 if [[ $mpeg && ( $encode == ?:0:? || $usespeed ) || $usespeed && ! $encode && $step -gt 1 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1538 FPS=($(grep ID_VIDEO_FPS "$output".log | cut -f2 -d=) [1]=23.976 24.000 25.000 29.970 30.000 50.000 59.940 60.000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1539 for ((i=1;i<9;i++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1540 a=$(awk -v a=${FPS[0]} -v b=${FPS[i]} 'BEGIN{if (sqrt((a-b)*(a-b))<.02) print b}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1541 if [[ $a ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1542 if [[ ${FPS[0]} != ${FPS[i]} ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1543 echo "++ WARN: [$PROGNAME] input video frame rate is not exactly ${FPS[i]}fps" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1544 FPS[0]=${FPS[i]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1545 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1546 FPS[10]=$i |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1547 break |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1548 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1549 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1550 [[ $usespeed && $i -eq 9 ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1551 echo "++ WARN: [$PROGNAME] input video frame rate is not a valid NTSC/PAL value; disabling -usespeed" | tee -a "$output".log && usespeed= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1552 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1553 if [[ ${FPS[0]} = ${FPS[4]} || ${FPS[0]} = ${FPS[5]} ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1554 FPS[9]=$(mplayer -nocache -quiet "${MPLAYERINFO[@]}" -vo null -nosound -benchmark -frames 60 2>/dev/null | awk '/^demux_mpg:/{print $2}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1555 [[ ${FPS[9]} = 24fps || ${FPS[9]} = 24000/1001fps ]] && FPS[10]=$((FPS[10]-3)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1556 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1557 if [[ $usespeed ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1558 if ((vfr!=${FPS[10]})); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1559 NSPEEDCOEF=([1]=1001 1001 5 1001 1001 5 1001 25 1250 5 25 2500 5 1200 6 2 2400 12 1001 1001 2 1001 5 2000 2 1200 6 1001 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1560 MSPEEDCOEF=([1]=1000 960 4 800 480 2 400 24 1001 4 12 1001 2 1001 5 1 1001 5 1000 200 1 500 3 1001 1 1001 5 1000 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1561 DCOEF=([1]=-2 3 7 10 12 13 13) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1562 if ((vfr>${FPS[10]})); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1563 #### black magic here ;-) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1564 n=$((vfr+${FPS[10]}+${DCOEF[${FPS[10]}]})) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1565 a=${NSPEEDCOEF[n]}/${MSPEEDCOEF[n]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1566 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1567 n=$((vfr+${FPS[10]}+${DCOEF[vfr]})) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1568 a=${MSPEEDCOEF[n]}/${NSPEEDCOEF[n]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1569 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1570 MENCODERARG=( -speed $a -srate $asr -af-adv force=1 "${MENCODERARG[@]}" ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1571 MPLAYERYUVOPT=("${MPLAYERYUVOPT[@]}" -speed $a ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1572 echo " INFO: [usespeed] using speed factor $a" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1573 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1574 elif [[ ${FPS[0]} = ${FPS[4]} || ${FPS[0]} = ${FPS[5]} ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1575 if [[ ${FPS[9]} = 24fps || ${FPS[9]} = 24000/1001fps || $telesrc ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1576 { echo -n " INFO: [$PROGNAME] " |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1577 [[ ${FPS[9]} = 24fps || ${FPS[9]} = 24000/1001fps ]] && echo -n "detected" || echo -n "user selected" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1578 echo " telecined source" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1579 } | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1580 MENCODERARG=( "${MENCODERARG[@]}" -ofps 24000/1001 -mc 0 ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1581 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1582 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1583 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1584 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1585 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1586 #### scale and expand/crop to adapt the aspect ratio |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1587 #### added rotation and overscan |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1588 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1589 if [[ $mpegfixaspect && $step -gt 1 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1590 a=$(get_aspect "${MPLAYERINFO[@]}") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1591 [[ ${a:0:9} = undefined ]] && a=$(awk -v a=$h_res -v b=$v_res 'BEGIN{printf("%f",a/b)}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1592 [[ $mpegaspect == 1 ]] && b=$(awk -v a=$H_RES -v b=$V_RES 'BEGIN{printf("%f",a/b)}') || b=${ASPECT[${mpegaspect:-2}]} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1593 vfilter=$(awk -v a=$a -v A=$b -v W=$H_RES -v H=$V_RES -v crop=$mpegfixaspect -v i=${interlaced:-0} -v r=$rotate -v o=$overscan -v logfile="$(echo "$output" | sed 's/\\/\\\\/g')".log 'BEGIN{ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1594 ko=(1-o/100) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1595 if(a==1.78)a=16/9 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1596 if(a==1.33)a=4/3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1597 if(A=="4/3")A=4/3 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1598 if(A=="16/9")A=16/9 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1599 if(r!=""){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1600 A=1/A |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1601 tmp=W |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1602 W=H |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1603 H=tmp |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1604 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1605 if(a>A&&crop==0||a<A&&crop==1){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1606 Eh=A*H/a |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1607 Ew=W |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1608 }else{ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1609 Ew=W*a/A |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1610 Eh=H |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1611 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1612 Ew=2*int(Ew*ko/2+0.50) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1613 Eh=2*int(Eh*ko/2+0.50) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1614 printf("-vf scale=%d:%d",Ew,Eh) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1615 printf(" INFO: [mpegfixaspect] -vf scale=%d:%d",Ew,Eh) >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1616 if(i==1)printf(":1") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1617 if(i==1)printf(":1") >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1618 if(crop==0){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1619 printf(",expand=%d:%d",W,H) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1620 printf(",expand=%d:%d",W,H) >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1621 }else{ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1622 printf(",crop=%d:%d",W,H) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1623 printf(",crop=%d:%d",W,H) >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1624 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1625 if(r!=""){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1626 printf(",rotate=%d",r) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1627 printf(",rotate=%d",r) >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1628 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1629 if(o!=0) printf(" [overscan=%d]",o) >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1630 printf("\n") >>logfile |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1631 }') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1632 if [[ $mpeg ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1633 for ((a=0;a<${#MENCODERARG[*]};a++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1634 if [[ ${MENCODERARG[a]} = -vf ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1635 MENCODERARG[a+1]=$(echo ${MENCODERARG[a+1]} | sed 's/scale=[^,]*,//;s/^/'"${vfilter#-vf }"',/') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1636 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1637 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1638 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1639 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1640 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1641 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1642 #### dvd vobsub |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1643 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1644 #### function to select the vobsub to extract |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1645 next_vobsub_idx () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1646 if ((${#SID[*]})); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1647 if ((idx < ${#encsid[*]})); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1648 SID=(-sid ${encsid[idx]} -vobsuboutindex ${encsdx[idx]} ${encsla:+-vobsuboutid ${encsla[idx]}} -vobsubout "$output") |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1649 echo " INFO: [$PROGNAME] dumping subtitle ${encsid[idx]} to vobsub ${encsdx[idx]}${encsla:+ (${encsla[idx]})}" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1650 idx=$((idx+1)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1651 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1652 unset SID |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1653 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1654 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1655 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1656 #### turn on vobsub extraction if encsid is given |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1657 if (( ${#encsid[*]} )) ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1658 (( ${#encsdx[*]} )) || encsdx=( ${encsid[*]} ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1659 idx=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1660 SID=(0000) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1661 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1662 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1663 unset SID |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1664 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1665 status_bit sub || unset SID |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1666 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1667 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1668 #### test condition "extra" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1669 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1670 IDACOD=$(grep "ID_AUDIO_CODEC" "$output".log | tail -1 | cut -f2 -d=) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1671 [[ $mpeg && ! $pictsrc && ( $encode == 1:?:? || $multiaudio || $encode == 0:?:? && $IDACOD != mp3 && $IDACOD != a52 ) ]] && extra=1 || extra= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1672 [[ $extra ]] && echo "**ERROR: [$PROGNAME] output stream: unsupported audio codec $IDACOD" | tee -a "$output".log && exit 1 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1673 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1674 CLEAN[${#CLEAN[*]}]="$output".tmp |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1675 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1676 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1677 #### avi/mpeg section |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1678 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1679 if [[ $encode ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1680 if status_bit avi ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1681 find_sbr () { |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1682 local kv k ka |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1683 if [[ $mpeg ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1684 kv=9888 ; k=33 ; ka=996 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1685 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1686 if ((usesbr<=6)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1687 sbr=$(awk '/for '"${SBR[usesbr-1]}"'MB CD/{print $NF}' <"$output".log) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1688 [[ $sbr ]] && ((sbr<vbitrate)) && VIDEOPASS=${VIDEOPASS/vbitrate=$vbitrate:/vbitrate=$sbr:} && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1689 echo " INFO: [mencoder] using vbitrate=$sbr" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1690 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1691 #### usesbr is in MB |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1692 #### remind: 650-800,650-1400,800-1400 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1693 sbr[0]=650 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1694 sbr[1]=1400 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1695 sbr[2]=$(awk '/for '"${SBR[0]}"'MB CD/{print $NF}' <"$output".log) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1696 sbr[3]=$(awk '/for '"${SBR[4]}"'MB CD/{print $NF}' <"$output".log) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1697 [[ ${sbr[2]} && ${sbr[3]} ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1698 sbr[4]=$(((((usesbr*kv/10000-k)-(audiosize*ka/1000))*(sbr[3]-sbr[2])+sbr[1]*sbr[2]-sbr[0]*sbr[3])/(sbr[1]-sbr[0]))) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1699 [[ ${sbr[4]} ]] && ((sbr[4]<vbitrate && sbr[4]>0)) && VIDEOPASS=${VIDEOPASS/vbitrate=$vbitrate:/vbitrate=${sbr[4]}:} && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1700 echo " INFO: [mencoder] using vbitrate=${sbr[4]}" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1701 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1702 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1703 AID= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1704 #### start mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1705 PLOG=( -passlogfile "$output".avi2pass.log ) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1706 rm -f frameno.avi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1707 if ((PASS==1)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1708 if [[ $usesbr && ! $extra ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1709 mencoder $OPTIONS -ovc frameno -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS 2>&1 | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1710 mp_single_log mencoder '^Recommended video bitrate' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1711 find_sbr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1712 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1713 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1714 ((DEBUG)) && debug_line $((LINENO+1)) "PASS 1/$PASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1715 mencoder $OPTIONS $VIDEOPASS -o "$output".$SUF "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $volume -v | mplayer_log mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1716 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1717 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1718 #### N pass |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1719 if [[ $usesbr && ! $extra ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1720 mencoder $OPTIONS -ovc frameno -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS 2>&1 | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1721 mp_single_log mencoder '^Recommended video bitrate' |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1722 find_sbr |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1723 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1724 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1725 CLEAN[${#CLEAN[*]}]="$output".avi2pass.log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1726 ((DEBUG)) && debug_line $((LINENO+1)) "PASS 1/$PASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1727 mencoder $OPTIONS ${VIDEOPASS}:vpass=1$turbo -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $volume "${PLOG[@]}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1728 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1729 if ((PASS==2)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1730 ((DEBUG)) && debug_line $((LINENO+1)) "PASS 2/$PASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1731 mencoder $OPTIONS ${VIDEOPASS}:vpass=2 -o "$output".$SUF "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $volume "${PLOG[@]}" -v | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1732 mplayer_log mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1733 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1734 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1735 for ((a=2;a<PASS;a++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1736 ((DEBUG)) && debug_line $((LINENO+1)) "PASS $a/$PASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1737 mencoder $OPTIONS ${VIDEOPASS}:vpass=3 -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $volume "${PLOG[@]}" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1738 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1739 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1740 ((DEBUG)) && debug_line $((LINENO+1)) "PASS $PASS/$PASS" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1741 mencoder $OPTIONS ${VIDEOPASS}:vpass=3 -o "$output".$SUF "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $volume "${PLOG[@]}" -v | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1742 mplayer_log mencoder |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1743 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1744 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1745 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1746 status_bit avi set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1747 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1748 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1749 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1750 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1751 #### if there are still vobsub to dump, do it now |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1752 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1753 while ((${#SID[*]})) ; do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1754 ((DEBUG)) && debug_line $((LINENO+1)) vobsub |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1755 mencoder -ovc copy -o /dev/null $AID "${SID[@]}" "${MENCODERARG[@]}" -nosound |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1756 next_vobsub_idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1757 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1758 if status_bit sub ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1759 if [[ -f $output.sub && -f $output.idx && ${#encsid[*]} -gt 0 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1760 #### reset the subtitles with the wrong timestamp |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1761 awk -v logfile="$(echo "$output" | sed 's/\\/\\\\/g')".log '{ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1762 if($1=="id:")id=" ("$0")" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1763 if($1=="timestamp:"){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1764 n=$2; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1765 sub(/,/,"",n); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1766 # convert the timestamp in seconds |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1767 m=3600*substr(n,1,index(n,":")-1); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1768 sub(/[0-9]*:/,"",n); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1769 m=m+60*substr(n,1,index(n,":")-1); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1770 sub(/[0-9]*:/,"",n); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1771 m=m+substr(n,1,index(n,":")-1); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1772 sub(/[0-9]*:/,"",n); |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1773 m=m+n/1000; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1774 # .002 is already ok |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1775 if(m+.004<t){ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1776 printf("++ WARN: [encsid] reset bad timestamp sequence: %s %s%s\n",gensub(/[^ ]* /,"",1,gensub(/,.*/,"",1,p)),substr($2,1,length($2)-1),id) >>logfile ; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1777 id=""; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1778 p=gensub(/ [^ ]* /," 00:00:00:000, ",1,p)" #"p} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1779 t=m} |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1780 else t=0; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1781 if(NR>1)print p; |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1782 p=$0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1783 } |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1784 END{print p}' <"$output".idx >"$output".idx.idx && mv "$output".idx.idx "$output".idx |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1785 status_bit sub set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1786 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1787 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1788 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1789 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1790 #### if fast mode skip multiplexing |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1791 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1792 if [[ $mpeg && $fast ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1793 if status_bit mpg ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1794 if [[ ! $extra ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1795 rm -f "$output".mpg "${output}"[0-9][0-9].mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1796 status_bit mpv set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1797 status_bit mpa set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1798 status_bit mpg set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1799 mv "$output".$SUF "$output".mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1800 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1801 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1802 #FIXME remove once the mpeg muxer is fixed |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1803 #### NTSC dvd warn |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1804 [[ $videonorm = n && $frameformat = DVD ]] && \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1805 echo "++ WARN: [$PROGNAME] mencoder does not multiplex correctly NTSC mpeg, you may want to use encode2mpeg instead" | tee -a "$output".log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1806 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1807 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1808 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1809 #### split the mpeg stream (for Mpeg Mode) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1810 ############################################################################### |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1811 if status_bit spl ; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1812 #### split for Mpeg Mode (mpeg4 codec not supported) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1813 #### mencoder does not support split as it does mpeg2enc/mplex |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1814 #### this solution is slow, but it seems quite accurate |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1815 if [[ $mpeg && $split && $vcodec != mpeg4 ]]; then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1816 [[ ! $fast ]] && mv "$output"01.mpg "$output".mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1817 file_size "$output".mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1818 if ((split*1024*1024<fsize)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1819 chunks=$((fsize/(split*1024*1024)+1)) |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1820 CLEAN[${#CLEAN[*]}]="$output".framelist |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1821 mplayer "$output".mpg -vf framestep=I -vo null -nosound -benchmark 2>/dev/null | tr '\015' '\012' | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1822 awk '{if($1=="I!")print t,substr(f,1,index(f,"/")-1);t=$2;f=$3}' >"$output".framelist |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1823 m=0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1824 #### removed -vc dummy |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1825 [[ $multiaudio ]] && a=$(mplayer -vo null -ao null -frames 1 -v "$output".mpg 2>/dev/null | awk '/==> Found audio str/{print $NF}' | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1826 sort -n | tr '\012' ',' | sed 's/,$/\n/') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1827 for ((i=0;i<chunks;i++)); do |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1828 if ((i<chunks-1)); then |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1829 n=$(mplayer "$output".mpg -vf framestep=I -vo null -nosound -benchmark 2>/dev/null -sb $(((i+1)*split*1024*1024)) -frames 30 | \ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1830 tr '\015' '\012' | awk '{if($1=="I!"){print t;exit};t=$2}') |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1831 n=$(awk '/^'"$n"'/{print $2-1;exit}' "$output".framelist) #should be -2 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1832 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1833 n= |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1834 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1835 ((DEBUG)) && debug_line $((LINENO+1)) "mpeg_split $((i+1))/$chunks" |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1836 "$PROGFILE" -norc "$output".mpg -o "$output"$(printf "%02d" $((i+1))) -mpegonly -mpeg -encode 0:0:1 -$(echo $frameformat| tr '[:upper:]' '[:lower:]') -nosplit -noshowlog -sb $((i*split*1024*1024)) ${n:+-frames $((n-m))} -a ${mpegaspect:-2} ${multiaudio:+-multiaudio $a} -mc 0 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1837 rm "$output"$(printf "%02d" $((i+1))).log |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1838 m=$n |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1839 done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1840 rm "$output".mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1841 else |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1842 mv "$output".mpg "$output"01.mpg |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1843 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1844 status_bit spl set |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1845 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1846 fi |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1847 |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1848 ################################################################################ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1849 #### done |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1850 ################################################################################ |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1851 exit |
c658a7107209
new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff
changeset
|
1852 |