-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_autoradio
executable file
·48 lines (37 loc) · 1.57 KB
/
convert_autoradio
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
#!/bin/bash
# Convert files to MPEG, suitable for using in (my) car-radio
if [[ $# -eq 0 ]]; then
echo "Usage: $0 [file]"
exit
fi
for file in "$@"
do
if [[ ! -f "$file" ]]; then
echo "$file not found"
continue
fi
echo "Converting $file"
split_video "$file" 600
find . -type f -name "${file%\.*}*-split-*" | while read splitFile; do
splitFileMpeg=${splitFile%\.*}.mpeg
echo "$splitFile -> $splitFileMpeg"
if [[ $splitFile == *.mp3 ]]; then
# Audio file
echo "Audio file, converting to video file..."
ffmpeg -nostdin -f lavfi -i 'color=c=black:s=720x480:r=1' -filter_complex "[0:v]drawtext=text='%{pts\:hms}':x=(w-tw)/2:y=h-(2*lh):fontcolor=white:fontsize=25:fontfile=/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf[withtime];[withtime]drawtext=text='${splitFileMpeg%.*}':x=(w-text_w)/2:y=(h-text_h)/2:fontcolor=white:fontsize=25:fontfile=/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf[video]" -i "$splitFile" -map "[video]" -map 1:a -target ntsc-dvd -aspect "16:9" -b:v 64k -shortest "$splitFileMpeg"
ffmpegReturn=$?
else
# Video file
ffmpeg -nostdin -i "$splitFile" -target ntsc-dvd -threads 8 -aspect "16:9" -b:v 256k "$splitFileMpeg"
ffmpegReturn=$?
fi
if [[ $ffmpegReturn -ne 0 ]]; then
echo "Error: ffmpeg did not return correctly"
continue
fi
ls -lh "$splitFile"
ls -lh "$splitFileMpeg"
rm -vf "$splitFile"
done
rm -vf "$file"
done