32 lines
		
	
	
	
		
			674 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			674 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
# complain if no input file given
 | 
						|
if [ $# -lt 1 ]; then
 | 
						|
    >&2 echo "usage: $0 <input_file>"
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# get input video name
 | 
						|
input="${1}"
 | 
						|
shift 1
 | 
						|
 | 
						|
# without file extension
 | 
						|
output_base="${input%.*}"
 | 
						|
 | 
						|
# common video resolutions
 | 
						|
heights=(240 360 480)
 | 
						|
widths=(426 640 854)
 | 
						|
 | 
						|
# just a quick-and-dirty loop
 | 
						|
for index in $(seq 0 2); do
 | 
						|
    height="${heights[$index]}"
 | 
						|
    width="${widths[$index]}"
 | 
						|
 | 
						|
    # actual conversion
 | 
						|
    ffmpeg -i "${input}" \
 | 
						|
        -acodec aac -vcodec h264 \
 | 
						|
        -vf "scale=w=${width}:h=${height}:force_original_aspect_ratio=decrease,pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2" \
 | 
						|
        "${output_base}_${height}.mp4"
 | 
						|
done
 | 
						|
 | 
						|
exit 0
 |