我正在尝试通过 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: 发帖
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"
}
}
简短回答:您无法上传本地媒体文件。
虽然错误消息暗示了错误的视频规格方向,但实际错误来自于video_url查询参数是本地路径。
来自 instagram-api 文档:
视频和卷轴所需。仅适用于视频和卷轴。视频的路径。 我们使用传入的 URL 对视频进行 cURL,因此它必须位于公共服务器上。
通过 ffmpeg 创建的视频,其规格如上文所建议的那样,可以使用。
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 秒的视频(这将导致不同的错误),这是使用 Web 界面时不存在的另一个限制。