-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvideo2qt
executable file
·50 lines (41 loc) · 1.88 KB
/
video2qt
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
#
# This will convert a file to a format readable by Quicktime
#
# Based on the mencoder manual:
# http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-quicktime-7.html
appname="$(basename "$0")"
orig_video="$1"
final_video="$orig_video.mp4"
if [ "z$orig_video" = "z" ] ; then
echo "Usage: ${appname} video_file"
exit 1
fi
if [ ! -r "$orig_video" ] ; then
echo "File '$orig_video' is unreadable."
exit 2
fi
# First pass
mencoder "$orig_video" -o /dev/null -ovc x264 -x264encopts pass=1:threads=auto:bitrate=900:bframes=1:me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 -vf scale=-10:-1,harddup -oac faac -faacopts br=192:mpeg=4:object=2 -channels 2 -srate 48000 || exit 3
# Second pass
temp_avi="$(mktemp -t "${appname}_temp_avi_XXXXXXXX")"
mencoder "$orig_video" -o "$temp_avi" -ovc x264 -x264encopts pass=2:threads=auto:bitrate=900:bframes=1:me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 -vf scale=-10:-1,harddup -oac faac -faacopts br=192:mpeg=4:object=2 -channels 2 -srate 48000 || exit 4
rm -f divx2pass.log
# Dump audio and video files
temp_aac="$(mktemp -t "${appname}_temp_aac_XXXXXXXX")"
temp_h264="$(mktemp -t "${appname}_temp_h264_XXXXXXXX")"
mplayer "$temp_avi" -dumpaudio -dumpfile "$temp_aac" || exit 5
mplayer "$temp_avi" -dumpvideo -dumpfile "$temp_h264" || exit 6
# mp4creator needs specific extensions
link_aac="$orig_video.aac"
link_h264="$orig_video.h264"
ln -s "$temp_aac" "$link_aac" || exit 7
ln -s "$temp_h264" "$link_h264" || exit 7
# Make the final MP4 video
mp4creator -create="$link_aac" "$final_video" && rm "$temp_aac" && rm "$link_aac"
mp4creator -create="$link_h264" -rate=23.976 "$final_video" && rm "$temp_h264" && rm "$link_h264"
mp4creator -hint=1 "$final_video"
mp4creator -hint=2 "$final_video"
mp4creator -optimize "$final_video"
# Display the results
mp4creator -list "$final_video"