Last active
April 10, 2023 09:53
-
-
Save bezlant/fd8fea7f924271dfb1766718a1f036d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
# A simple script to overlay audio over a video lowering the original video's volume by 80% | |
# FFMPEG is awesome! | |
video="$1" | |
audio="$2" | |
if [[ "$video" != *".webm"* ]]; then | |
echo "Please input a video file as a first argument" | |
exit 1 | |
fi | |
if [[ "$audio" != *".mp3"* ]]; then | |
echo "Please input an audio file as a second argument" | |
exit 1 | |
fi | |
ffmpeg \ | |
-i "$video" \ | |
-i "$audio" \ | |
-filter_complex \ | |
"[1:a]apad[A];[0:a]volume=0.20,[A]amerge[out]" \ | |
-c:v copy -map 0:v -map [out] -y \ | |
"processed_${video:0:10}.mp4" | |
# Concat multiple videos into one, listed in a file | |
# $ cat mylist.txt | |
# file '/path/to/file1' | |
# file '/path/to/file2' | |
# file '/path/to/file3' | |
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4 | |
# Split a video given two timestamps | |
# Time in form Hh:Mm:Ss | |
video="$1" | |
timestamp="$2" | |
ffmpeg -i "$video" -to "$timestamp" -c copy first.mp4 | |
ffmpeg -i "$video" -ss "$timestamp" -c copy second.mp4 | |
# Trim a video | |
video="$1" | |
time="$2" | |
ffmpeg -i "$video" -vcodec copy -c:a copy -map 0 -ss "$time" trimmed.webm | |
# Make a video from a single image | |
image="$1" | |
audio="$2" | |
length="$3" #Hh:Mm:Ss | |
ffmpeg \ | |
-r 0.01 -loop 1 -i "$image" \ | |
-i "$audio" -c:v libx264 \ | |
-tune stillimage -preset ultrafast \ | |
-ss 00:00:00 -t "$length" \ | |
-c:a aac -b:a 96k -pix_fmt yuv420p \ | |
-shortest out.mp4 -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment