Last active
January 1, 2023 10:18
-
-
Save Dobby233Liu/daa60b985e23d12fbae5fcd4d207b86e to your computer and use it in GitHub Desktop.
A way to make a video from a frame of another video and audio extracted from a song
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
# Download and trim audio | |
# yt-dlp does not work for some reason | |
you-get "https://music.163.com/#/song?id=1433075058" | |
mv "0. 惊涛落日(Official Vers.).mp3" jtlr.mp3 | |
sox jtlr.mp3 jtlr_trim.wav trim 101.25 33 | |
# Download video and extract a frame | |
# as a .png file to avoid messing with compression | |
yt-dlp "https://m.youtube.com/watch?v=PJuIWf-sEyA" --sub-langs en --embed-subs -f bestvideo | |
mv "강아지가 엉덩이를 들이미는 이유 6가지 [PJuIWf-sEyA].webm" src.webm | |
ffmpeg -i src.webm -vf subtitles=src.webm -ss 00:00:54 -frames:v 1 frame.png | |
# Generate video | |
# To make the output's length accurate | |
# while technically having more than 1 frame (for thumbnail generation on Discord to work), | |
# we must hardcode the audio length here, for some reason | |
# (may be unnecessary if the output frame rate is high enough) | |
# It would seem that the lower the frame rate, the more broken seeking might be in certain video players, | |
# 1fps is ok on Discord though | |
ffmpeg -r 1 -loop 1 -i frame.png -i jtlr_trim.wav -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 192k -t 33 i_will_protect_you.mp4 | |
# Outputs is just slightly below 1MB, good I guess |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lessons for today: