Last active
December 27, 2022 10:52
-
-
Save fathonyfath/e73ab34f446af43103a413d85b6941f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
check_ffmpeg() { | |
# Check if the `ffmpeg` command is available | |
if which ffmpeg >/dev/null; then | |
# If `ffmpeg` is available, return 0 | |
return 0 | |
else | |
# If `ffmpeg` is not available, return 1 | |
return 1 | |
fi | |
} | |
get_filename_without_extension() { | |
# Get the filename without the path | |
filename=$(basename "$1") | |
# Remove the extension from the filename | |
filename=$(echo "$filename" | sed 's/\.[^.]*$//') | |
# Return the result | |
echo "$filename" | |
} | |
# Check if ffmpeg is not found, exit program | |
if [ ! check_ffmpeg ]; then | |
echo 'ffmpeg command not found!' | |
exit 1 | |
fi | |
# Check if no parameter present, exit program | |
if [ $# -eq 0 ]; then | |
echo 'Put file path as first argument!' | |
exit 1 | |
fi | |
# Process input | |
filename=$(get_filename_without_extension "$1") | |
filename="${filename}.mp4" | |
# Run ffmpeg scripts | |
ffmpeg -y -i "$1" -vcodec h264 -acodec mp2 "$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment