首页 > 解决方案 > FFMPEG 视频不适用于社交媒体平台 (Flutter-FFMPEG)

问题描述

我正在使用Flutter-FFMPEG一个基于 Mobile FFMPEG 的 Flutter 库。我正在从 .bmp 图像列表创建视频。视频作品在 android 或桌面设备媒体播放器中正常播放。

但是当我尝试在社交媒体(比如 Instagram)上分享该视频时,它显示不支持文件格式。

它以前不能在 WhatsApp 上运行,但经过一些谷歌搜索后,我做了一些更改,它现在可以在 WhatsApp 和 Youtube 上运行,但不能在 Instagram、Linkedin 等上运行。

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');
      
    });
  • 我使用的插件(Flutter-FFMPEG)不支持 libx264

  • 我尝试使用 ' -profile:v' 作为基线,但这给出了一个错误,说Error setting profile to baseline.

  • 另外,我尝试先制作一个 .webm 文件,然后将其转换为 mp4。在将 .webm 转换为 mp4 时,我也能够使用 ' -profile:v' 并且没有出错,但输出视频在社交媒体平台上不起作用。

标签: flutterffmpegandroid-ffmpegmobile-ffmpegflutter-ffmpeg

解决方案


推荐阅读