1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

TOOLS: Remove most of the mencoder scripts and references

This commit is contained in:
Clément Bœsch 2011-01-21 01:55:40 +01:00 committed by Uoti Urpala
parent 69fdb30400
commit 3a7b071517
7 changed files with 5 additions and 1467 deletions

View File

@ -5,8 +5,7 @@ Preamble
--------
In this directory you can find some nice scripts and code that makes
using MPlayer and MEncoder easier, for example scripts for DVD track
encoding in three pass mode or creating SVCDs from a movie.
using MPlayer easier.
FIXME: Document the following tools:
@ -86,93 +85,6 @@ Usage: wma2ogg [options] <-f FILE1 | -f FILE2 ... | -a>
-del remove WMA file(s) after the transcoding
MEncoder scripts in the TOOLS dir
---------------------------------
divx2svcd.sh
Author: Miklos Vajna
Description: A simple utility that creates an SVCD from a video in an AVI
container.
Usage: divx2svcd.sh <input_avi> [options]
see 'divx2svcd.sh -h' for more info
mencvcd.sh
Author: Jürgen Hammelmann
Description: Converts DVD (or anything else that MPlayer plays) to (S)VCD
Usage: mencvcd.sh <basename> [mencvcd.sh options] [mplayer options]
see 'mencvcd.sh -h' for more info
Note: Requires MPlayer, mjpegtools, VCDImager, cdrdao, and optionally
LAME, tooLAME and SoX.
dvd2divxscript.pl
Author: Florian Schilhabel
Description: Yet another DVD to divx helper script.
This script encodes a DVD track in three pass mode to MPEG-4 with
libavcodec. Optionally it writes the resulting movie file to
CD-ROM the corresponding audio track to MP3. It can also shut
down the computer when it finishes. If you like, you can
watch the MEncoder output on /dev/tty8.
Usage: --help show help
--abr (AudioBitRate) Please enter the desired bitrate this
can be either [96|128|192] kbit/sec (default: 128).
--lang Specify the Language of the audio track this can be
for example <en> or <de> (default: <de>).
--dvd Specify the DVD track you want to encode.
--cdsize Specify the size of your CD-ROM (default: 700MB).
--shutdown Shutdown the system, when the encoding process has
finished. Needs appropriate privileges.
--out Specify the name of your encoded movie. The file
extension will be appended automatically.
--writecd Takes the newly created movie and writes it to a
CD-ROM.
--writedev cdrecord device identifier, for example 0,1,0
--speed writing speed (default: 4)
--dvd-device device to pull the video off (default: /dev/dvd)
aconvert.sh
Author: Jonas Jermann
Description: A hack to allow MEncoder to read respectively encode from audio
only files.
Usage: aconvert.sh <"input file"> <"output file"> <"options">
If no options are specified the following is assumed:
-oac lavc -lavcopts acodec=mp3:abitrate=192
Note: The script is probably bash dependent and it's just a quick
hack, feel free to improve it (or much better: fix MEncoder ;).
qepdvcd.sh
Author: Reynaldo H. Verdejo Pinochet
Description: converter from any supported format to VCD/SVCD PAL/NTSC
Usage: qepdvcd.sh file <options>
Run with no arguments to see the list of options.
Note: You will need vcdimager/cdrecord to master/burn the resulting
files.
Tech scripts in the TOOLS dir
-----------------------------
@ -302,8 +214,8 @@ Description: A simple tool to fix chunk sizes in RIFF AVI files.
Usage: avi-fix [-fix] <badfile.avi>
Note: It does not check or fix the index, to do this use
'mencoder -forceidx -oac copy -ovc copy'.
Note: It does not check or fix the index. You can try to fix it with
ffmpeg -i ... -acodec copy -vcodec copy.
checktree.sh

View File

@ -1,13 +0,0 @@
#!/bin/sh
# Author: Jonas Jermann
# Description: A hack to allow mencoder to encode from an audio only file
if [ "$1" = "" ]; then
echo "Usage: $0 <\"input file\"> <\"output file\"> <\"options\">"
exit 0
fi
options=${3:-"-oac mp3lame"}
mencoder -demuxer rawvideo -rawvideo w=1:h=1 -ovc copy -of rawaudio -endpos `mplayer -identify $1 -frames 0 2>&1 | grep ID_LENGTH | cut -d "=" -f 2` -audiofile $1 -o $2 $options $1

View File

@ -1,6 +1,7 @@
/* avi-fix v0.1 (C) A'rpi
* simple tool to fix chunk sizes in a RIFF AVI file
* it doesn't check/fix index, use mencoder -forceidx -oac copy -ovc copy to fix index!
* it doesn't check/fix index. You can try to fix it with ffmpeg -i ... -acodec
* copy -vcodec copy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,369 +0,0 @@
#!/bin/bash
# (c) 2003 Vajna Miklos <mainroot@freemail.hu>
# divx2svcd for MPlayer
# distributed under GPL License
# simple utility that creates a SVCD from a video in an AVI container
# The newest version of this utility can be found at
# http://vmiklos.uw.hu/divx2svcd/divx2svcd
# MPlayer available at
# http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre3try2.tar.bz2
###changelog###
#nobody cares about it :-)
cat >/dev/null <<EOF
0.5.1
- faster code by not re-mplexing one-cd-size or smaller videos
0.5.0
- needless for dumpvideo patch ;-)
0.4.9
- changed default bitrate to 1600 for better quality
- fix for burning more than one cd
- fix for wrong parameter help
0.4.8
- small fixes
0.4.7
- fixed bug, when there is no sub available
0.4.6
- support for burning the svcd with cdrecord
- lots of paranoid options for better quality from Denes Balatoni
0.4.5
- support for filenames including spaces
0.4.4
- support for checking all applications this script uses
- this changelog
0.4.3
- advanced detectation of movie aspect (mpeg4 codec, mpeg container)
0.4.2
- advanced vf options for movies with non-standard aspect
0.4.1
- checking for available sub
0.4.0
- support for tcmplex-panteltje
- support for libavcodec audio encoder
0.3.1-0.3.2
- small fixes
0.3
- almost totally rewritten from scratch
based on the idea of Denes Balatoni <pnis@coder.hu>
- support for toolame instead of mp2enc
- suppert for libavcodec mpeg2video codec instead of mpeg2enc
0.2
- support for tcmplex instead of mplex
0.1rc2-rc4
- small bugfixes
0.1rc1
- initial release
EOF
###preparing###
#help
usage()
{
cat <<EOF
Usage: `basename $0` input_avi [options]
Options:
-b|--bitrate xx bitrate of mp2 video stream [1375]
-s|--cdsize xx size of the cd we split the video to [795]
-w|--writecd enables burning [disable]
-d|--device xx scsi cd-recording device if you are using linux 2.4.x [0,0,0]
-c|--clean clean up svcd images you just created
-h|--help this help screen
EOF
}
#initializating constants
version='0.5.1'
bitrate=1375
cdsize=795
burning=0
cleaning=0
dev4='0,0,0'
firstcd=1
#paranoid options
paraopts='vrc_override=1,10,708:vqcomp=0.1:vratetol=10000000:vrc_buf_size=917:vrc_maxrate=2500:intra_matrix=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,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:inter_matrix=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,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'
#header
echo "DivX2SvcD $version (C) 2003-2004 Vajna Miklos"
echo
#checking for ls
ls=`which ls`
#checking for bc
which bc >/dev/null 2>&1
bcbin=`which bc 2>/dev/null`
if [ $? != 0 ]; then
cat <<EOF
ERROR: Can't find bc. You can download it at
ftp://ftp.ibiblio.org/pub/gnu/bc/bc-1.06.tar.gz
EOF
exit 1
fi
#checking for vcdimager
which vcdimager >/dev/null 2>&1
bcbin=`which vcdimager 2>/dev/null`
if [ $? != 0 ]; then
cat <<EOF
ERROR: Can't find vcdimager. You can download it at http://www.vcdimager.org
/pub/vcdimager/vcdimager-0.7_UNSTABLE/vcdimager-0.7.14.tar.gz
EOF
exit 1
fi
#checking which mplex utility we have to use
which tcmplex-panteltje >/dev/null 2>&1
if [ $? = 0 ]; then
tcp_path=`which tcmplex-panteltje 2>&1`
else
tcp_path="x"
fi
which tcmplex >/dev/null 2>&1
if [ $? = 0 ]; then
tc_path=`which tcmplex 2>&1`
else
tc_path="x"
fi
if [ -x $tcp_path ]; then
tcbin=tcmplex-panteltje
tcopt=-0
elif [ -x $tc_path ]; then
tcbin=tcmplex
tcopt=-p
else
cat <<EOF
ERROR: Can't find any sutable mplex utility. You can download
tcmplex-panteltje at http://sunsite.rediris.es/
sites2/ibiblio.org/linux/apps/video/tcmplex-panteltje-0.3.tgz
EOF
exit 1
fi
#pharsing parameters
if [ $# -le 0 ]; then
echo "Missing parameter!"
usage
exit 1
fi
case $1 in
-h)
usage
exit 1
;;
-*)
echo "Missing parameter!"
usage
exit 1
;;
*)
input=`echo $1 |sed 's/\\ / /'`
if [ "$input" = "`basename "$input"`" ]; then
input="`pwd`/$1"
fi
nev=`basename "$input" .avi`
shift 1
;;
esac
while [ "$1"x != "x" ]; do
case $1 in
-b|--bitrate)
bitrate=$2
shift 1
;;
-s|--cdsize)
cdsize="$2"
shift 1
;;
-d|--device)
dev4="$2"
shift 1
;;
-w|--write)
burning=1
;;
-c|--clean)
cleaning=1
;;
-h|--help)
usage
exit 0
;;
esac
shift 1
done
#checking for cd-recording device
if [ "$burning" = 1 ]; then
echo -n "Searching for cdrecorder device... "
if [ `uname -r |cut -d '.' -f 2` = 4 ]; then
#linux 2.4.x
dev="dev=$dev4"
echo "$dev4"
elif [ `uname -r |cut -d '.' -f 2` = 6 ]; then
#linux 2.6.x
if [ -e /dev/cdrecorder ]; then
dev='dev=/dev/cdrecorder'
echo "/dev/cdrecorder"
else
cat <<EOF
ERROR: Device file /dev/cdrecorder not found. Please link your
cd-recording device to /dev/cdrecorder!
Example: 'cd /dev; ln -s hdc cdrecorder'
EOF
exit 1
fi
else
cat <<EOF
ERROR: Linux 2.4 or 2.6 series not found. You can download it at
http://www.kernel.org/ ;-)
EOF
exit 1
fi
#checking for cdrecord
which cdrecord >/dev/null 2>&1
cdrbin=`which cdrecord 2>/dev/null`
if [ $? != 0 ]; then
cat <<EOF
ERROR: Can't find cdrecord. You can download it at
ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-2.01a20.tar.gz
EOF
exit 1
else #checking for version >= 2.01a14
echo -n "Checking for cdrecord version >= 2.01a14... "
$cdrbin cuefile=a 2>&1 |grep 'Bad Option' >/dev/null 2>&1
if [ "$?" = 0 ]; then
cat <<EOF
ERROR: Can't find cdrecord version >= 2.01a14. You can download it at
ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-2.01a20.tar.gz
EOF
else
echo "`$cdrbin -version |cut -d ' ' -f 2`"
fi
fi
fi
#checking for sub avariable
if [ -f "$nev.sub" ]; then
subopts=$nev.sub
else
subopts=''
fi
if [ "x$subopts" = "x" ]; then
subs=''
else
subs='-sub '
fi
#checking for what height needed
inputwidth=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 1`
inputheight=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 2`
svcdaspect=`echo -e "scale=10\n1.596/($inputwidth/$inputheight)"|bc /dev/stdin`
height=`echo -e "scale=10\n$svcdaspect*480"|bc /dev/stdin|cut -d . -f 1`
#checking for ratios less than 1.33
istoohigh=`expr $height \> 577`
if [ "$istoohigh" = 1 ]; then
height=576
fi
#find out the vf options
if [ "$height" = 576 ]; then
vfopts='-vf scale=480:576'
else
#-vf processes filters in reverse order
exy=`echo -e "scale=10\n(576-$height)/2"|bc /dev/stdin|cut -d . -f 1`
vfopts="-vf scale=480:$height,expand=480:576:0:$exy:1"
echo "Using filter options: '$vfopts'"
fi
#finish displaying informations
if [ "$burning" = 1 ]; then
#asking for cd
cat <<EOF
Please insert a blank cd in your cdwriter.
(If you are using a rewritable media,
don't forgot to blank it before using divx2svcd.)
Press any key when your are ready.
EOF
read -n 1 i
fi
###start working###
#encoding
mencoder -ofps 25 -oac lavc "$input" -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=$bitrate:acodec=mp2:abitrate=128:keyint=25:aspect=4/3:$paraopts -o "${nev}2.avi" -srate 44100 -of mpeg -channels 2 $vfopts $subs "$subopts"
videosize=`$ls -l "${nev}2.avi"|tr -s ' '|cut -d ' ' -f5`
if ! [ `echo $(( $cdsize*1048576 < $videosize ))` = "1" ]; then
#video is smaller, than $cdsize
mv ${nev}2.avi ${nev}00.mpg
else
#splitting
mplayer -dumpvideo -dumpfile "$nev.m2v" "${nev}2.avi"
mplayer -dumpaudio -dumpfile "$nev.mp2" "${nev}2.avi"
rm "${nev}2.avi"
echo "maxFileSize = $cdsize" > template
$tcbin -i "$nev.m2v" $tcopt "$nev.mp2" -o "$nev.mpg" -m s -F template
rm template
rm "$nev.m2v" "$nev.mp2"
fi
for i in *mpg
do
nev2=`basename "$i" .mpg`
#creating images
vcdimager -t svcd -c "$nev2.cue" -b "$nev2.bin" "$i"
#burning if needs
if [ "$burning" = 1 ]; then
if [ "$firstcd" != 1 ]; then
cat <<EOF
Please insert an another blank cd in your cdwriter.
Press any key when your are ready.
EOF
read -n 1 i
else
firstcd=2
fi
$cdrbin -v -dao $dev speed=12 gracetime=2 driveropts=burnfree -eject cuefile="$nev2.cue"
fi
#cleaning if needs
if [ "$cleaning" = 1 ]; then
rm -f "$nev2.cue" "$nev2.bin"
fi
done
rm -f "$nev"*mpg

View File

@ -1,256 +0,0 @@
#!/usr/bin/perl
#
# (c) 2002-2004 by Florian Schilhabel <florian.schilhabel@web.de>
#
#
# version 0.1 initial release 22/08/2002
#
#
# If you have any comments, suggestions, etc., feel free to send me a mail ;-))
# flames and other things like that should go to /dev/null
# thankx to all the mplayer developers for this really *great* piece of software
#
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
#
use Getopt::Long;
# specify your default Settings here...
$abr_default = 128; # The default AudioBitRate
$lang_default = "de"; # ... the language
$cdsize_default = 700; # ... the CD-Rom Size
$writedev_default = "0,1,0"; # ... the CD Writer Device
$speed_default = 4; # ... the writer speed
$dvd_device = "/dev/dvd"; # and the DVD Rom Device
# end of default Settings
sub delete_tempfiles {
if (open(FILE, "< audio.stderr")) {
close (FILE);
system ("rm audio.stderr")
}
if (open(FILE, "< frameno.avi")) {
close (FILE);
system ("rm frameno.avi");
}
if (open(FILE, "< lavc_stats.txt")) {
close (FILE);
system ("rm lavc_stats.txt");
}
}
GetOptions( "help" => \$help,
"abr=i" => \$abr,
"lang=s" =>\$lang,
"cdsize=i" => \$cdsize,
"dvd=i" => \$dvd_track,
"keeptemp" => \$keeptemp,
"shutdown" => \$shutdown,
"out=s" => \$output,
"writecd" => \$writecd,
"writedev=s" => \$writedev,
"speed=i" => \$speed,
"dvd-device=s" => \$dvd_device );
if ($help) {
print "Welcome to the DVD to DIVX Helper Script\n";
print "\n";
print "this script encodes a DVD track in 3-pass mode to libavcodec's mpeg4\n";
print "Optionally it writes the resulting MovieFile to a CD-Rom\n";
print "as well as the corresponding audio track to mp3\n";
print "Optionally it writes the resulting MovieFile to a CD-Rom\n";
print "and shuts down the Computer.\n";
print "If you like, you can watch the mencoder output on /dev/tty8\n";
print "Usage:\n";
print "--help show this text\n";
print "--abr (AudioBitRate) Please enter the desired bitrate\n";
print " this can be either [96|128|192] kbit/sec.\n";
print " Default: 128 kbit/sec.\n";
print "--lang specify the Language of the audio track\n";
print " this can be for example <en> or <de>\n";
print " Default: <de>\n";
print "--dvd specify the DVD Track, you want to encode\n";
print "--cdsize specify the Size of your CD-ROM\n";
print " Default: 700MB\n";
print "--shutdown Shutdown the System, when the encoding process has finished\n";
print " this will only be possible if you are root\n";
print "--out Specify the Name of your encoded Movie\n";
print " The File Extension will be appended automatically\n";
print "--writecd takes the newly created Movie and writes it to a CD-Rom\n";
print "--writedev is the usual cdrecord device identifier\n";
print " for example 0,1,0\n";
print "--speed the writing speed\n";
print " Default: 4\n";
print "--dvd-device device to pull the video off\n";
print " Default: /dev/dvd\n";
exit;
}
delete_tempfiles();
# testing user values && set defaults...
if ($abr == 96){}
elsif ($abr == 128) {}
elsif ($abr == 192) {}
elsif ($abr == 0 ) {
print "No AudioBitRate specified - Setting to Default Value\n";
$abr = $abr_default;
}
else {
print "AudioBitRate not valid. please choose [96|128|192]\n";
exit;
}
if ($lang eq "") {
print "No Language specified - Setting to Default Value\n";
$lang = $lang_default;
}
else {}
if ($dvd_track == 0 ) {
print "No DVD Track selected - You must specify one with: --dvd trackno.\n";
exit;
}
if ($cdsize == 650) {}
elsif ($cdsize == 700) {}
elsif ($cdsize == 800) {}
elsif ($cdsize == 0 ) {
print "No CD Size Specified - Setting to Default Value\n";
$cdsize = $cdsize_default;
}
else {
print "CD Size not valid. please choose [650|700|800]\n";
exit;
}
if ($output eq "") {
print "No MovieName given - You must specify one with: --out [movie_name]\n";
exit;
}
else {
($name, $extension) = split(/./, $out);
if ($extension eq "avi") {
$vob_tempfile = "$name.vob";
$avi_filename = "$output";
}
else {
$vob_tempfile = "$output.vob";
print "VOB CacheFile set to $vob_tempfile\n";
$avi_filename = "$output.avi";
print "Movie Filename set to $avi_filename\n";
}
}
if ($shutdown) {
# test who i am
$user = `id -u`;
if ($user == 0) {
print "System will be shut down after Movie encoding\n";
}
else {
print "Cannot shutdown the system after Movie encoding - you are not 'root'\n";
exit;
}
}
if ($writecd) {
if ($writedev == "") {
print "Setting CD Writer Device to Default Value\n";
$writedev = $writedev_default;
}
if ($speed == 0) {
print "Setting CD Writer Speed to Default value\n";
$speed = $speed_default;
}
}
###
print "Your Settings for this run are:\n";
print "AudioBitRate: $abr\n";
print "Language: $lang\n";
print "DVD-Track: $dvd_track\n";
print "CD-Rom Size: $cdsize\n";
print "Movie FIlename: $avi_filename\n";
if ($writecd) {
print "CD Writer Dev.: $writedev\n";
print "Writer Speed: $speed\n";
}
# here comes the fun part...
print "precacheing...\n";
$status = system ("mencoder dvd://$dvd_track -ovc copy -oac copy -dvd-device $dvd_device -alang $lang -o $vob_tempfile 1>/dev/tty8 2>/dev/tty8");
die "Prechacheing failed. mencoder exited with Status Code $?" unless $status == 0;
print "Encoding Audio...\n";
$status = system ("mencoder $vob_tempfile -ovc frameno -oac mp3lame -lameopts br=$abr:cbr:vol=3 -o frameno.avi 1>./audio.stderr 2>/dev/tty8");
die "Encoding Audio failed. mencoder exited with Status Code $?" unless $status == 0;
# now we have to find out the recommended bitrate for the Video encoding process...
# my current method to find this out is, hmm, well, *strange*
# but anyway, it works ;-))
open(FILE, "< audio.stderr") or die "Unable to open audio.stderr.";
@lines = <FILE>;
foreach $line (@lines) {
($index, $zz) = split(" ", $line);
if ($index eq "Recommended") {
($a, $b, $c, $d, $size, $f, $bitrate) = split(" ", $line);
if ($cdsize == $size) {
$video_bitrate = $bitrate;
print "Setting Videobitrate to $video_bitrate\n";
}
}
}
close (FILE);
print "Encoding Video Stream, 1st pass...\n";
$status = system ("mencoder $vob_tempfile -ovc lavc -lavcopts vpass=1:vcodec=mpeg4:vbitrate=$video_bitrate:vhq -oac copy -o $avi_filename 1>/dev/tty8 2>/dev/tty8");
die "Encoding Video Stream failed. mencoder exited with Status Code $?" unless $status == 0;
print "Encoding Video Stream, 2nd pass...\n";
$status = system ("mencoder $vob_tempfile -ovc lavc -lavcopts vpass=2:vcodec=mpeg4:vbitrate=$video_bitrate:vhq -oac copy -o $avi_filename 1>/dev/tty8 2>/dev/tty8");
die "Encoding Video Stream failed. mencoder exited with Status Code $?" unless $status == 0;
print "finished encoding\n";
if ($writecd) {
print "Now writing CD-Rom\n";
$status = system("mkisofs -r -J $avi_filename | cdrecord speed=$speed dev=$writedev -data - 2>/dev/tty8 1>/dev/tty8");
die "Writing CD failed. cdrecord exited with Status Code $?" unless $status == 0;
}
delete_tempfiles();
print "Finished - have a nice day ;-)\n";
if ($shutdown) {
system("halt");
exit;
}
exit;

View File

@ -1,440 +0,0 @@
#!/bin/bash
#
# Version: 0.2.2
#
# Licence: GPL
#
# 2002/09/21 Jürgen Hammelmann <juergen.hammelmann@gmx.de>
#
# Script: MPlayer Sources (DVD) to (S)VCD ripping and burning
#
# requires: mplayer
# mjpegtools
# vcdimager
# cdrdao
# lame (optionally)
# toolame (optionally)
# sox (optionally)
for exe in mplayer mpeg2enc mp2enc mplex yuvscaler ; do
if [ -z "`which $exe`" ]; then
echo "ERROR: $exe must be in your path $PATH!"
exit 1
fi
done
for exe in vcdimager lame cdrdao yuvdenoise sox toolame normalize; do
if [ -z "`which $exe`" ]; then
echo "WARNING: $exe is not found in your path $PATH!"
fi
done
################################################################################
#
# 2002/04/11 v0.1.0: first version
# 2002/04/12 v0.1.1:
# 2002/04/14 v0.1.2:
# - handles now multiple vcd's
# - support's mp3 audio as option
# - use of mp2enc/lame instead of toolame because of support
# of resampling and mp3
# 2002/04/16 v0.1.3:
# - new option "-burnonly"
# - new option "-vbr"
# - removes mpg file after mastering cd image
# (mplayer can read bin images!)
# - bugfixes
# 2002/04/22 v0.1.4
# - bugfixes / changes
# - more options
# 2002/05/06 v0.1.5
# - new option "-norm"
# 2002/05/08 v0.1.6
# - bugfixes
# - new option "-vfr"
# - "-norm" renamed to "-vnorm"
# 2002/05/15 v0.1.7
# - bugfixes
# - more help
# 2002/05/26 v0.1.8
# - new option "-sync"
# 2002/06/19 v0.1.9
# - new option "-mpgonly"
# 2002/09/21 v0.1.10
# - bug fixes
# - tests now, if the commands are in path and give warnings
# and errors.
# 2002/11/01 v0.2
# - bug fixes
# - new options: "-sox", "-volume", "-toolame"
# - renamed "-mpg" to "-mpegsrc"
# - default cd size changed to 800mb
# 2002/11/18 v0.2.1
# - aspect ratio for vcd's, too
# - pulldown mode...
# 2002/12/01 v0.2.2
# - -normalize
#
################################################################################
#
# global config section, change them to your needs!
TMPDIR="." # path to directory for creating temporary files, recommended 2-3GB space
CDDRV="generic-mmc" # cdrdao: cdwriter driver
CDDEV="--device 0,1,0" # or comment out and create link /dev/cdrecorder
# to your cdwriter dev
CDMAXSIZE=800
################################################################################
AUDIO="audiodump.wav"
VIDEO="stream.yuv"
VCDMODE=2
SVCDMODE=5
################################################################################
usage() {
echo "Usage: $HOWCALLED <basename> [$HOWCALLED options] [mplayer options]"
echo
echo " <basename> is used as basename of the resulting mpg/bin files."
echo
echo "For mplayer options see mplayer help and manual."
echo
echo "$HOWCALLED options:"
echo
echo "-?|-h help."
echo "-a <n> sets the aspect ratio (for SVCD):"
echo " 1 - 1:1 display"
echo " 2 - 4:3 display"
echo " 3 - 16:9 display"
echo " 4 - 2.21:1 display"
echo "-abr <n> output audio bitrate in kbs [224]."
echo "-asr <n> output audio sample rate in Hz [44100]."
echo "-blank cleans cd-rw before burning."
echo "-burnonly burn only the premastered <name>*.cue/<name>*.bin images."
echo "-cdsize <n> maximal size of cd images [800 = 80min raw cd]."
echo "-denoise denoises mpeg stream."
echo "-mp3 outputs audio in mp3 instead of mp2 format."
echo "-mpegsrc don't encode from source, multiplex/burn the "
echo " encoded mpg stream."
echo "-mpgonly do only encoding to mpeg 1/2 format."
echo "-noburn disables burning."
echo "-normalize use 'normalize'."
echo "-overburn enables overburning a cd."
echo "-pulldown enable pulldown mode in output."
echo "-ratio <s> output ratio size of frames, see yuvscaler (1)."
echo "-size <X>x<Y> sets output size of frames."
echo "-sox use sox for audio resampling."
echo "-svcdout encode to SVCD format [VCD default]."
echo "-sync <n> set the presentation timestamp offset of video"
echo " stream w.r.t. audio stream (video-audio) in mSec."
echo "-toolame use toolame instead of mp2enc."
echo "-v <volume> change amplitude (floating point); less than 1.0"
echo " decreases, greater than 1.0 increases. Use that only"
echo " together with sox!"
echo "-vbr <n> output video bitrate in kbs [VCD:1152, SVCD:2500]."
echo "-vfr <n> sets the frame-rate of the output-stream. Currently"
echo " only the standard MPEG rates are supported:"
echo " 0 - illegal"
echo " 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM)"
echo " 2 - 24.0 (NATIVE FILM)"
echo " 3 - 25.0 (PAL/SECAM VIDEO / converted FILM)"
echo " 4 - 30000.0/1001.0 (NTSC VIDEO)"
echo " 5 - 30.0"
echo " 6 - 50.0 (PAL FIELD RATE)"
echo " 7 - 60000.0/1001.0 (NTSC FIELD RATE)"
echo " 8 - 60.0"
echo "-vnorm <p|n|s> sets the input video norm p, n or s:"
echo " forces the input stream to be treated as PAL|NTSC|SECAM"
echo " regardless of what the stream header might suggest."
echo "-w outputs in wide screen format 16:9."
echo
echo "examples:"
echo
echo "'$HOWCALLED teneriffa teneriffa.avi'"
echo "this creates a VCD from an avi file."
echo
echo "'$HOWCALLED crazy dvd://3 -w':"
echo "encodes and burns dvd title 3 to VCD in 16:9."
echo
echo "'$HOWCALLED carter dvd://1 -sid 0 -aid 128 -ss 3:00 -frames 1500 \\"
echo " -noburn -vnorm n -vfr 1':"
echo "this encodes 1500 frames of dvd title 1 with subtitle 0 and audio stream"
echo "128 starting from 3:00 with frame rate 29.97 fps and input video norm NTSC"
echo "and output frame rate 23.98 fps because of the 3:2 pulldown method in NTSC."
echo
echo "'$HOWCALLED bj -size 640x272 -vf expand=640:480:0:104:0 \\"
echo " -cdsize 645 -noburn bj.avi'"
echo "this example above shows you, how to deal with movies which are not"
echo "created with aspect ratios of 4:3 or 16:9."
}
HOWCALLED=`basename $0`
if [ $# -le 1 ]; then
usage
exit 1
fi
case $1 in
-*)
usage
exit 1
;;
*)
NAME=$1
shift 1
;;
esac
cd $TMPDIR
rm -f $VIDEO
rm -f $AUDIO
# create a named pipe for video stream
mkfifo -m 660 $VIDEO
# some inits
sub=""
size=""
aratio=""
ratio=""
params=""
wide=""
blank=0
burn=1
burnonly=0
mp3=0
mpgonly=0
mkstream=1
abr=224
abrset=0
asr=44100
vbr=1152
vbrset=0
denoise="cat -"
vnorm="VCD"
mplexnorm="-f $VCDMODE -m 1 -V -b 46"
imaget="-t vcd2"
yuvin=""
framerate=""
sync=""
sox=0
toolame=0
volume="1.0"
overburn=""
pd=""
norm=0
while [ "$1"x != "x" ]; do
case $1 in
-a)
aratio="-a $2"
shift 1
;;
-w)
wide="-M WIDE2STD"
;;
-h|-?)
usage
exit 0
;;
-abr)
abr=$2
abrset=1
shift 1
;;
-asr)
asr=$2
shift 1
;;
-cdsize)
CDMAXSIZE=$2
shift 1
;;
-blank)
blank=1
;;
-noburn)
burn=0
;;
-burnonly)
burnonly=1
burn=1
;;
-overburn)
overburn="--overburn"
;;
-pulldown)
pd="-p"
;;
-vfr)
framerate="-F $2"
shift 1
;;
-mp3)
mp3=1
;;
-mpegsrc)
mkstream=0
;;
-mpgonly)
mpgonly=1
;;
-normalize)
norm=1
;;
-vnorm)
yuvin="-n $2"
shift 1
;;
-volume)
volume="$2"
shift 1
;;
-denoise)
denoise="yuvdenoise"
;;
-ratio)
ratio=$2
shift 1
;;
-sid) # mplayer option: have to set vf expand, too!!!
sub="-vf pp,expand=-1:-1:-1:-1:1 -sid $2"
shift 1
;;
-size)
size=$2
shift 1
;;
-svcdout)
vnorm="SVCD"
;;
-sync)
sync="-O $2"
shift 1
;;
-sox)
sox=1
;;
-toolame)
toolame=1
;;
-vbr)
vbr=$2
vbrset=1
shift 1
;;
*)
params="$params $1"
;;
esac
shift 1
done
# some configs
mpegnorm="-f $VCDMODE -b $vbr -B 260 -V 46"
if [ "$vnorm" = "SVCD" ]; then
[ $vbrset -eq 0 ] && vbr=2500
mplexnorm="-f $SVCDMODE -m 2 -V -b 230"
mpegnorm="-f $SVCDMODE -b $vbr -B 260 -V 230"
imaget="-t svcd"
fi
# ratio overwrites wide sizing, size overwrites default frame size
[ -n "$ratio" ] && wide="-M $ratio"
[ -n "$size" ] && size="-O SIZE_$size"
# with mp3 audio set the default audio bitrate to 128 kbs
[ $mp3 -eq 1 -a $abrset -eq 0 ] && abr=128
# audio sample rate in kHz
a=$(($a=$asr / 1000))
b=$(($b=$asr % 1000))
[ $b -le 9 ] && b="00$b00"
[ $b -le 99 ] && b="0$b00"
kasr="$a.$b"
# start de-/encoding
if [ $burnonly -eq 0 ]; then
# encode streams
if [ $mkstream -eq 1 ]; then
# start mplayer
command="mplayer -noframedrop -vo yuv4mpeg -ao pcm:waveheader -v -osdlevel 0 $sub $params"
echo "$command"
$command &
# mjpegtools
($denoise < $VIDEO | \
yuvscaler -v 0 $wide -O $vnorm $size $yuvin | \
mpeg2enc -v 0 -s $mpegnorm $aratio -S $CDMAXSIZE -g 6 -G 15 -r 16 \
$pd $framerate $yuvin -4 2 -2 1 -o $NAME.mpv) &
# wait for finishing the subprocesses
wait
# normalize sound
[ $norm -eq 1 ] && (echo "normalizing sound..."; normalize $AUDIO)
# do resampling with sox
if [ $sox -ne 0 ]; then
echo "wait, do resampling with sox..."
sox $AUDIO -v $volume -r $asr $NAME.wav resample -qs
mv -f $NAME.wav $AUDIO
fi
if [ $toolame -ne 0 -a $mp3 -eq 0 ]; then
# do mp2 encoding with toolame
echo "wait, encoding to mp2 audio with toolame..."
toolame -b $abr $AUDIO
mv -f `basename $AUDIO .wav`.mp2 $NAME.mpa
elif [ $toolame -eq 0 -a $mp3 -eq 0 ]; then
# mp2enc/lame can't read audiodump.wav directly from named pipe,
# we have to read the whole file.
echo "wait, encoding to mp2 audio with mp2enc..."
mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO
elif [ $mp3 -ne 0 ]; then
echo "wait, encoding to mp3 audio with lame..."
lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO
fi
fi
# remove wav file, won't need anymore!
rm -f $AUDIO
# multiplex streams
[ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1
rm -f ${NAME}*.mpg
mplex $mplexnorm $sync $NAME.mpv $NAME.mpa -o ${NAME}%d.mpg
# remove pipe, won't need anymore!
rm -f $VIDEO
# should i create only the mpeg file?
[ $mpgonly -eq 1 ] && exit 0
# create cd images
for mpg in ${NAME}*.mpg; do
[ -f $mpg ] || exit 1
cue="`basename $mpg .mpg`.cue"
bin="`basename $mpg .mpg`.bin"
rm -f $cue $bin
vcdimager $imaget -c $cue -b $bin $mpg
[ -f $bin -a -f $cue ] && rm -f $mpg
done
# end of streaming/mastering
fi
# burn the (s)vcd's
[ $burn -eq 0 ] && exit 0
for cue in ${NAME}*.cue; do
bin="`basename $cue .cue`.bin"
[ -f $bin -a -f $cue ] || exit 1
echo "please insert a cd in your cdwriter, after a keypress we start:"
read -n 1 i
if [ $blank -eq 1 ]; then
cdrdao blank --reload $CDDEV --driver $CDDRV --blank-mode minimal
fi
cdrdao write $overburn --reload $CDDEV --driver $CDDRV $cue
done
exit 0

View File

@ -1,297 +0,0 @@
#!/bin/bash
#
# QEPDVCD
#
# Most of this stuff comes straight from MPlayer documentation.
# Options are limited only to a small useful subset, if you
# want more control, RTFM and DIY.
#
# Version: 0.1
#
# Licence: GPL
#
# Author: Reynaldo H. Verdejo Pinochet <reynaldo@opendot.cl>
#
# Script: MPlayer Sources. Anything supported to vcd/svcd pal/ntsc
#
# requires: mencoder
#
# sugests: vcdimager / cdrecord
#
# Thanks to: Carlos Navarro Salas - name author ;)
#
#
# Defaults
MYNAME=`basename $0`
TARGET="svcd"
ENCQ="2"
ABPS="224"
VBPS="2000"
NORM="NTSC"
SPLIT="0"
TOLERANCE="85"
OUTNAME="mencodedvcd"
SUBFILENAME=0
EDLFILENAME="pass.edl"
HAVESUB=0
WORKDIR="."
RATIOX=4
RATIOY=3
OPTIONS="INPUTFILENAME TARGET ENCQ ABPS VBPS NORM SPLIT TOLERANCE OUTNAME"
usage()
{
echo ""
echo "usage $MYNAME inputfile [options]"
echo ""
echo "Options: [Default value]"
echo ""
echo "-t Target svcd|vcd [svcd]"
echo "-q Encoding quality 0|1|2 [2]"
echo "-a Audio bitrate in kbps [224]"
echo "-v Video bitrate in kbps [2000 For SVCD, 1150 For VCD]"
echo "-n Norm NTSC|PAL [NTSC]"
echo "-d Divide/split movie at given times time1:time2:... [no split]"
echo "-s Shitty TV screen tolerance %, afects subtitle positioning [85]"
echo "-u Subtitle file name [No subtitle]"
echo "-o Output basename [mencodedvcd]"
echo ""
echo "In case you want to use -a/-v please read:"
echo "http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html"
echo ""
}
test_needed()
{
for i in mencoder; do
if [ -z "`which $i`" ]; then
echo "[ERROR] mencoder not found in $PATH!"
exit 1
fi
done
}
test_sugested()
{
for i in vcdimager cdrecord; do
if [ -z "`which $i`" ]; then
echo "[WARNING] $i not found in $PATH!"
echo "You'll likely need it after we finish."
exit 1
fi
done
}
test_needed
test_sugested
if [ $# -lt 1 ]; then
echo ""
echo "[ERROR] Input filename parameter is mandatory."
echo ""
usage
exit 1
fi
case $1 in
-*)
usage
exit 1
;;
*)
INPUTFILENAME=$1
shift 1
;;
esac
while [ "$1"x != "x" ]; do
case $1 in
-t)
TARGET=$2
shift 1
;;
-q)
ENCQ=$2
shift 1
;;
-a)
ABPS=$2
shift 1
;;
-v)
VBPS=$2
shift 1
;;
-n)
NORM=$2
shift 1
;;
-d)
SPLIT=$2
shift 1
;;
-s)
TOLERANCE=$2
shift 1
;;
-u)
SUBFILENAME="$2"
HAVESUB=1
shift 1
;;
-o)
OUTNAME=$2
shift 1
;;
esac
shift 1
done
echo ""
echo "[STATUS] Will re-encode using the following parameters:"
echo ""
for i in $OPTIONS ; do
echo "$i ${!i}";
done
# Parameter Sanity Check ###########################################
# We need to check supplied params against known format constraints
####################################################################
if [ $TARGET = "svcd" ]; then
if [ $ABPS -gt 384 ]; then
echo "[ERROR] SVCD maximum abitrate is 384kbps."
exit 1
fi
if [ $VBPS -gt 2600 ]; then
echo "[ERROR] SVCD maximum vbitrate is 2600kbps."
exit 1
fi
else [ $TARGET = "vcd" ]
if [ $ABPS -eq 224 ]; then
echo "[ERROR] VCD abitrate must be 224kbps."
exit 1
fi
if [ $VBPS -gt 1150 ]; then
echo "[ERROR] VCD maximum vbitrate is 1150kbps."
exit 1
fi
fi
# Set encoding options ##############################################
if [ $TARGET = "svcd" ]; then
FORMAT="xsvcd"
VCODEC="mpeg2video"
VRCMINRATE=4
VRCMAXRATE=2500
VRCBUFSIZE=917
if [ $NORM = "NTSC" ]; then
SCALEX=480
SCALEY=480
KEYINT=18
OFPS="24000/1001"
TELECINE=":telecine"
else [ $NORM = "PAL" ]
SCALEX=480
SCALEY=576
KEYINT=15
OFPS=25
fi
else [ $TARGET = "vcd" ]
FORMAT="xvcd"
VCODEC="mpeg1video"
VRCMINRATE=$VBPS
VRCMAXRATE=$VBPS
VRCBUFSIZE=327
if [ $NORM = "NTSC" ]; then
SCALEX=352
SCALEY=240
KEYINT=18
OFPS="24000/1001"
else [ $NORM = "PAL" ]
SCALEX=352
SCALEY=288
KEYINT=15
OFPS=25
fi
fi
# Start reencoding ###################################################
cd $WORKDIR
if [ $(($HAVESUB+1)) -eq 1 ]; then
SUBTITLESTRING="/dev/null"
else
SUBTITLESTRING="$SUBFILENAME"
fi
if [ $SPLIT = "0" ]; then
CICLES=0
TIMESTRING=""
else
if [ -e $EDLFILENAME ]; then
echo "[ERROR]"
echo "The -d option needs to generate a temporary file called"
echo "$EDLFILENAME. You already have one in this directory,"
echo "please remove/rename it and run $MYNAME again."
echo ""
exit 1
else
EDLSTRING=$(echo $SPLIT | sed -e s/:/' '/g)
EDLARRAY=($EDLSTRING)
CICLES=$(echo $EDLSTRING | wc -w)
TIMESTRING="-edl $EDLFILENAME -hr-edl-seek"
fi
fi
for j in $(seq 0 $CICLES); do
NEWNAME=$OUTNAME"_PART"$j".mpg"
echo ""
echo "Making $NEWNAME, wish me luck ;-)"
echo ""
# Create EDLFILENAME #################################################
if [ $CICLES -ge 1 ]; then
for i in $(seq 0 $CICLES)
do
if [ $i -eq $j ]; then
if [ $j -ne 0 ]; then
echo "0 ${EDLARRAY[$(($i-1))]} 0" > $EDLFILENAME
fi
if [ $i -ne $CICLES ]; then
echo "${EDLARRAY[$(($i))]} 999999 0" >> $EDLFILENAME
fi
fi
done
fi
# Mencoder Time ;-) ###################################################
mencoder \
-ovc lavc -oac lavc -vf expand=:::::$RATIOX/$RATIOY:1,scale=$SCALEX:$SCALEY,harddup \
-srate 44100 -af lavcresample=44100 -lavcopts acodec=mp2:abitrate=$ABPS:vcodec=$VCODEC:\
vbitrate=$VBPS:keyint=$KEYINT:mbd=$ENCQ:vrc_buf_size=$VRCBUFSIZE:vrc_maxrate=$VRCMAXRATE:\
vrc_minrate=$VRCMINRATE:vi_qfactor=0.1:vi_qoffset=1.5:aspect=$RATIOX/$RATIOY -of mpeg \
-mpegopts format=$FORMAT$TELECINE -sub $SUBTITLESTRING -subpos $TOLERANCE -subwidth \
$TOLERANCE -ofps $OFPS $TIMESTRING -o $NEWNAME $INPUTFILENAME
echo "Encoding of $NEWNAME finished."
echo "Run vcdimager -t svcd/vcd $NEWNAME and burn with cdrecord."
done
echo "$(($CICLES+1)) VCD/SVCD file(s) created!!!"
echo "Happy to be of some help ;-) have fun."
exit 0