FFMPEG Video not working on Social Media Platforms (Flutter-FFMPEG)

654 views Asked by At

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.

1

There are 1 answers

0
Raj Dhakad On
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"));
  }