ffmpegでgifからmp4に変換した動画がInstagramに投稿できない

先日のttygifで作成したanimation gifをInstagramに投稿しようとしたところ,animation gifは投稿できるけどanimationせず1枚目の画像が表示されるだけです.ffmpegでmp4に変換するだけで良さそうだけど投稿できません.白い動画でプログレスがずっと表示され,「次へ」を押すとアプリ自体が落ちてしまいます.動画は同端末のvlcなどでは問題なく再生できています.

IMG 20191005 195714

$ ffmpeg -i tty.gif tty.mp4

音声がないのがいけないのかな?と anullsrc フィルタで無音の音声トラックを追加してみても変わらず.

$ ffmpeg -f lavfi -i anullsrc -i tty.gif -shortest tty.mp4

手詰まりになって検索してみると以下のページを発見.

このページによると以下の条件で投稿できないようです.

  • 3秒以下の動画
  • Instagramが受け付けないカラーエンコーディングの利用

今回の動画は20秒ほどなので長さは問題無さそうです.

うまく行っていなかった動画を確認すると元記事と同様 yuv444p を使っているようです.

$ ffprobe tty.mp4 2>&1 | grep -E "Stream.*Video"
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 802x750, 73 kb/s, 4.17 fps, 4.17 tbr, 12800 tbn, 8.33 tbc (default)

てことで,以下のようにカラーエンコーディングに yuv420p を指定して変換すると投稿できました.(音声トラックはあってもなくてもどちらでもOKだった)

$ ffmpeg -i tty.gif -pix_fmt yuv420p -filter_complex "scale=trunc(iw/2)*2:trunc(ih/2)*2" tty.mp4
$ ffprobe tty.mp4 2>&1 | grep -E "Stream.*Video"
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1058x750, 97 kb/s, 16.08 fps, 16.08 tbr, 12352 tbn, 32.17 tbc (default)

この投稿をInstagramで見る

🏛️

pfetch logo #unix

matoken 🏛️さん(@matoken)がシェアした投稿 –

公式の文章があればいいんですが見つからず.以下が少し近い?

変換環境
$ dpkg-query -W ffmpeg
ffmpeg	7:4.1.4-1+b2
$ lsb_release -dr
Description:	Debian GNU/Linux bullseye/sid
Release:	unstable
$ uname -m
x86_64
投稿環境
$ adb shell dumpsys package com.instagram.android | grep -E 'versionCode|versionName'
    versionCode=175574628 minSdk=23 targetSdk=28
    versionName=113.0.0.39.122
$ adb shell getprop ro.bootimage.build.fingerprint
essential/mata/mata:10/QP1A.190711.122/420:user/release-keys
$ adb shell getprop ro.build.version.security_patch
2019-09-05
$ adb shell getprop ro.product.cpu.abilist
arm64-v8a,armeabi-v7a,armeabi

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.