View Full Version : Convert audio for youtube with static video for Youtube
Update:
Here's what works at present:
ffmpeg -loop 1 -i image.bmp -i audio.mka -shortest -r {Low framerate, 0.008 works for hour long files Higher framerate increases encoding time and filesize} -acodec copy -vcodec libx264 -tune stillimage -crf 0 output.mkv
Original post:
Hello!
I want to upload a long audio file to youtube, but of course youtube dumbly doesn't let me upload audio files.
There are bunch of videos with a still image as a video. Now I want the same thing but I don't want bloated video files for a still image.
So the question is can I make a videofile video file with 0 fps? Or how can I make a videofile that only has one keyframe and other frames basically reference the same frame? Or at least something close to these.
Well, I tried something like this:
ffmpeg -i image.bmp -i input_audio -r 1 -acodec copy -vcodec libx264 -preset ultrafast -crf 0 output.mkv
The converion process finished witout issue, but players/youtube wouldn't swallow it. (Well, mplayer plays it, but can't seek)
poisondeathray
9th May 2013, 19:07
Don't use crf 0 . Youtube won't accept lossless x264 streams
Pomegranate
9th May 2013, 19:10
With avisynth, you could do
ImageSource("image.bmp", end = xxx, fps=25)
# you calculate xxx according to the length of your audio. If audio is 10 minutes long, it's 600 seconds * 25 fps = 15,000. So, xxx=15,000
You then use the script to make an mkv and mux your audio afterwards.
With avisynth, you could do
ImageSource("image.bmp", end = xxx, fps=25)
# you calculate xxx according to the length of your audio. If audio is 10 minutes long, it's 600 seconds * 25 fps = 15,000. So, xxx=15,000
You then use the script to make an mkv and mux your audio afterwards.
Unfortunately I don't know anything about avisynth.
Don't use crf 0 . Youtube won't accept lossless x264 streams
Ok.
I tried modifying the command line based on this (http://stackoverflow.com/questions/5887311/ffmpeg-1-image-1-audio-file-1-video). But the encoding
ffmpeg -loop 1 -shortest -i image.bmp -i audio.mka -r 1 -acodec copy -vcodec libx264 -tune stillimage output.mkv
But The encoding process doesn't stop when it should. It goes on.
poisondeathray
9th May 2013, 20:15
That command no longer works in ffmpeg builds (something changed about a year ago) . If you use a old ffmpeg build, I think that command will work (you have to go april 2012 or older)
Your commandline in post #2 should work if you adjust CRF to something else e.g. --crf 10
EDIT: no, there is something else wrong with it
I tested various methods a few months ago. VFR files are not accepted properly, and the lowest FPS upload YT would accept is 1.0 . It had problems with VFR and fractional FPS files . However, when it re-encoded the 1FPS video, the YT video became something like 6 FPS (checked when downloading the uploaded video) - audio still fine, just frames duplicated (not that it matters for a still image)
Also the audio quality is better (more audio bitrate allocated by youtube), the larger the resolution of the video. So don't think that uploading a low resolution video just to save a few bytes uploading is a good idea...
Things are always changing at youtube, so I don't know if these observations still hold true today
That command no longer works in ffmpeg builds (something changed about a year ago) . If you use a old ffmpeg build, I think that command will work (you have to go april 2012 or older)
-loop 1, -shortest or both?
Your commandline in post #2 should work if you adjust CRF to something else e.g. --crf 10
Apparently it doesn't work though..
I tested various methods a few months ago. VFR files are not accepted properly, and the lowest FPS upload YT would accept is 1.0 . It had problems with VFR and fractional FPS files . However, when it re-encoded the 1FPS video, the YT video became something like 6 FPS (checked when downloading the uploaded video) - audio still fine, just frames duplicated (not that it matters for a still image)
Also the audio quality is better (more audio bitrate allocated by youtube), the larger the resolution of the video. So don't think that uploading a low resolution video just to save a few bytes uploading is a good idea...
Things are always changing at youtube, so I don't know if these observations still hold true today
Well, I always wanted to upload the music with a FullHD res images so that's not a problem. There's just apparently no way to do it the way I imagined.
That last command seemes be producing a good output with the test file, but it doesn't stop....
poisondeathray
9th May 2013, 20:54
-loop 1, -shortest or both?
shortest doesn't work with ffmpeg in the last few months, that's why video continues on longer than the audio length
see this post, it works with older builds
http://forum.videohelp.com/threads/355301-Merging-an-image-in-audio-file?p=2234935&viewfull=1#post2234935
The tests I did before were with avisynth where you could control the fps and length (you can still feed the .avs script to ffmpeg to encode, or another encoder)
poisondeathray
9th May 2013, 21:09
Kind of sucks that you can't do it automatically, but I guess as a workaround you can manually enter -t hh:mm:ss.ms for the duration of the audio
e.g
ffmpeg -loop 1 -r 1 -i image.png -i audio.mp4 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -pix_fmt yuv420p -t 00:05:20.117 output.mp4
poisondeathray
9th May 2013, 21:34
And for completeness, the RGB=>YUV conversion by ffmpeg swscale will use Rec601, but youtube will use Rec709 for converting to RGB for display (the colors will look a bit off)
If you want to convert as if it had used rec709 for the RGB=>YUV conversion, you can add -vf colormatrix=bt601:bt709
shortest doesn't work with ffmpeg in the last few months, that's why video continues on longer than the audio length
see this post, it works with older builds
http://forum.videohelp.com/threads/355301-Merging-an-image-in-audio-file?p=2234935&viewfull=1#post2234935
The tests I did before were with avisynth where you could control the fps and length (you can still feed the .avs script to ffmpeg to encode, or another encoder)
So it's just broken for a year now? Well, that's sad...
Kind of sucks that you can't do it automatically, but I guess as a workaround you can manually enter -t hh:mm:ss.ms for the duration of the audio
e.g
ffmpeg -loop 1 -r 1 -i image.png -i audio.mp4 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -pix_fmt yuv420p -t 00:05:20.117 output.mp4
I tried the old version. So far the 1fps version was good (crf0). the 0.1 fps version was borked (the music doesn't start at the beginning, an not all players can stomach it) but youtube accepted that one too. :)
This worked:
ffmpeg -loop 1 -shortest -i image.bmp -i audio.mka -r 0.008 -acodec copy -vcodec libx264 -tune stillimage -crf 0 output.mkv
It added less then four megabytes to the video. The encoding wasn't fast (apparently ffmpeg can't go above 50% CPU usage like normally.) and players don't like it much but youtube accepted it. Even though I uploaded it in FullHD the YT 480p version is almost twice the size. :)
Apparently the new ffmpeg version wants the -shortest after specifying the input files such as this:
ffmpeg -loop 1 -i image.bmp -i audio.mka -shortest -r 0.008 -acodec copy -vcodec libx264 -tune stillimage -crf 0 output.mkv
Works with latest build, and it gives an error for the old method. I'm assuming the bug was that it didn't give an error but ignored the option before.
Now the big question is why on earth does it take so long. It's like 30 frames an hour yet the encoding process took more than an hour.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.