Created
April 12, 2021 18:16
-
-
Save bossbadi/a5899a828a44313ecc0b45775f4ef7c6 to your computer and use it in GitHub Desktop.
Bash script to reverse a video from YouTube. Intended for longer videos.
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
# install dependencies | |
pip3 install youtube-dl | |
sudo apt install ffmpeg | |
# make folders to store movie chunks | |
mkdir parts r_parts | |
# download movie (change URL to your video) | |
youtube-dl "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -f mp4 -o movie_in.mp4 | |
# split movie into 1 minute chunks | |
ffmpeg -i movie_in.mp4 -threads 3 -vcodec copy -f segment -segment_time 60 parts/%04d.mp4 | |
# reverse each 1 minute chunk | |
for i in parts/*; do ffmpeg -i $i -vf reverse -af areverse "r_parts/${i##*/}"; done | |
# index reversed chunks IN REVERSE ORDER | |
for f in $(ls -1 r_parts/*.mp4 | sort -r); do echo "file $f" >> mylist.txt; done | |
# merge all chunks by reading from index file | |
ffmpeg -f concat -safe 0 -i mylist.txt -c copy movie_out.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment