使用 Instagram 上传视频时出错 API

Getting error while uploading Video using Instagram API

我正在尝试通过 API 将视频上传到 Instagram。我收到以下错误。请指教 通过此方法上传图片成功。

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

请求 1:
https://graph.facebook.com/xxxxxxx/media?media_type=VIDEO&video_url=/Users/vijayaraghavandevaraj/Downloads/Drops.mp4&access_token={{token}} - 成功

回复:

{
    "id": "xxxxxxxxxxxx"
}

请求 2: Post https://graph.facebook.com/xxxxxxxxxx/media_publish?creation_id=xxxxxxx&access_token={{token}} - 失败

回复:

{
    "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"
    }
}

可能的原因可能是视频要求。查看 https://developers.facebook.com/docs/instagram-api/reference/ig-user/media

我发现 Instagram 需要相当多的视频参数才能完全符合它们的定义 - Graph API 为 Facebook 接受的相同视频可能不会为 Instagram 接受。即使是通过 Instagram 网站上传的视频也不一定通过 API 接受。 我在这个网站上找到了一个工作示例: 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

请记住,API 不接受超过 60 秒的视频(这将导致不同的错误),这是使用网络界面时不存在的另一个限制。