How to setting pictures and audio to mp4 ffmpeg?

I’m trying to set some pictures and audio to mp4 using ffmpeg

I tried with these commands:

-i %02.png -pix_fmt yub420p -vcodec mjpeg -qmin 1 -qmax 1 -r 25 -i loop.pm3 -ar 22050 -ab 192k -aframes 25 -shortest out.mp4

-r 60 -f image2 -i %02.png -i loop.mp3 -vcodec libx264 -b:c -vpre -acodec copy out.mp4

-r 60 -f image2 -i %02.png -i loop.mp3 -vcodec libx264 -b:c -vpre -acodec copy -strict -experimental out.mp4

-r 60 -f image2 -i %02.png -i loop.mp3 -map 0 -c:v libx264 -vpre -acodec copy -strict -2 out.mp4

Some commands create the out.mp4 file, but I can’t seem to reproduce them in Android I just want to know the correct command to set a pictures group and an audio to a video

Answer

You are trying a bunch of different things in each of your commands. Let’s break this down into a more simple form, and then you can add any extra arguments you’d like once you get a more simplified version of what you desire.

To combine an image sequence with Audio at 60fps, try:

ffmpeg -framerate 60 -i %02.png -i loop.mp3 -map 0:v -c:v libx264 -pix_fmt yuv420p 
-map 1:a -c:a libfdk_aac -shortest -movflags +faststart out.mp4

Here you are encoding the video to H.264, and encoding the audio to AAC. I’m using these as a default here because not all video/audio codecs are compatible with MP4 container; which may be why you were having trouble.

If you don’t have the encoder libfdk_aac, then use -c:a aac -strict experimental instead to use the native FFmpeg AAC encoder.

Give the command above a shot, and if that doesn’t work, please update your original post with your console output. It will help in answering the question.

Also – this question isn’t appropriate here. It should be posted to superuser instead.

Hope that helps!

Also see:

Leave a Reply

Your email address will not be published. Required fields are marked *