gpt4 book ai didi

flutter - FFMPEG 视频不适用于社交媒体平台 (Flutter-FFMPEG)

转载 作者:行者123 更新时间:2023-12-04 22:50:06 31 4
gpt4 key购买 nike

我正在使用 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');

});
  • 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.

最佳答案

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"));
}

关于flutter - FFMPEG 视频不适用于社交媒体平台 (Flutter-FFMPEG),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67188315/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com