2

I am using Flutter-FFMPEG a Flutter library based on Mobile FFMPEG. I am creating a video from a list of .bmp images. The video works plays normally in devices media player on android or desktop.

But when I tried to share that video on social media like say Instagram it says file format not supported.

It didn't use to work on WhatsApp but after some googling, I made some changes and it works on WhatsApp and Youtube now but not on Instagram, Linkedin, etc.

void _runFFmpeg() async {
    print('Run FFMPEG');
   
    var dir = await getApplicationDocumentsDirectory();
    var output = await getExternalStorageDirectory();
    String videoSize = '$ImageWidth:$ImageSize';
    print("${ImageWidth}x$ImageSize");
    var arguments = [
      "-y", // replace output file if it already exists
      "-i", "${output.path}/frame_%d.bmp",
       
      "-s", '${ImageWidth}x$ImageSize',
      "-framerate", "30", // framrate
      
      "-c:v", "libvpx",
      
      '-ab', '128k',
      '-ar', '44100',
      '-strict', 'experimental',
     
      "-vcodec", "libx264",

      "-pixel_format", "yuv420p",

      "-preset", "ultrafast",

      "-tune", "animation",

      "${output.path}/test.mp4"
    ];
   
    await _flutterFFmpeg.executeWithArguments(arguments).then((rc) {
      print('Process done with $rc');
      
    });
  • The plugin I am using (Flutter-FFMPEG) didn't support libx264

  • I tried using '-profile:v' to baseline but that gives an error, saying Error setting profile to baseline.

  • Also, I tried to first make a .webm file and then convert that to mp4. I was also able to use '-profile:v' when converting .webm to mp4 and gave no error but the output video didn't work on Social Media platforms.

Raj Dhakad
  • 852
  • 2
  • 17
  • 39
  • 1
    I'm not really sure if this applies, but [What are the video upload requirements for IGTV on Instagram?](https://www.facebook.com/help/instagram/1038071743007909) shows some requirements. – Hernán Alarcón Apr 21 '21 at 02:00
  • Well, my video is in .mp4 format and complies with all standard requirements. Also, the video is just 6 seconds long and is not working at all on Instagram from stories, posts, chat nowhere. It's an FFmpeg encoding problem since I made the video from a list of images using the FFmpeg library. – Raj Dhakad Apr 21 '21 at 02:07
  • 1
    I'm having the same issue. Did you ever find a solution? – Lokua Mar 14 '22 at 19:00
  • 1
    @Lokua, I have added an answer, I processed the faulty video again. The tags to be used depend on ur video type I have all the tags I tried. – Raj Dhakad Apr 29 '22 at 09:50

1 Answers1

0
fixFFMPEG(int imageWidth, int imageSize) async {
    print('Fix FFMPEG');
    var output = await getExternalStorageDirectory();
    var arguments2 = [
      '-y',
      // "-s",
      // '${imageWidth}:$imageSize',
      '-i',
      '${output.path}/testNew.mp4',
      "-framerate", "30", // framrate
      "-vcodec", "h264",
      "-c:v", "libx264rgb",
      "-c:a", 'acc',
      '-ab', '128k',
      '-ar', '44100',
      '-strict', 'experimental',
      // '-c',
      // 'copy',
      // '-strict',
      // '-2',
      "-vprofile",
      "baseline",
      "-level",
      "3.0",
      "-an",
      "-pixel_format", "yuv420p",
      // '-vtag',
      // 'avc1',
      // "-vprofile",
      // "baseline",
      // "-level",
      // "3.0",
      // "-brand", "mp42",
      '${output.path}/fixedvideo1.mp4'
    ];
    // await _flutterFFmpeg
    //     .executeWithArguments(arguments2)
    //     .then((rc) => print("FFmpeg process2 exited with rc $rc"));
  }
Raj Dhakad
  • 852
  • 2
  • 17
  • 39