Getting error while uploading Video using Instagram API

Viewed 828

I am trying to upload the video to Instagram via API. I am getting the below error. Please Advice Uploading image via this method is successful.

Reference: https://developers.facebook.com/docs/instagram-api/reference/ig-user/media_publish#creating

Request1:
https://graph.facebook.com/xxxxxxx/media?media_type=VIDEO&video_url=/Users/vijayaraghavandevaraj/Downloads/Drops.mp4&access_token={{token}} - Success

Response:

{
    "id": "xxxxxxxxxxxx"
}

Request2: Post https://graph.facebook.com/xxxxxxxxxx/media_publish?creation_id=xxxxxxx&access_token={{token}} - Failed

Response:

{
    "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 the specs for the supported streams format",
        "fbtrace_id": "AA3qcWZCmMsp0OfEE_m1cLJ"
    }
}
3 Answers

I found that Instagram requires quite a number of video parameters to be exactly as they define - the same video that the Graph API accepts for Facebook might not be accepted for Instagram. Even videos that are accepted via upload through Instagram's website are not necessarily accepted via the API. I found a working example on this site: https://ffmpegfromzerotohero.com/blog/ffmpeg-instagram-best-practices/

ffmpeg -framerate 1/60 -i your_still_picture.jpg -i your_audio_track.wav -map 0:v -map 1:a -r 25 -c:v h264 -tune stillimage -crf 18 -c:a aac -b:a 128k -ac 2 -ar 44100 -pix_fmt yuv420p -max_muxing_queue_size 1024 -shortest your_final_instagram_video.mp4

Keep in mind that the API does not accept videos longer than 60 seconds (which will result in a different error), another limitation that does not exist when using the web interface.

Short answer: You can't upload local media files.

While the error message hints into the direction of wrong video specifications, the actual error comes from the video_url query parameter being a local path.

From the instagram-api docs:

Required for videos and reels. Applies only to videos and reels. Path to the video. We cURL the video using the passed-in URL, so it must be on a public server.

A video created via ffmpeg with specs as proposed above will work.

Related