-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffimgaud
More file actions
executable file
·49 lines (45 loc) · 1.92 KB
/
ffimgaud
File metadata and controls
executable file
·49 lines (45 loc) · 1.92 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
#!/bin/bash
[ -z "$1" ] && printf "Missing Input File\n" 2>&1 && exit
compress=0
while [ $# -gt 0 ]; do
case "$(file --mime-type -b "$1")" in
-c|--continue)
compress=1
shift
;;
video/*)
[ -n "$inputname" ] && audioinput="$1" && shift && continue
inputname="$1"
ffmpegPreArgs=" -stream_loop -1"
ffmpegPostArgs=' -c:v libx264 -pix_fmt yuv420p -preset veryfast -tune film -g 25 -crf 26 -x264opts no-scenecut -c:a aac -ac 2 -map 0:v -map 1:a -shortest'
shift
;;
image/gif)
inputname="$1"
ffmpegPreArgs=" -ignore_loop 0"
ffmpegPostArgs=' -c:v libx264 -pix_fmt yuv420p -preset fast -crf 28 -profile:v baseline -tune film -g 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:a aac -movflags +faststart -shortest'
shift
;;
image/*)
inputname="$1"
ffmpegPreArgs=" -r 1 -loop 1"
ffmpegPostArgs=" -c:v libx264 -pix_fmt yuv420p -r 1 -crf 28 -preset fast -profile:v baseline -tune stillimage -vf ""scale='iw-mod(iw,2)':'ih-mod(ih,2)'"" -c:a aac -map 0:v:0 -map 1:a -movflags +faststart -shortest"
shift
;;
audio/*)
audioinput="$1"
shift
;;
*)
outputname="${1%.*}.mp4"
break
;;
esac
done
echo $audioinput
echo $inputname
[ -z "$audioinput" ] || [ -z "$inputname" ] && printf "Missing Input\n" 2>&1 exit 1
[ "$compress" -eq 1 ] && convert "$inputname" -resize 50%x50% "/tmp/tmp-$inputname" && inputname="/tmp/tmp-$inputname"
timeLimit=$(ffprobe -i "${audioinput}" -show_entries format=duration -v quiet -of csv="p=0")
echo "ffmpeg $ffmpegPreArgs -i "$inputname" -i "$audioinput" $ffmpegPostArgs -t "$timeLimit" "$outputname""
ffmpeg $ffmpegPreArgs -i "$inputname" -i "$audioinput" $ffmpegPostArgs -t "$timeLimit" "$outputname"