-
Notifications
You must be signed in to change notification settings - Fork 1
/
ts-to-mp4.sh
executable file
·60 lines (47 loc) · 1.06 KB
/
ts-to-mp4.sh
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
#!/bin/bash
scale=""
if [ "$1" == "-s" ] ; then
echo "scaling to $2"
scale="-vf scale=$2"
shift
shift
fi
INFILE="$1"
if [ "$INFILE" == "" ] ; then
echo "no input file specified"
exit 1
fi
if [ "$2" == "" ] ; then
OUTFILE=`echo $INFILE | sed 's/ts$/mp4/g'`
echo "Info, output file name $OUTFILE was derived from input file name"
else
OUTFILE="$2"
fi
if [ "$OUTFILE" == "" ] ; then
echo "Error, OUTFILE blank"
exit 1
fi
if [ "$INFILE" == "$OUTFILE" ] ; then
echo "Error, INFILE '$INFILE' same as OUTFILE '$OUTFILE'"
exit 1
fi
if [ ! -f "$INFILE" ] ; then
echo "Error, input file doesn't exist"
exit 1
fi
if [ -f "$OUTFILE" ] ; then
echo "Error, output file already exists"
exit 1
fi
if [ "$scale" == "" ] ; then
time nice ffmpeg -nostdin -loglevel warning -i "$INFILE" -c:a copy -c:v copy "$OUTFILE"
errcode=$?
else
time nice ffmpeg -nostdin -loglevel warning -i "$INFILE" $scale -c:v libx264 -profile:v baseline "$OUTFILE"
errcode=$?
fi
if [ $errcode -ne 0 ] ; then
echo "ffmpeg returned error code $errcode"
fi
exit $errcode
# end ts-to-mp4.sh