I am trying to create a video from images using FFmpeg in different scenarios, and my commands work on Windows but not in Android Studio. I am using this library in my Android project:
implementation("com.arthenica:ffmpeg-kit-full:6.0-2")
When I run the commands, I get this error in Logcat:
[vost#0:0 @ 0x73746c8800] Unknown encoder 'libx264'.
Here are the commands I tried:
- When I have a list of images and a total duration, so each image's duration is automatically calculated based on the total duration. (For example, 3 images and a total duration of 9 seconds, so each image is shown for 3 seconds).
ffmpeg -framerate 1/3 -i image%d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p output.mp4
- When each image has its own specific duration. (For example, image1 = 3 sec, image2 = 5 sec, image3 = 10 sec, so the total video length is 18 seconds).
ffmpeg -loop 1 -t 3 -i image1.jpg -loop 1 -t 5 -i image2.jpg -loop 1 -t 10 -i image3.jpg \
-filter_complex "[0:v][1:v][2:v]concat=n=3:v=1:a=0[outv]" -map "[outv]" -c:v libx264 -r 30 -pix_fmt yuv420p output.mp4
- When I have a list of images along with an audio file, and the video duration matches the audio length. (For example, 5 images and an audio file of 30 seconds, so each image is displayed for 6 seconds).
ffmpeg -framerate 1/6 -i image%d.jpg -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -b:a 192k -shortest output.mp4
Since libx264 is not available in my Android FFmpeg build, what alternative codec or approach should I use to generate the video correctly?