facebookfacebook-graph-apiinstagram-apiinstagram-graph-apiffmpeg-php

Facebook Graph API return OIL Error for some videos


We are using the Facebook Graph API to publish Reels on Instagram business accounts. When uploading videos either via file_url or through chunked uploads, certain videos consistently return an OIL Error. We have carefully reviewed the video specifications listed here: https://developers.facebook.com/docs/page-stories-api/ and verified that all parameters seem correct.

Additionally, we processed the videos using PHP with ffmpeg using the following command, but it did not resolve the issue: graph api response;

"status_code": "IN_PROGRESS",
  "video_status": {
    "uploading_phase": {
      "status": "error",
      "bytes_transferred": 0,
      "source_file_size": 0,
      "errors": [
        {
          "code": 1363008,
          "message": "OIL Error[FILE_NOT_FOUND: 6]: File not found.Caused by exception: facebook_crude_OILException"
        }
      ]
    },
    "processing_phase": {
      "status": "error"
    }
  },

Despite these measures, the Graph API initially reports the uploading_phase status as 'completed', but shortly after, it changes to an error state. This happens consistently for the problematic videos, with the following Graph API response:

ffmpeg -i input.mp4 \
  -c:v libx264 \
  -preset slow \
  -crf 18 \
  -profile:v high \
  -level:v 4.0 \
  -pix_fmt yuv420p \
  -vf "scale=1080:1920" \
  -r 30 \
  -maxrate 15M -bufsize 30M \
  -x264opts keyint=60:min-keyint=30:scenecut=0 \
  -c:a aac \
  -b:a 128k \
  -ar 48000 \
  -ac 2 \
  -movflags +faststart \
  output.mp4

We've also referred to recommendations listed here: https://dev.to/alfg/ffmpeg-for-instagram-35bi but haven't found a solution yet.

We strongly suspect the issue relates to specific video metadata or encoding settings rather than our PHP code, as the issue occurs inconsistently. Some larger videos (e.g., 80MB) are successfully published, while smaller ones (e.g., 50MB) fail.

You can inspect the problematic video here: https://plexorin.com/hub/assets/content-file/test-video-6810c814da067-68178b546649d.mp4

How we can solve this issue? What we change on our ffmpeg code?


Solution

  • I am not sure which command solve it but, it solved with the following ffmpeg command;

    $ffmpegCmd = "ffmpeg -y -i " . escapeshellarg($inputPath) . " " .
                "-vf \"format=yuv420p,scale=1080:1920:force_original_aspect_ratio=decrease," .
                "pad=1080:1920:(ow-iw)/2:(oh-ih)/2,setsar=1\" " .
                "-c:v libx264 -preset medium -profile:v baseline -level 3.0 " .
                "-color_range tv -colorspace bt709 " .
                "-pix_fmt yuv420p " .
                "-r 30 -g 60 -keyint_min 60 -sc_threshold 0 -x264opts no-scenecut " .
                "-c:a aac -b:a 128k -ac 2 -ar 48000 " .
                "-movflags +faststart " .
                "-video_track_timescale 15360 " .
                "-max_muxing_queue_size 9999 " .
                escapeshellarg($outputPath);