-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsp-transcoder.sh
More file actions
executable file
·75 lines (66 loc) · 1.67 KB
/
psp-transcoder.sh
File metadata and controls
executable file
·75 lines (66 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# Given n video files on the command line, transcode them for a PSP 3000
# device (MP4[AVC, AAC]) in the default or optionally overridden directory.
#
# Default parameters
OUTDIR="`pwd`"
ASPECT='4:3'
ffmpeg_encode()
{
ffmpeg -i "$1" -f psp -threads auto -pass 1 \
-ac 2 -ar 48000 -b:a 224k \
-r 30000/1001 -aspect $ASPECT -s 480x272 -b:v 384k -vcodec h264 -subq 6 \
-level 30 -trellis 0 -refs 2 -bf 8 -b-pyramid none -weightb 0 -mixed-refs 0 \
-8x8dct 0 -coder ac -y /dev/null && \
ffmpeg -i "$1" -f psp -threads auto -pass 2 \
-ac 2 -ar 48000 -b:a 224k \
-r 30000/1001 -aspect $ASPECT -s 480x272 -b:v 384k -vcodec h264 -subq 6 \
-level 30 -trellis 0 -refs 2 -bf 8 -b-pyramid none -weightb 0 -mixed-refs 0 \
-8x8dct 0 -coder ac -y "$2"
}
while getopts 'a:o:h' OPTION; do
case $OPTION in
a)
ASPECT="$OPTARG"
;;
o)
OUTDIR="$OPTARG"
;;
h)
echo -e "Usage: $0 [options] <video file,...>\nOptions:"
echo -e " -h Help! Print this message then exit"
echo -e " -a <aspect ratio> Alternative aspect ratio to $ASPECT"
echo -e " -o <output dir> Alternative output directory to $OUTDIR"
exit 0
;;
?)
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [ "x$1" = "x" ]; then
echo "Provide at least 1 input video file" >&2
exit 1
fi
set -eu
declare -a TOOLS=(ffmpeg)
for t in ${TOOLS[@]}
do
if [ ! -x "`which $t 2> /dev/null`" ]; then
echo "Required tool '$t' not found or not executable" >&2
exit 1
fi
done
cd /tmp
for f in $@
do
if [ ! -f "$f" ]; then
echo "'$f' not a regular file" >&2
continue
fi
name="`basename $f`"
base="${OUTDIR}/${name%%.*}"
ffmpeg_encode "$f" "${base}.mp4" 2>&1 | tee "${base}.log"
done