image + audio = mp4: how to make video smaller?
I'm using ffmpeg to add a JPG to an MP4 to make an MP4.
As there is only one image to make the video I'm wondering if there is a way to reduce the video size?
Command:
$ ffmpeg -loop 1 -i image.jpg -i audio.mp3 -shortest -c:a copy output.mp4
Results:
image.jpg = 26.7K (image not so clear)
audio.mp3 = 64.6M (54 minutes)
output.mp4 = 80.6M (video result is not so clear, music still good)
Is it a reasonable size for MP4?
Top Answer/Comment:
For uploading to YouTube
H.264: smallest files
This method uses libx264 to encode H.264 video. It is slower than the stream copy method below, but potentially will output a smaller file size.
ffmpeg -loop 1 -framerate 1 -i image.jpg -i music.mp3 \
-c:v libx264 -preset veryslow -crf 0 -c:a copy -shortest output.mkv
Stream copy: fastest process
This method just stream copies (no encoding) the image into the MKV container. It's super fast, but if size is important than the method above may produce a smaller file.
ffmpeg -loop 1 -framerate 1 -i image.jpg -i music.mp3 -c copy -shortest output.mkv
YouTube accepts just about anything so these commands use a few tricks to make encoding faster, or make the file size small, and to keep quality high because YouTube will re-encode whatever you give it. Your player probably won't like it but YouTube will.
In these examples a very low frame rate is used which should process faster than the default of 25 fps.
Widest compatibility for any player
ffmpeg -loop 1 -i image.png -i music.mp3 -vf "scale='min(1280,iw)':-2,format=yuv420p" \
-c:v libx264 -preset medium -profile:v main -c:a aac -shortest -movflags +faststart output.mp4
This should play on just about anything except very ancient devices (change -profile:v main to -profile:v baseline if that is the case).
If your audio input is already AAC then change -c:a aac to -c:a copy to avoid unnecessary re-encoding.
Encoding time will be longer and file size will be bigger than the YouTube commands above.
See FFmpeg Wiki: H.264 for more info.
상단 광고의 [X] 버튼을 누르면 내용이 보입니다