DEV Community

Cover image for Minimalist audio videos for songs
Wesley
Wesley

Posted on

Minimalist audio videos for songs

So a while ago I found out about making one frame videos by simply throwing in an image, audio, and setting the framerate closest to the length of audio, in which I showed an example with Pinback's X.I.Y. for two minutes: https://www.youtube.com/watch?v=RIhPf-LqY6M
Which the command is basically:
ffmpeg -loop 1 -r 0.002777 -i cover.jpg -i audio.mp3 -ab 256k -shortest -t 360 video.avi
And of course is more efficient than 25fps or whatever fps for something that's just audio, and coincidentally as I was doing it with another album, YouTube Topic videos started just showing the album cover in a square rather than also including text, and having it at 25fps 🤔🤔🤔🤔🤔
I know someone will probably bring up the point of it not mattering how low the FPS is because of how the same frame is displayed for 4 minutes, but it actually does affect the file size, as I've tested a few times
Now at first, I was using rounded up numbers from this little online tool: http://www.zapstudio.net/framecalc/ and repeatedly changing numbers to see it get to the closest length of the audio until I found out the equation is 1 divided by the length of the song
I also happened to make a javascript function at the beginning of this year that takes in a string of HH:MM:SS and makes it a float (link)
With this I was able to mass render videos faster of audio from the album I mentioned, and not overestimate or underestimate 1 frame lasting 2-3 minutes
I might not be running a channel to upload a hardcore artist's entire catalog
So the process was simply get exact length of a song, 1/timeToFlt("00:04:40.250") in a browser console, and doing the same ffmpeg command as above but with the new framerate
And in addition, there was less to blank endings of the video after the song had already ended (and I noticed because the songs I was converting hit an instant stop instead of fading out normally)
Though it doesn't help YouTube will kind of force a minimal framerate anyway at like 5 or 8fps
In some cases (sometimes on mobile), it's so minimal that YouTube won't even show the quality setting, and I saw at some point seeking thumbnails weren't showing for a video or two

Top comments (0)