Search code examples
facebook-graph-apivideoffmpegmp4

How to convert a video to be compatible with facebook graph (reel) api


I am currently trying to get this api to work: create user media

Everything works if I try to post photos. But as soon as I try to post a reel I always get the same error:

{
  "error": {
    "message": "The video file you selected is in a format that we don't support.",
    "type": "OAuthException",
    "code": 352,
    "error_subcode": 2207026,
    "is_transient": false,
    "error_user_title": "Unsupported format",
    "error_user_msg": "The video format is not supported. Please check spec for supported streams format",
   "fbtrace_id": "<removed>"
  }
} 

So I look into the reel specifications here: reel specification

Try as I might, I cannot get it to work. I work with technical google searches all day long, yet this time I seem to be looking in a completely wrong direction.

I have tried converters like Any Video Converter.

I have tried ffmpeg with the following command: ffmpeg -i input.mp4 -c:v libx264 -aspect 16:9 -crf 18 -vf "scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2" -fpsmax 60 -preset ultrafast -c:a aac -b:a 128k -ac 1 -pix_fmt yuv420p -movflags +faststart -t 59 -y output.mp4

If there is a solution with ffmpeg I would appreciate it as I could automate much of the process. But if you know of any converter software I would gladly take that as well.

I think the main problem is the container requirement MPEG-4 Part 14. I can't seem to find any software that is able to produce a video with the required format. The closest I have gotten is MPEG-4 Part 10 but that doesn't work with the api.

Any help would be greatly appreciated.


Solution

  • It turned out that the issue was with the file name. Every new conversion resulted in a new file, with the same name.

    To use a video as reel via the api it has to be publicly available on some server. Facebook then cached the video the first time I tried the request. Every subsequent request, even if it was with a new video (with the same name), was not even considered and resulted in the same error.

    Using a new name for the file actually worked. Also, you can use the Facebook Sharing Debugger to clear the cache for your URI.

    Hope this helps.