mirror of
https://github.com/GRFreire/scripts.git
synced 2026-01-09 04:49:38 +00:00
vid2mov: better args handling
This commit is contained in:
parent
928d5d8304
commit
076b28e285
@ -5,6 +5,8 @@ a simple script around ffmpeg to convert a video file to `.mov`.
|
||||
|
||||
I personally use this script when I record something in OBS Studio and then want to import into DaVinci Resolve.
|
||||
|
||||
Run ``vid2mov -h`` for help.
|
||||
|
||||
## Requirements
|
||||
- [ffmpeg](https://www.ffmpeg.org/)
|
||||
- [notify-send](https://gitlab.gnome.org/GNOME/libnotify) (optional)
|
||||
|
||||
@ -1,17 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage: vid2mov -i [input_file] {-o [output_file]} {-y}
|
||||
|
||||
-h Show this help.
|
||||
|
||||
-i Specify input_file.
|
||||
|
||||
-o Specify output_file. Default to input_file with .mov extension.
|
||||
|
||||
-y Pass the -y flag to ffmpeg.
|
||||
EOF
|
||||
}
|
||||
|
||||
notify() {
|
||||
if [ "$(command -v notify-send)" ]; then
|
||||
notify-send "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
VIDEO_PATH=$1
|
||||
[ "$VIDEO_PATH" = "" ] && echo "error: video_path not given" && exit 1
|
||||
|
||||
[ "$2" != "" ] && OUT_PATH=$2 || OUT_PATH=${VIDEO_PATH%%.*}.mov
|
||||
VIDEO_PATH=""
|
||||
OUT_PATH=""
|
||||
CONFIRMATION=""
|
||||
|
||||
if ffmpeg -i "$VIDEO_PATH" -vcodec mpeg4 -q:v 2 -acodec pcm_s16le -q:a 0 -f mov "$OUT_PATH"; then
|
||||
while getopts "hi:o::y" ARG; do
|
||||
case $ARG in
|
||||
h) usage ; exit 0;;
|
||||
i) VIDEO_PATH=$OPTARG;;
|
||||
o) OUT_PATH=$OPTARG;;
|
||||
y) CONFIRMATION="-y";;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$VIDEO_PATH" = "" ] && echo "error: video_path not given" && usage && exit 1
|
||||
[ "$OUT_PATH" = "" ] && OUT_PATH=${VIDEO_PATH%%.*}.mov
|
||||
|
||||
if ffmpeg -i "$VIDEO_PATH" -vcodec mpeg4 -q:v 2 -acodec pcm_s16le -q:a 0 -f mov "$OUT_PATH" $CONFIRMATION; then
|
||||
echo "Done"
|
||||
notify "vid2mov" "$OUT_PATH done converting"
|
||||
exit 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user