Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- height=""
- length=""
- start_time=""
- aparam=""
- if [[ -z "$1" ]]; then
- printf "usage: video [audio [output [height]]]\n"
- exit
- fi
- #audio
- if [[ -n "$2" ]]; then
- if [[ "$2" == "no" ]]; then
- aparam="-an"
- else
- internal_alang=$(echo "$2" | sed s/[^0-9]//g)
- let "selected_alang=$internal_alang-1"
- aparam="-map 0:v:0 -map 0:a:$selected_alang -acodec copy"
- fi
- else
- aparam="-acodec copy"
- fi
- #output
- if [[ -n "$3" ]]; then
- output_path="$3"
- else
- output_path="$HOME";
- fi
- #height
- if [[ -n "$4" ]]; then
- height="-vf scale=trunc(oh*a/2)*2:$4"
- else
- height=""
- fi
- if [[ -n `ls /tmp/webm_start` ]]; then
- start_time_var=`cat /tmp/webm_start`
- start_time="-ss $start_time_var"
- else
- start_time="-ss 0";
- fi
- if [[ -n `ls /tmp/webm_end` ]]; then
- length_var=$(echo "`cat /tmp/webm_end` - $start_time_var" | bc)
- length="-t $length_var"
- else
- length=""
- fi
- ffmpeg $start_time $length -i "$1" -vcodec copy $aparam -f mp4 $height -sn -cpu-used 2 -threads 2 $output_path/"$1 s $start_time_var l $length_var".mp4
- sleep 1
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement