10
votes

I'm creating an mp4 video in my Android application by combining a static 1080x1080 .png image with 24/48 .wav audio, trying to generate a file that is compatible with and can be shared to social media platforms, such as Facebook and Instagram (feed).

When I attempt to share the videos I've created, they load and preview in the Instagram app (tested on both Android and iOS), but after hitting the "Share" button on the final step, the UI returns to my feed and the upload progress immediately switches to "Not Posted Yet. Try Again". If I then tap the retry button, I immediately get a dialog stating "Couldn't Post Video" "There was a problem rendering your video. If this keeps happening, you may have to use another video."

I'm using ffmpeg (via tanersener's mobile-ffmpeg library) to do this.

All of the documentation I've found this far does not show highly specific details for upload requirements for Instagram. I'm using AAC for audio, and h.264 (libx264) for video. The sample I'm using has a duration of 30 seconds. The PNG, as mentioned above, is 1080x1080.

I've taken Android out of the picture by using cmd-line ffmpeg on my Mac with the same input files and testing many variations of parameters, none of which create an uploadable video.

I have a similar .mp4 file created by our iOS app (not using ffmpeg), which I brought over to my Android device and it uploads successfully. I've also sent my .mp4 file to the iOS device and it will not upload, so it seems likely it's an encoding issue of some sort.

I have yet to find a combination of ffmpeg parameters that generate a video that can be successfully shared to Instagram.

Is there a way to get verbose logs from Instagram to have some sort of idea why it's rejecting the files?

This is the ffmpeg command I've been concentrating on:

ffmpeg -i test.wav -i test.png -c:a aac -b:a 256k -ar 44100 -c:v libx264 -b:v 5M -r 30 -pix_fmt yuv420p -preset faster -tune stillimage test.mp4

I've tried all sorts of variations of video and audio bitrates, framerates, scaling, presets, tunes, profiles, etc. But no luck as of yet.

Does anyone have a working ffmpeg command for generating videos for Instagram?

1
in IG make a video , share and download same .. then use as input to ffprobe. study the metadata / stdout from ffprobe and then iterate using CLI ffmpeg until u have an output from ffmpeg that "matches" what u observe in ffprobe ... THEN return to android/ffmpeg activity. - Robert Rowntree

1 Answers

14
votes

Your visual input is just one frame. I suspect IG doesn't like this. Loop it to make a video stream out of it.

ffmpeg -i test.wav -loop 1 -i test.png -c:a aac -b:a 256k -ar 44100 -c:v libx264 -pix_fmt yuv420p -preset faster -tune stillimage -shortest test.mp4

(Manual bitrate isn't usually necessary for libx264)