annotate TOOLS/encode2mpeglight @ 23837:7065615ef25c

Do not set vo_sub to NULL on changing subtitles, update_subtitles will do this when called with reset == 1. Fixes subtitles getting stuck when switching via 'j'.
author reimar
date Wed, 25 Jul 2007 17:11:22 +0000
parents 21b938300bf7
children 37feaaf7b7b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #
20867
21b938300bf7 -vop has been deprecated a long time ago.
diego
parents: 20858
diff changeset
3 # Version: 0.6.3
17507
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>
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
8 # 2006-11-06 <encode2mpeg at email.it>
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
9 #
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
10 # Purpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD MPEG
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
11 #
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
12 # encode2mpeglight is free software; you can redistribute it and/or modify
17507
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
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
16 # encode2mpeglight is distributed in the hope that it will be useful,
17507
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
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
22 # along with encode2mpeglight; if not, write to the Free Software
19614
36589811e5d0 The FSF changed postal address.
diego
parents: 17507
diff changeset
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17507
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 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
27 # encode2mpeglight is a program that can create VCD/SVCD/DVD MPEGs
17507
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,
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
46 # I try to make it work with SVN too, but due to the "unstable" nature of
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
47 # SVN, bugs may suddenly appear. If you find any, please report them to me.
17507
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
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
71 echo "$PROGNAME defaults to encode2mpeg's MPEG Mode, the other modes are not"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
72 echo "available."
17507
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 () {
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
95 mplayer -msglevel identify=6 -vo md5sum:outfile=/dev/null -ao null -nocache -frames 0 "$@" 2>/dev/null
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
96 }
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
97 ###############################################################################
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
98 id_find () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
99 local ID=$1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
100 shift
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
101 mp_identify "$@" | awk -v id=$ID -F= '$1==id{t=$2}END{print t}'
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
102 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
103 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
104 get_aspect () {
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
105 mplayer -vc -mpegpes, -vo null -ao null -nocache -frames 4 "$@" 2>/dev/null | sed '/^Movie-Aspect is/!d;s/.*Movie-Aspect is //;s/:.*//'
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
106 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
107 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
108 mlistopt () {
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
109 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
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 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
112 do_log () {
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
113 echo "$1"
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
114 ((LG)) && echo "$1" >>"$output".log || WARN="$WARN${WARN:+\n}$1"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
115 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
116 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
117 isarg () {
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
118 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
119 [[ ${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
120 [[ ! $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
121 "$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
122 "$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
123 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
124 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
125 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
126 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
127 exit
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
128 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
129 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
130 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
131 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
132 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
133 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
134 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
135 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
136 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
137 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
138 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
139 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
140 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
141 INFO=$(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_')
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
142 ABR=$(echo "$INFO" | grep '^ID_AUDIO_BITRATE' | tail -1 | cut -f2 -d=)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
143 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
144 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
145 *) 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
146 esac
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 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
150 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
151 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
152 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
153 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
154 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
164 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
165 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
166 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
167 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
168 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
169 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
170 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
171 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
172 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
173 LIST=(mozilla seamonkey firefox)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
174 [[ ${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
175 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
176 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
177 done
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
178 LIST=(mozilla firefox seamonkey opera konqueror epiphany galeon)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
179 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
180 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
181 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
182 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
183 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
184 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
185 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
186 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
187 *) OPTION= ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
188 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
189 "${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
190 return
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
191 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
192 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
193 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
194
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
195 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
196 #### variable initialization
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
197 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
198 abr=;asr=;vbr=;vfr=;videonorm=;frameformat=;output=;audioformat=;mp1=;mp2=;mp3=;ac3=;dts=;lpcm=;aac=;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=;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=;rawsub=;vobsubsrc=;af=;lavf=;subrender=;harddup=;overburn=
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 TOOL=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
237 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
238 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
239 LPCMPAR=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
240 SUBLANG=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
241 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
242 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
243 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
244 LAVC=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
245 WARN=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
246 LOG=
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
247 LG=0
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
248 SVN=0
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
271 #### 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
272 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
273 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
274
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
275 (($#)) || ! 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
276 CMD=( "$@" )
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 #### 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
279 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
280 $(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
281 $(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
282 $(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
283
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
284 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
285 #### 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
286 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
287 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
288 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
289 [[ ${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
290 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
291 if [[ ! $norc ]] && ! awk '{if($1~"^#")exit 1}' ~/.encode2mpegrc ; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
292 do_log "++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" >/dev/null
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
293 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
294 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
295 [[ ! $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
296 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
297
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
298 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
299 #### 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
300 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
301 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
302 #### PARSING
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
303 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
304 -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
305 #-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
306 [[ $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
307 shortusage
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
308 exit
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
309 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
310 -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
311 #-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
312 [[ $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
313 usage
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 -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
317 #-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
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 [[ ${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
320 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
321 exit
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
322 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
323 -noshowlog)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
324 #-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
325 [[ $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
326 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
327 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
328 -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
329 #-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
330 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
331 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
332 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
333 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
334 -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
335 # 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
336 # 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
337 # 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
338 # 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
339 #- 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
340 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
341 [[ $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
342 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
343 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
344 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
345 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
346 -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
347 # 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
348 # 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
349 #-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
350 [[ $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
351 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
352 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
353 [[ $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
354 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
355 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
356 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
357 -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
358 # 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
359 # 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
360 #-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
361 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
362 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
363 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
364 shift
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:=0}
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
366 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
367 -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
368 # 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
369 # 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
370 # 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
371 # 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
372 #--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
373 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
374 [[ ${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
375 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
376 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
377 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
378 -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
379 #-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
380 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
381 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
382 exit
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
383 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
384 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
385 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
386 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
387 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
388 -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
389 #-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
390 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
391 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
392 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
393 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
394 -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
395 #-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
396 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
397 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
398 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
399 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
400 -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
401 # 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
402 # [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
403 # 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
404 # 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
405 # 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
406 # 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
407 # 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
408 # 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
409 # 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
410 #- 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
411 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
412 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
413 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
414 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
415 -n|-video-norm) #<n|p|s>
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
416 # set the video norm of the VCD/SVCD/DVD; NTSC is USA standard,
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
417 # PAL is European standard and SECAM is French standard; concerning
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
418 #-VCD/SVCD/DVD encoding, SECAM is equivalent to PAL
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
419 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
420 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
421 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
422 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
423 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
424 *) 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
425 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
426 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
427 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
428 -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
429 # 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
430 # 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
431 #-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
432 [[ $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
433 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
434 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
435 -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
436 # 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
437 # 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
438 # 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
439 # 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
440 # 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
441 # 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
442 # 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
443 # 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
444 #- 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
445 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
446 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
447 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
448 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
449 -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
450 # 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
451 #-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
452 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
453 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
454 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
455 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
456 -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
457 # 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
458 # 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
459 # 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
460 # 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
461 # 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
462 # 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
463 #- 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
464 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
465 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
466 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
467 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
468 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
469 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
470 -vcd) #
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
471 #-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
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=VCD
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
474 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
475 -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
476 # 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
477 # 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
478 # 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
479 # 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
480 #-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
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 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
483 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
484 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
485 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
486 -svcdht) #
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
487 # 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
488 # 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
489 #-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
490 [[ $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
491 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
492 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
493 -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
494 # 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
495 # 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
496 # 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
497 # 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
498 # 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
499 # 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
500 # 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
501 #-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
502 [[ $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
503 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
504 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
505 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
506 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
507 -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
508 #-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
509 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
510 [[ $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
511 shift
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 -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
514 # 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
515 #-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
516 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
517 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
518 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
519 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
520 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
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 *)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
523 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
524 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
525 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
526 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
527 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
528 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
529 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
530 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
531 -mpeg1vbr) #
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
532 # 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
533 # 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
534 #-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
535 [[ $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
536 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
537 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
538 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
539 -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
540 # 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
541 #-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
542 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
543 [[ $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
544 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
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 -mpegchannels) #<1-6>
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
548 # number of channels of the MPEG audio stream, 1-6 for ac3 and lpcm;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
549 # 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
550 #-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
551 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
552 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
553 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
554 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
555 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
556 -normalize)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
557 #-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
558 [[ $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
559 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
560 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
561 -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
562 # 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
563 #-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
564 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
565 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
566 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
567 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
568 -noscale) #
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
569 # encode2mpeg automatically scales the video according to the MPEG
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
570 # profile chosen, this option disables this feature; used mainly
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
571 # for debug purposes.
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
572 [[ $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
573 scale=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
574 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
575 -monochrome)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
576 #-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
577 [[ $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
578 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
579 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
580 -split) #<n>
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
581 #-split the resulting MPEG stream in <n> MB chunks.
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
582 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
583 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
584 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
585 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
586 -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
587 # 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
588 # 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
589 # 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
590 # 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
591 # 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
592 # 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
593 # 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
594 # 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
595 # 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
596 # 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
597 # 7 toolame/mp2
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
598 # 8 libfaac/aac
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
599 #- 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
600 encode=5:3:2
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
601 echo "$2" | grep -qE '^[0-8]:[0-4]:[1-9](,[0-9]+)?$' && encode=$2
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
602 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
603 shift
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 -telecinesrc) #
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
606 # if you use -encode n:0:i in MPEG Mode, encode2mpeg needs to know
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
607 # if the source NTSC MPEG is telecined, otherwise the stream copy may
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
608 # not work properly; normally encode2mpeg is able to detect telecined
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
609 # sources, but, if the source MPEG is mixed, part not telecined and
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
610 # 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
611 #-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
612 [[ $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
613 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
614 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
615 -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
616 # 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
617 #-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
618 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
619 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
620 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
621 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
622 -hispeed) #
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
623 # 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
624 # 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
625 # option is mainly intented for testing, but it can be used if you
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
626 #-want to create more quickly an MPEG-4/AVI or a DVD.
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
627 [[ $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
628 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
629 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
630 -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
631 # 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
632 #-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
633 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
634 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
635 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
636 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
637 -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
638 # 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
639 #--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
640 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
641 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
642 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
643 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
644 -acustom) #<mp3lame options>
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
645 # specify a custom set of lame options (with -encode 2:m:i) or faac
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
646 #-options (with -encode 8:m:i)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
647 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
648 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
649 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
650 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
651 -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
652 #-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
653 # 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
654 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
655 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
656 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
657 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
658 -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
659 # 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
660 #-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
661 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
662 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
663 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
664 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
665 -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
666 #-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
667 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
668 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
669 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
670 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
671 -usespeed) #
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
672 # 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
673 # 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
674 # 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
675 # 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
676 #-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
677 [[ $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
678 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
679 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
680 -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
681 # 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
682 # 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
683 # 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
684 # 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
685 # 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
686 #-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
687 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
688 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
689 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
690 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
691 [[ $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
692 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
693 -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
694 #-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
695 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
696 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
697 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
698 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
699 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
700 -interlaced)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
701 #-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
702 [[ $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
703 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
704 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
705 -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
706 # 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
707 # 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
708 #-the audio file is used
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
709 isarg $1 "$2" images
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
710 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
711 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
712 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
713 -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
714 # 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
715 #-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
716 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
717 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
718 [[ $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
719 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
720 shift
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 -norc)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
723 #-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
724 [[ $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
725 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
726 -debug)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
727 # 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
728 # 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
729 #-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
730 [[ $2 = doc || $2 = help ]] && isarg $1 $2
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
731 echo "$2" | grep -q '^[0-7]$' && DEBUG=$2 && shift || DEBUG=3
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
732 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
733 (-frames)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
734 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
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 (-channels)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
739 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
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 (-srate)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
744 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
745 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
746 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
747 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
748 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
749 (-endpos)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
750 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
751 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
752 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
753 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
754 (-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
755 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
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 (-vf)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
758 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
759 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
760 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
761 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
762 ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
763 (-af)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
764 af="-af $2"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
765 isarg $1 $2
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
766 shift
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
767 ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
768 (-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
769 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
770 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
771 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
772 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
773 (mf://*)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
774 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
775 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
776 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
777 IFS=,
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
778 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
779 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
780 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
781 ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
782 (-sub)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
783 [[ ! -f $2 ]] && echo "**ERROR: [$PROGNAME] subtitle file '$2' not found" && exit 1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
784 MPLAYEROPT=( "${MPLAYEROPT[@]}" $1 "$2" )
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
785 subrender=1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
786 shift
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
787 ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
788 (-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
789 *)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
790 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
791 [[ ${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
792 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
793 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
794 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
795 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
796 *)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
797 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
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 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
800 fi
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 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
803 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
804 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
805
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
806 [[ -s ~/.encode2mpegrc && ! $norc ]] && do_log " INFO: [$PROGNAME] using .encode2mpegrc settings: '$(<~/.encode2mpegrc)'"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
807 if [[ $subrender || $harddup ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
808 if [[ $vf ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
809 vf=$vf${subrender:+,expand=::::1}
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
810 [[ $harddup ]] && ! echo $vf | grep -q harddup && vf=$vf,harddup
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
811 for ((a=0;a<${#MPLAYEROPT[*]};a++)); do
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
812 [[ ${MPLAYEROPT[a]} = -vf ]] && MPLAYEROPT[a+1]=${vf#-vf }
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
813 done
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
814 else
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
815 vf="-vf ${subrender:+expand=::::1}${harddup:+${subrender:+,}harddup}"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
816 MPLAYEROPT=( "${MPLAYEROPT[@]}" $vf )
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
817 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
818 fi
17507
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 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
821 #### debug part
17507
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 if ((DEBUG)); then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
824 if ((DEBUG & 1)); then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
825 #### redirect stdout and stderr to the debug file
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
826 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
827 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
828 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
829 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
830 PROCTEE=$!
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
831 exec &>"$output".debug.fifo
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
832 trap 'rm "$output".debug.fifo' 0
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
833 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
834 if ((DEBUG & 2)); then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
835 #### catch mplayer/mencoder errors
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
836 mplayer () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
837 command mplayer "$@"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
838 ret=$? ; (( ret )) && error_line "$FUNCNAME $*" || true
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
839 }
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
840 mencoder () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
841 command mencoder "$@"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
842 ret=$? ; (( ret )) && error_line "$FUNCNAME $*" || true
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
843 }
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
844 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
845 ((DEBUG & 4)) && set -x
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
846 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
847
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
848 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
849 #### 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
850 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
851 #### 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
852 for a in mplayer mencoder ; do
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
853 type -f $a &>/dev/null || ! echo "**ERROR: [$PROGNAME] $a missing, install $(echo ${a:0:2} | tr '[:lower:]' '[:upper:]')${a:2}" || exit 1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
854 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
855 #### 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
856 [[ ! $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
857 #### unspecified video norm
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
858 [[ ! $videonorm && step -gt 1 && ! ( $mpeg && ${encode%,*} == ?:0:? && ! $menu ) && ${#TITLESET[*]} -eq 0 ]] && \
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
859 echo "**ERROR: [$PROGNAME] you must specify a video norm (-n n|p|s)" && exit 1
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
860 #### libfaac check
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
861 if [[ ${encode%,*} == 8:?:? ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
862 ! mencoder -oac help 2>/dev/null | grep -q faac && echo "**ERROR: [$PROGNAME] missing libfaac support in mencoder [-encode 8:m:i]" && exit 1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
863 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
864 #### mpeg4
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
865 if [[ $vcodec = mpeg4 ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
866 [[ $pictsrc && $step -gt 1 && $mpeg ]] && echo "**ERROR: [$PROGNAME] -vcodec mpeg4, -mpeg and mf://file are not compatible" && exit 1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
867 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
868 #### pictsrc
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
869 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
870 [[ $slideaudio != /dev/null && ${encode%,*} == 0:?:? && $mpeg ]] && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
871 echo "**ERROR: [$PROGNAME] -encode 0:m:i is not compatible with mf:// in MPEG Mode" && exit 1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
872 [[ $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
873 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
874 #### -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
875 [[ ${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
876
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
877 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
878 #### 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
879 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
880 #### 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
881 if [[ ${encode%,*} == 7:?:? ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
882 if ! mencoder -oac help 2>/dev/null | grep -q t[wo]olame ; then
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
883 encode=4:${encode#?:}
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
884 do_log "++ WARN: [$PROGNAME] missing toolame support in mencoder, setting -encode $encode"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
885 else
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
886 mencoder -oac help 2>/dev/null | grep -q toolame && TOOLAME=toolame || TOOLAME=twolame
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
887 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
888 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
889
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
890 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
891 #### 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
892 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
893 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
894 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
895 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
896 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
897 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
898 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
899 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
900 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
901 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
902 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
903 6) AFMT=ac3 ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
904 8) AFMT=aac ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
905 esac
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
906 [[ $AFMT ]] && eval : ${audioformat:-\${$AFMT:=copy\}}
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
907 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
908 : ${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
909 : ${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
910 : ${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
911 ((${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
912 : ${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
913 : ${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
914 : ${dts:=copy}
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
915 : ${aac:=faac}
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
916 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
917 mp1)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
918 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
919 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
920 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
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 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
923 mp2)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
924 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
925 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
926 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
927 [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
928 esac
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 mp3)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
931 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
932 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
933 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
934 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
935 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
936 ac3)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
937 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
938 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
939 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
940 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
941 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
942 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
943 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
944 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
945 ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
946 aac) : ${abr:=$((${mpegchannels:-2}*48))} ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
947 #### 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
948 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
949 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
950 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
951 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
952 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
953 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
954 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
955 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
956 [[ $mpeg && ${encode%,*} == ?:0:? ]] && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
957 vbr=$(($(id_find ID_VIDEO_BITRATE "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@")/1000))
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
958 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
959 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
960 *) : ${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
961 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
962 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
963 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
964 : ${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
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 n)
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
967 [[ $frameformat != VCD && ! $vfr && $hispeed -eq 0 && ! $testmca ]] && vfr=1 && telecine=1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
968 : ${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
969 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
970 esac
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
971 [[ $encode && ${encode%,*} != ?:0:? ]] && : ${vfr:=2}
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
972 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
973 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
974 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
975 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
976 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
977 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
978 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
979 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
980 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
981 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
982 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
983 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
984 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
985 [[ $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
986 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
987
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
988 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
989 #### 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
990 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
991 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
992
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
993 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
994 #### 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
995 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
996 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
997 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
998 #### 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
999 #### 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
1000 ((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
1001 [[ $(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
1002 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
1003 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1004 ((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
1005
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 #### -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
1008 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1009 PCMWAV=(pcm:waveheader:fast:file=%$((${#output}+4))%"$output".wav)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1010 PCMTMP=(pcm:waveheader:fast:file=%$((${#output}+4))%"$output".tmp)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1011 PCMNOWYUV=(pcm:nowaveheader:fast:file=/dev/fd/4)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1012
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1013 [[ $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
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 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1016 #### 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
1017 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1018
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1019 #### 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
1020 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
1021 [[ $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
1022 fi
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 #### 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
1025 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
1026
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1027 #### 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
1028 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
1029 if [[ $slideaudio && $slideaudio != /dev/null ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1030 [[ $(id_find ID_AUDIO_RATE "$slideaudio") != $asr ]] && SRATE="-srate $asr -af-adv force=1" || SRATE=
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1031 CLEAN[${#CLEAN[*]}]="$output".wav
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1032 mplayer "$slideaudio" $SRATE -vo null -vc dummy -ao "${PCMWAV[@]}" $afm ${mpegchannels:+-channels $mpegchannels -af channels=$mpegchannels}
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1033 MPLAYEROPT=( "${MPLAYEROPT[@]}" -fps 1/$(id_find ID_LENGTH "$output".wav) -audiofile "$output".wav )
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1034 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1035 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
1036 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
1037 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
1038 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1039 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
1040 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1041 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1042 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1043
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1044 #### 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
1045 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
1046
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1047 MENCODERARG=( "${MENCODERARG[@]}" "${MENCODEROPT[@]}" ${endpos:+-endpos $endpos} ${ofps:+-ofps $ofps} )
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1048 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
1049 MENCODERARG=( "${MENCODERARG[@]}" -channels $mpegchannels )
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1050 af=$(echo "${af:--af }${af:+,}" | sed 's/channels=[^,]*,//')channels=$mpegchannels
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1051 elif [[ $channels ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1052 MENCODERARG=( "${MENCODERARG[@]}" -channels $channels )
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1053 af=$(echo "${af:--af }${af:+,}" | sed 's/channels=[^,]*,//')channels=$channels
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1054 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1055
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1056 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
1057
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1058 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
1059 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
1060 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
1061 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
1062 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
1063 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1064 [[ $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
1065 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
1066 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
1067
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1068 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
1069 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
1070 SVCD)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1071 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
1072 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
1073 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
1074 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1075 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1076 DVD)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1077 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
1078 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
1079 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
1080 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
1081 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
1082 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
1083 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1084 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1085 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1086 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
1087 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
1088 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
1089 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
1090 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
1091 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
1092 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
1093 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
1094 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1095 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
1096 VCD)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1097 : ${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
1098 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
1099 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
1100 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
1101 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
1102 [[ $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
1103 ((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
1104 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
1105 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1106 SVCD)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1107 : ${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
1108 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
1109 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
1110 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
1111 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
1112 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
1113 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1114 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
1115 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
1116 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1117 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
1118 [[ $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
1119 ((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
1120 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
1121 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1122 DVD)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1123 : ${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
1124 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
1125 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
1126 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
1127 [[ $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
1128 ((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
1129 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
1130 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1131 esac
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 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1134 #### 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
1135 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1136 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
1137 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
1138 if [[ $mpeg ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1139 # mencoder can put in the MPEG container:
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1140 # 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
1141 # 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
1142 [[ ${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
1143 #MUX="-mpegopts ${mpegaspect:+vaspect=${ASPECT[mpegaspect]}:}:vbitrate=${vbr}"
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1144 MUX="-mpegopts "
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1145 if [[ $telecine ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1146 if [[ $vcodec = mpeg2video || ! $vcodec && $frameformat != VCD ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1147 if [[ $vfr == [12] ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1148 [[ $videonorm = n ]] && MUX2=":telecine" || MUX2=":film2pal"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1149 else
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1150 do_log "++ WARN: [$PROGNAME] telecine only works with 24000/1001 or 24 fps, disabling it"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1151 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1152 else
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1153 do_log "++ WARN: [$PROGNAME] telecine only works for MPEG-2, disabling it"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1154 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1155 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1156 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
1157 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
1158 SVCD) if [[ $trick ]]; then MUX="${MUX}format=xvcd" ; else
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1159 MUX="${MUX}format=xsvcd" ; fi ; LAVC="vcodec=${vcodec:-mpeg2video}:vrc_buf_size=917" ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1160 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
1161 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1162 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
1163 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
1164 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
1165 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
1166 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1167 [[ $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
1168 [[ $mpegmbr ]] && [[ $mpegmbr -lt $vbr ]] && mpegmbr=$vbr
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1169 #### -a 1 is SAR=1 (do not scale), not DAR=1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1170 [[ $mpegaspect != 1 ]] && LAVC="${LAVC}:aspect=${ASPECT[mpegaspect]}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1171 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
1172 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
1173 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
1174 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
1175 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
1176 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
1177 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
1178 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
1179 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
1180 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1181 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1182 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
1183 fi
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 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
1187 ((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
1188 [[ $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
1189 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
1190
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1191 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
1192
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1193 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
1194 #### 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
1195 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
1196 [[ ! $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
1197
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1198 #### 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
1199 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
1200 [[ $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
1201 fi
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 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
1204 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
1205 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
1206 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
1207 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
1208 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
1209 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
1210 6:?:?) AUDIOPASS="-oac lavc -lavcopts acodec=ac3:abitrate=$abr" ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1211 7:?:?) AUDIOPASS="-oac $TOOLAME -${TOOLAME}opts br=$abr" ;;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1212 8:?:?) AUDIOPASS="-oac faac -faacopts ${acustom:-br=$abr}" ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1213 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
1214 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
1215 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
1216 6:?:?,*) AUDIOPASS="-oac lavc -lavcopts acodec=ac3:abitrate=${encode#*,}" ;;
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1217 7:?:?,*) AUDIOPASS="-oac $TOOLAME -${TOOLAME}opts br=${encode#*,}" ;;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1218 8:?:?,*) AUDIOPASS="-oac faac -faacopts ${acustom:-br=${encode#*,}}" ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1219 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1220 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
1221 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
1222 ?: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
1223 ?: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
1224 ?: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
1225 ?: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
1226 ?: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
1227 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1228 ((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
1229 PASS=${encode##*:}
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1230 [[ $normalize && $encode != 0:?:? ]] && af=${af:--af }${af:+,}volnorm
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1231 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1232
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1233
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1234 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1235 #### 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
1236 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1237 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
1238 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
1239 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
1240 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
1241 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
1242 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
1243 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
1244 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
1245 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
1246 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
1247 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
1248 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
1249 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
1250 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
1251 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1252 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
1253 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
1254 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1255 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
1256 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1257 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1258 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1259 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
1260 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
1261 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
1262 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
1263 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
1264 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
1265 while ((fint>=1024)) ; do
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1266 ((fint/1024 < 1024)) && ffrac=$((( fint+=51 )%1024))
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1267 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
1268 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
1269 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1270 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
1271 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
1272 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1273 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1274 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
1275 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
1276 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
1277 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1278 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1279 show_finalvideo_info () {
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1280 local codec TYPE i VIDEO OUT ASPECT CH FAAC SUBST
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1281 SUBST=
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1282 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
1283 if [[ ! $VIDEO ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1284 # MPEGs with MPEG-4 video do not show all the video informations in one line,
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1285 # 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
1286 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
1287 if echo "$OUT" | grep -q '^\[V].*fourcc:0x10000004' ; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1288 VIDEO="VIDEO: MPEG-4 $(echo "$OUT" | awk '$1=="VO:"&&$2=="[null]"{print $3}')"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1289 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
1290 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
1291 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
1292 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
1293 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
1294 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
1295 *) 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
1296 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1297 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
1298 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1299 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1300 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
1301 #### 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
1302 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
1303 echo -n " $1: AUDIO[$i]: " >>"$output".log
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1304 codec=$(mplayer -ac mp3, -nocache -frames 0 -v -ao null -vo null "$2" -aid $i 2>/dev/null | \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1305 sed '/Selected audio codec:/!d;s/[^(]*(//;s/).*//;s/AAC.*/& AAC/;s/.* //')
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1306 #### AAC info are insufficient/incorrect
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1307 if [[ $codec = AAC ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1308 CH=$(mplayer -nocache -frames 0 -v -ao null -vo null "$2" -aid $i 2>/dev/null | awk '/FAAD: Negotiated samplerate:/{print $NF}')
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1309 if type &>/dev/null faad ; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1310 mplayer -dumpaudio -dumpfile "$output".audio -aid $i "$2" 2>/dev/null
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1311 FAAC=$(faad -i "$output".audio 2>&1 | tail -2 | head -n 1)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1312 #ADTS, 4.087 sec, 103 kbps, 44100 Hz
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1313 rm -f "$output".audio
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1314 SUBST="s/AAC.*/AAC:$(echo "$FAAC" | sed 's/.*,\([^,]*Hz\).*/\1/'), "
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1315 SUBST="${SUBST}$CH ch, $(echo "$FAAC" | sed 's/,.*//'),"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1316 SUBST="${SUBST}$(echo "$FAAC" | sed 's/.*,\([^,]*kbps\).*/\1/')"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1317 SUBST="${SUBST}/;"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1318 else
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1319 SUBST="s/2 ch,/$CH ch,/;"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1320 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1321 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1322 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' | \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1323 grep -e '^AC3:' -e '^MPEG' -e '^AUDIO:' | sed 's/AUDIO/'"$codec"'/;'"$SUBST"'q' >>"$output".log
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1324 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1325 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
1326 shift
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1327 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
1328 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
1329 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1330 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1331 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1332 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
1333 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
1334 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1335 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1336 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
1337 EXIT=$?
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1338 status_bit mpg || [[ ! -f ${output}.mpg && ! -f ${output}01.mpg ]] || show_finalvideo_info "MPEG" "${output}"*.mpg
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1339 [[ $usesbr ]] && ((DEBUG && usesbr>6)) && awk -v u=$usesbr -v f=$fsize \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1340 'BEGIN{b=u*1024*1024;printf("--DEBUG: [usesbr] target: %dMB (%d bytes), error: %f%%\n",u,b,(b-f)*100/b)}' >>"$output".log
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1341 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
1342 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
1343 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
1344 ((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
1345 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
1346 echo
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1347 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1348 ((!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
1349 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1350 ((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
1351 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1352 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1353 me_log () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1354 rm -f "$output".fifo
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1355 mkfifo "$output".fifo
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1356 tee -a /dev/stderr <"$output".fifo | sed 's/.*\r//' | \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1357 awk '/^PSNR:|^M[EP][ln]|^There are |^\[open]|^audio stream:|^number of|^subtitle|^==> |^Recommended video bitrate/{sub(/^/," INFO: [mencoder] ");
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1358 print}' >>"$output".log &
17507
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 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1361 me_bit_log () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1362 rm -f "$output".fifo
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1363 mkfifo "$output".fifo
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1364 tee -a /dev/stderr <"$output".fifo | sed 's/.*\r//;/^Recommended video bitrate/!d;s/^/ INFO: [mencoder] /' >>"$output".log &
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1365 }
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 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
1368 # 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
1369 # 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
1370 # 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
1371 # 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
1372 # 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
1373 # 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
1374 # 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
1375 # 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
1376 # 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
1377 # 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
1378 # 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
1379 # 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
1380 # 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
1381 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
1382 ac3)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1383 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
1384 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
1385 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
1386 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
1387 *) 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
1388 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1389 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1390 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
1391 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
1392 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
1393 *) 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
1394 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1395 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1396 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
1397 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
1398 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
1399 *) 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
1400 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1401 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1402 *) 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
1403 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1404 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1405 mp3)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1406 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
1407 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
1408 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
1409 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
1410 *) 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
1411 esac
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 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
1414 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
1415 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
1416 *) 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
1417 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1418 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1419 *) 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
1420 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1421 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1422 mp2)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1423 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
1424 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
1425 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
1426 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
1427 *) 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
1428 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1429 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1430 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
1431 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
1432 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
1433 *) 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
1434 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1435 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1436 *) 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
1437 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1438 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1439 mp1)
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1440 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
1441 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
1442 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
1443 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
1444 *) 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
1445 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1446 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1447 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
1448 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
1449 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
1450 *) 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
1451 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1452 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1453 *) 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
1454 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1455 ;;
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1456 *) 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
1457 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1458 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1459 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1460 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
1461 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
1462 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1463 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1464 error_line () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1465 echo "--DEBUG: [$PROGNAME] $1"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1466 echo "**ERROR: [$PROGNAME] there has been an error during the execution of the previous line, this should not happen"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1467 echo "possible causes:"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1468 echo " 0) missing or misspelled input stream"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1469 echo " 1) the input stream is corrupted"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1470 echo " -> try a different input stream"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1471 echo " 2) one of the options used has triggered a bug present only on your combination of architecture/compiler/distribution"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1472 echo " -> try to recompile MPlayer with a different compiler version or try another distribution"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1473 if ((SVN)); then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1474 echo " 3) one of the options used is not valid or is buggy for your SVN/unsupported version of MPlayer/MEncoder"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1475 echo " -> check MPlayer's man page and/or try a supported release of MPlayer"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1476 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1477 echo
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1478 echo "submit a bugreport if you think this is a bug in $PROGNAME"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1479 exit $ret
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1480 }
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1481 ###############################################################################
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1482 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
1483 local codec lib ASR
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1484 codec=([4]=mp2 mp3 ac3 mp2 aac)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1485 lib=([4]=libavcodec libavcodec libavcodec lib${TOOLAME} libfaac)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1486 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
1487 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
1488 }
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1489 ###############################################################################
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1490 is_film2pal () {
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1491 local a
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1492 a=$(mplayer -nocache "$@" -vo null -nosound -benchmark -frames 60 -noquiet 2>/dev/null | tr '\015' '\012' | tail | \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1493 awk -F/ '$1~/^V:/{s=$1;t=$2}END{match(s,/ [0-9]+$/);n=substr(s,RSTART+1);match(t,/[0-9]+ /);m=substr(t,1,RLENGTH-1);r=n/m;if(r>1.02)print "24"}')
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1494 [[ $a ]] && a=$(mplayer -nocache "$@" -vo null -nosound -benchmark -frames 1500 -noquiet 2>/dev/null | tr '\015' '\012' | tail | \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1495 awk -F/ '$1~/^V:/{s=$1;t=$2}END{match(s,/ [0-9]+$/);n=substr(s,RSTART+1);match(t,/[0-9]+ /);m=substr(t,1,RLENGTH-1);r=n/m;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1496 if(r>1.042)print "24000/1001fps";if(r<1.042&&r>1.041)print "24fps"}')
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1497 echo "$a"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1498 }
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1499
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1500 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1501 #### 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
1502 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1503 #### 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
1504 #### 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
1505 #### 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
1506 #### no check is done on the other channel in case of multiaudio
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1507 if [[ $encode == [2-8]:?:? ]]; then
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1508 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
1509 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
1510 else
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1511 r=$(id_find ID_AUDIO_RATE "${MPLAYERINFO[@]}")
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1512 if [[ ! $r ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1513 do_log "++ WARN: [$PROGNAME] failure to detect the audio sample rate of the input stream"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1514 [[ ! $multiaudio && ! $audioid ]] && do_log "++ WARN: [$PROGNAME] if your source video does not have audio use -encode 0:${encode#*:}" || \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1515 do_log "++ WARN: [$PROGNAME] probably is incorrect the audio stream selected with -${audioid:+aid}${multiaudio:+multiaudio}"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1516 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1517 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
1518 case $frameformat in
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1519 *VCD) ((r != 44100)) && do_log "++ WARN: [$PROGNAME] $frameformat standard requires 44100kHz audio, add -srate 44100" ;;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1520 DVD) ((r != 48000)) && do_log "++ WARN: [$PROGNAME] $frameformat standard requires 48000kHz audio, add -srate 48000" ;;
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1521 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1522 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1523 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1524 if [[ $encode == [4-7]:?:? ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1525 check_mencoder_abr "$r" ${AUDIOPASS##*=}
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1526 elif [[ $encode == 8:?:? ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1527 case $r in
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1528 8000|11025|12000|16000|22050|24000|32000|44100|48000|64000|88200|96000) : ;;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1529 *) echo "**ERROR: [$PROGNAME] libfaac does not support $r Hz sample rate" ; exit 1 ;;
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1530 esac
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1531 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1532 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
1533 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
1534 *) 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
1535 esac
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1536 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1537 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1538 #### copy of non-MPEG audio in a VCD
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1539 if [[ $step -gt 1 && $frameformat = VCD && $encode == 0:?:? && ( $mpeg || ${!audioformat} = copy ) && ! $testmca && ! $pictsrc ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1540 a=$(id_find ID_AUDIO_CODEC "${MPLAYERINFO[@]}")
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1541 [[ $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
1542 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1543 #### mpegchannels > 2 only with ac3 and aac
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1544 [[ $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
1545 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
1546 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1547 #### 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
1548 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1549 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
1550 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
1551
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1552 skip=0
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1553 LG=1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1554
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1555 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1556 #### 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
1557 ###############################################################################
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 [[ ! $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
1559 { 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
1560 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
1561 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1562 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
1563 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
1564 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1565 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
1566 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
1567 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
1568 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1569 if [[ $mpeg ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1570 [[ $testmca ]] && echo -n "Testmca Mode" || echo -n "MPEG Mode"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1571 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1572 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1573 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
1574 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
1575 } >"$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
1576 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1577
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1578 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1579 #### 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
1580 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1581 #### WARN
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1582 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
1583 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
1584 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1585 #### 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
1586 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
1587 [[ $encode == 0:?:? && ( ${!audioformat} = copy || $step -eq 1 || $mpeg ) || ${!audioformat} = copy && ! $encode ]] && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1588 do_log "++ WARN: [$PROGNAME] you cannot modify the volume of the output audio stream if you are making a copy the input audio stream"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1589 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1590 #### 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
1591 if [[ $cpu && $bframes ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1592 ((bframes)) && do_log "++ WARN: [$PROGNAME] with bframes>0 the encoding will be faster with cpu=1"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1593 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1594 #### -usespeed
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 [[ $usespeed && ( $encode == 0:?:? || $encode == ?:0:? ) ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1596 do_log "++ WARN: [$PROGNAME] -usespeed may not work if you do not encode both audio and video." && echo -n "Press return to proceed" && read
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1597 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1598 #### 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
1599 [[ $encode != ?:0:? ]] && ((step>1&&abr*audiostream*1024/1000+vbr>MAXBR)) && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1600 do_log "++ WARN: [$PROGNAME] total video+audio bitrate ($vbr+$((abr*audiostream*1024/1000))kbps) exceed $frameformat specifications (${MAXBR}kbps)"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1601 #### -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
1602 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
1603 ((${#PICTSRC[*]}!=1||$(ls ${PICTSRC[0]} | wc -l)!=1)) && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1604 do_log "++ WARN: [$PROGNAME] you should use only one source image if you use the option -slideaudio"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1605 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1606
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1607 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1608 #### 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
1609 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1610 { 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
1611 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
1612 [[ $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
1613 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
1614 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
1615 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
1616 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1617 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
1618 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
1619 [[ $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
1620 [[ $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
1621 [[ $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
1622 echo
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1623 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
1624 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
1625 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
1626 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
1627 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
1628 done
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 ((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
1630 [[ $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
1631 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1632 txt=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1633 [[ $(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
1634 [[ ${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
1635 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
1636 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
1637 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1638 [[ ! $resume ]] && { [[ $audioonly ]] && mp_identify "$audioonly" || mp_identify "${MPLAYERINFO[@]}" -frames 1 ; } | \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1639 sed -n '/^ID_/s/^/ INFO: [identify] /p' | uniq
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1640 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
1641 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
1642 for ((i=0;i<${#VARS[*]};i++)) ; do
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1643 s="INFO: \[${VARS[i]}] \${${VARS[i]}[*]}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1644 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
1645 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1646 } >>"$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
1647 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
1648 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
1649 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
1650 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
1651 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
1652 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
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 [[ $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
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 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1657 #### 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
1658 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1659 if [[ $volume ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1660 volume=$(awk -v a=$volume 'BEGIN{if(a>0) print 20*log(a)/log(10) ; else print 0}')
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1661 af=${af:--af }${af:+,}volume=$volume
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1662 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1663
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1664 [[ ${mver:0:5} = 1.0rc ]] || SVN=1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1665
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1666 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1667 #### telecined (NTSC/PAL) MPEG copy/speed encoding change
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1668 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1669 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
1670 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
1671 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
1672 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
1673 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
1674 if [[ ${FPS[0]} != ${FPS[i]} ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1675 do_log "++ WARN: [$PROGNAME] input video frame rate is not exactly ${FPS[i]}fps"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1676 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
1677 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1678 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
1679 break
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1680 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1681 done
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1682 [[ $usespeed && $i -eq 9 ]] && do_log "++ WARN: [$PROGNAME] input video frame rate is not a valid NTSC/PAL value; disabling -usespeed" && usespeed=
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1683
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1684 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
1685 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
1686 [[ ${FPS[9]} = 24fps || ${FPS[9]} = 24000/1001fps ]] && FPS[10]=$((FPS[10]-3))
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1687 elif [[ ${FPS[0]} = ${FPS[3]} ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1688 FPS[9]=$(is_film2pal "${MPLAYERINFO[@]}")
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1689 if [[ ${FPS[9]} ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1690 [[ ${FPS[9]} = 24fps ]] && FPS[10]=2 || FPS[10]=1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1691 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1692 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1693 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
1694 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
1695 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
1696 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
1697 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
1698 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
1699 #### 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
1700 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
1701 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
1702 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1703 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
1704 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
1705 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1706 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
1707 MPLAYERYUVOPT=("${MPLAYERYUVOPT[@]}" -speed $a )
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1708 do_log " INFO: [usespeed] using speed factor $a"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1709 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1710 elif [[ ${FPS[0]} = ${FPS[4]} || ${FPS[0]} = ${FPS[5]} || ${FPS[0]} = ${FPS[3]} ]]; then
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1711 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
1712 { 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
1713 [[ ${FPS[9]} = 24fps || ${FPS[9]} = 24000/1001fps ]] && echo -n "detected" || echo -n "user selected"
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1714 [[ ${FPS[0]} = ${FPS[3]} ]] && echo -n " PAL" || echo -n " NTSC"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1715 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
1716 } | tee -a "$output".log
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1717 [[ ${FPS[10]} = 1 ]] && MENCODERARG=( "${MENCODERARG[@]}" -ofps 24000/1001 -mc 0 ) || MENCODERARG=( "${MENCODERARG[@]}" -ofps 24 -mc 0 )
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1718 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1719 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1720 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1721
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1722 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1723 #### 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
1724 #### 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
1725 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1726 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
1727 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
1728 [[ ${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
1729 [[ $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
1730 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
1731 ko=(1-o/100)
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1732 if(a==1.78||a==1.74)a=16/9
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1733 if(a==1.33||a==1.30)a=4/3
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1734 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
1735 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
1736 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
1737 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
1738 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
1739 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
1740 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
1741 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1742 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
1743 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
1744 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
1745 }else{
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1746 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
1747 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
1748 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1749 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
1750 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
1751 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
1752 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
1753 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
1754 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
1755 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
1756 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
1757 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
1758 }else{
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1759 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
1760 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
1761 }
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(r!=""){
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1763 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
1764 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
1765 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1766 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
1767 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
1768 }')
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1769 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
1770 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
1771 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
1772 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
1773 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1774 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1775 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1776 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1777
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1778 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1779 #### warn for aspect ratio
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1780 ###############################################################################
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1781 if [[ ( $mpeg && $encode != ?:0:? || ! $mpeg && $step -gt 1 ) && ! $mpegfixaspect && ${#TITLESET[*]} -eq 0 && ! $testmca ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1782 a=$(get_aspect "${MPLAYERINFO[@]}")
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1783 [[ ${mpegaspect:-2} = 2 && $a != 1.33 && $a != 1.30 || ${mpegaspect:-2} = 3 && $a != 1.78 && $a != 1.74 || ${mpegaspect:-2} = 4 && $a != 2.21 ]] && \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1784 do_log "++ WARN: [$PROGNAME] selected aspect ratio [${ASPECT[${mpegaspect:-2}]}] and source aspect ratio [$a] are different"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1785 fi
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1786
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1787 ###############################################################################
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1788 #### 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
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 #### 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
1791 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
1792 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
1793 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
1794 SID=(-sid ${encsid[idx]} -vobsuboutindex ${encsdx[idx]} ${encsla:+-vobsuboutid ${encsla[idx]}} -vobsubout "$output")
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1795 do_log " INFO: [$PROGNAME] dumping subtitle ${encsid[idx]} to vobsub ${encsdx[idx]}${encsla:+ (${encsla[idx]})}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1796 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
1797 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1798 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
1799 fi
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 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1802 #### 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
1803 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
1804 (( ${#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
1805 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
1806 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
1807 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
1808 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1809 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
1810 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1811 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
1812
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1813 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1814 #### 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
1815 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1816 IDACOD=$(grep "ID_AUDIO_CODEC" "$output".log | tail -1 | cut -f2 -d=)
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1817 [[ $IDACOD = hwdts ]] && echo "**ERROR: [$PROGNAME] dts audio support missing in MPlayer" && \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1818 echo "**ERROR: add dts support (libdts-0.0.2.tar.gz) or select a non dts stream" && \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1819 echo "**ERROR: example: -aid 128 (ac3), -aid 160 (lpcm), -aid 0 (mpeg)" && exit 1
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1820 [[ $mpeg && ! $pictsrc && ( $encode == 1:?:? || $multiaudio || $encode == 0:?:? && $IDACOD != mp3 && $IDACOD != a52 && $IDACOD != faad ) ]] && extra=1 || \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1821 extra=
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1822 [[ $extra ]] && do_log "**ERROR: [$PROGNAME] output stream: unsupported audio codec $IDACOD" && exit 1
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1823
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1824 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
1825
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1826 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1827 #### AVI/MPEG section
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1828 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1829 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
1830 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
1831 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
1832 local kv k ka
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1833 sleep 2
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1834 [[ $mpeg ]] && kv=9888 k=33 ka=1015 || kv=10000 k=0 ka=1011
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1835 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
1836 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
1837 [[ $sbr ]] && ((sbr<vbitrate)) && VIDEOPASS=${VIDEOPASS/vbitrate=$vbitrate:/vbitrate=$sbr:} && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1838 do_log " INFO: [mencoder] using vbitrate=$sbr"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1839 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1840 #### 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
1841 #### 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
1842 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
1843 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
1844 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
1845 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
1846 [[ ${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
1847 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
1848 [[ ${sbr[4]} ]] && ((sbr[4]<vbitrate && sbr[4]>0)) && VIDEOPASS=${VIDEOPASS/vbitrate=$vbitrate:/vbitrate=${sbr[4]}:} && \
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1849 do_log " INFO: [mencoder] using vbitrate=${sbr[4]}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1850 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1851 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1852 AID=
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1853 if [[ ! $extra ]]; then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1854 RAWVIDEO=( -o "$output".$SUF )
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1855 fi
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1856 #### 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
1857 PLOG=( -passlogfile "$output".avi2pass.log )
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1858 MSG=( -msglevel open=6:demuxer=6:demux=6 )
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1859 rm -f frameno.avi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1860 [[ $encode == 0:?:? && ! $extra ]] && F= || F=$af
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1861 if [[ $usesbr && ! $extra ]]; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1862 ((DEBUG)) && debug_line $((LINENO+2)) "usesbr "
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1863 me_bit_log
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1864 mencoder $OPTIONS -ovc frameno -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F &>"$output".fifo
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1865 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
1866 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
1867 fi
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1868 if ((PASS==1)); then
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1869 ((DEBUG)) && debug_line $((LINENO+2)) "PASS 1/$PASS"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1870 me_log
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1871 mencoder $OPTIONS $VIDEOPASS "${RAWVIDEO[@]}" "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F "${MSG[@]}" >"$output".fifo
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1872 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
1873 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1874 #### 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
1875 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
1876 ((DEBUG)) && debug_line $((LINENO+1)) "PASS 1/$PASS"
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1877 mencoder $OPTIONS ${VIDEOPASS}:vpass=1$turbo -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F "${PLOG[@]}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1878 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
1879 if ((PASS==2)); then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1880 ((DEBUG)) && debug_line $((LINENO+2)) "PASS 2/$PASS"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1881 me_log
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1882 mencoder $OPTIONS ${VIDEOPASS}:vpass=2 "${RAWVIDEO[@]}" "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F "${PLOG[@]}" "${MSG[@]}" \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1883 >"$output".fifo
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1884 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
1885 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1886 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
1887 ((DEBUG)) && debug_line $((LINENO+1)) "PASS $a/$PASS"
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1888 mencoder $OPTIONS ${VIDEOPASS}:vpass=3 -o /dev/null "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F "${PLOG[@]}"
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1889 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
1890 done
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1891 ((DEBUG)) && debug_line $((LINENO+2)) "PASS $PASS/$PASS"
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1892 me_log
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1893 mencoder $OPTIONS ${VIDEOPASS}:vpass=3 "${RAWVIDEO[@]}" "${SID[@]}" "${MENCODERARG[@]}" $AID $AUDIOPASS $F "${PLOG[@]}" "${MSG[@]}" \
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1894 >"$output".fifo
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1895 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
1896 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1897 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1898 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
1899 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1900 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1901
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1902 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1903 #### 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
1904 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1905 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
1906 ((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
1907 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
1908 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
1909 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1910 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
1911 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
1912 #### 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
1913 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
1914 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
1915 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
1916 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
1917 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
1918 # 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
1919 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
1920 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
1921 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
1922 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
1923 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
1924 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
1925 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
1926 # .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
1927 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
1928 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
1929 id="";
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1930 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
1931 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
1932 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
1933 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
1934 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
1935 }
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1936 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
1937 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
1938 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1939 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1940
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1941 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1942 #### 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
1943 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1944 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
1945 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
1946 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
1947 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
1948 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
1949 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
1950 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
1951 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
1952 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1953 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1954 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1955
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1956 ###############################################################################
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1957 #### split the MPEG stream (for MPEG Mode)
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1958 ###############################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1959 if status_bit spl ; then
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1960 #### split for MPEG Mode (MPEG-4 codec not supported)
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1961 #### MEncoder does not support split as does mpeg2enc/mplex
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1962 #### 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
1963 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
1964 [[ ! $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
1965 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
1966 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
1967 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
1968 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
1969 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
1970 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
1971 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
1972 #### 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
1973 [[ $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
1974 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
1975 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
1976 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
1977 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
1978 tr '\015' '\012' | awk '{if($1=="I!"){print t;exit};t=$2}')
20858
4e8dbc741909 update to 0.6.2, patch by Giacomo Comes, comes naic edu
diego
parents: 19614
diff changeset
1979 n=$(awk '/^'"$n"'/{print $2-1;exit}' <"$output".framelist) #should be -2
17507
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1980 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1981 n=
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1982 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1983 ((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
1984 "$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
1985 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
1986 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
1987 done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1988 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
1989 else
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1990 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
1991 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1992 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
1993 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1994 fi
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1995
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1996 ################################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1997 #### done
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1998 ################################################################################
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
1999 exit
c658a7107209 new tool to encode to mpeg using only mencoder; patch by Giacomo Comes <comes ad naic punctum edu>
nicodvb
parents:
diff changeset
2000