-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwopass_ffmpeg
50 lines (32 loc) · 1.16 KB
/
twopass_ffmpeg
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
#!/bin/bash
# list the content of the home directory
ls -lh /$HOME/
# reads the user input and saves it under $infile variable
echo "Please select the input file [ENTER]: "
read infile
# echo "Please select the video bitrate in M (Mbps) or k (kbps) [ENTER]: "
# read vbitrate
vbitrate=20M
# echo "Please select the audio bitrate k (kbps) [ENTER]: "
# read abitrate
$abitrate=192k
$bufsize=40M
# run the 2-pas encoding for infile and rename the output file from xxx.mxf -> xxx.mp4
ffmpeg -y -i $infile \
-c libx264 -preset medium -b:v $vbitrate -maxrate $vbitrate -bufsize $bufsize -pass 1 \
-c:a aac -ac 2 -b:a $abitrate \
-f mp4 /dev/null \
&& ffmpeg -i $infile \
-c:v libx264 -preset medium -b:v $vbitrate -maxrate $vbitrate -bufsize $bufsize -pass 2 \
-c:a aac -ac 2 -b:a $abitrate \
${infile%.mxf}.mp4
# deletes the log files from the 2-pass encoding, you can comment this row to save them
rm ffmpeg2pass-0.log*
# shows the stats of the transcoded file
echo
echo "The transcoding finished successfully, these are the stats of your transcoded file:"
echo
ffprobe ${infile%.mxf}.mp4 &> test.log \
&& grep -i video test.log \
&& grep -i audio test.log \
&& rm test.log