I am using ffmpeg executeAsyncWithArguments to overlay a single image into a video from start to end, the filterParams I used do work as you can see in the logs. However, it seems that the execution of the command is stuck after the overlaying process, sort of hanging and no logs is happening there after. Btw I used the sample code in pub.dev documentation and non of the print statement is being printed. Can anyone shed light on this? Will really appreciate your help, same with the code, I am stuck on how to proceed. Thanks in advance.
我正在使用ffmpeg ecuteAsyncWithArguments从头到尾将单个图像叠加到视频中,我使用的filterParam的工作方式正如您在日志中看到的那样。然而,在覆盖过程之后,命令的执行似乎停滞不前,有点挂起,此后没有日志发生。顺便说一句,我使用了pub.dev文档中的示例代码,打印的不是print语句。有谁能说明这一点吗?我会非常感谢你的帮助,代码一样,我被困在如何继续。先谢谢你。
//printed filterParams
filterParams: [
-i, video_clip.mp4,
-i, image.png,
- filter_complex,
[1:v]scale=1920:1080[img];
[0:v][img]overlay=W-w-10:H-h-10[out]
-map, [out],
-c:a, copy,
-y, output_video.mp4]
The two execute commands (async and sync).
这两个执行命令(异步和同步)。
final FlutterFFmpeg _flutterFFmpeg = FlutterFFmpeg();
_flutterFFmpeg.executeAsyncWithArguments(filterParams,
(CompletedFFmpegExecution execution) {
print("executionID: ${execution.executionId} exited with rc
${ execution.returnCode}");
}).then((executionId) => print("Async FFmpeg process started with
executionId $executionId."));
//result from async command, the logs end empty
I/flutter (29780): Async FFmpeg process started with executionId 3001.
........
I/mobile-ffmpeg(29780): frame= 129 fps= 31 q=31.0 size= 1024kB time=00:00:04.32 bitrate=1940.3kbits/s dup=1 drop=0 speed=1.03x
I/mobile-ffmpeg(29780): frame= 135 fps= 31 q=31.0 Lsize= 1294kB time=00:00:04.52 bitrate=2341.8kbits/s dup=1 drop=0 speed=1.03x
I/mobile-ffmpeg(29780): video:1292kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
I/mobile-ffmpeg(29780): 0.110388%
I/mobile-ffmpeg(29780):
I tried to run the same filterParams using _ffmpeg.executeWithArguments(filterParams) and it runs fine. The logs ended with FFmpeg exited with rc: 0
我尝试使用_ffmpeg.executeWithArguments(filterParams)运行相同的filterParams,它运行得很好。日志以FFmpeg结束,退出rc:0
FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
_flutterFFmpeg.executeWithArguments(filterParams);
//using flutter_ffmpeg executeWithArguments(filterParams)
I/mobile-ffmpeg( 2199): frame= 89 fps= 30 q=31.0 Lsize= 784kB time=00:00:02.97 bitrate=2159.4kbits/s dup=2 drop=0 speed=1.02x
I/mobile-ffmpeg( 2199): video:782kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
I/mobile-ffmpeg( 2199): 0.155912%
I/mobile-ffmpeg( 2199):
D/flutter-ffmpeg( 2199): FFmpeg exited with rc: 0
My ultimate goal for this project, is to use the async method because the video I am planning to overlay varies from 5sec to 1 minute. I wish to utilize the async to free up the UI.
我这个项目的最终目标是使用异步方法,因为我计划覆盖的视频从5秒到1分钟不等。我希望利用异步来释放用户界面。
更多回答
Would you mind formatting your code, so it's more readable? It shouldn't be all on 1 line. Then, what are your filterParams
? Does it work with executeAsync()
? Does it work with a simplest possible ffmpeg command, maybe just copying the streams to another file with the same format, or just a simple format conversion?
你介意格式化你的代码,使它更具可读性吗?它不应该都在一行上。那么,你的过滤器参数是什么?它可以与ecuteAsync()一起使用吗?它是否适用于最简单的ffmpeg命令,可能只是将流复制到另一个相同格式的文件,或者只是简单的格式转换?
As an advice on formatting, I'd suggest including link to the docs or lib page where you found the information.
作为格式化方面的建议,我建议包括指向您找到信息的文档或库页面的链接。
Sorry for the one line code, I changed it and provided the logs for both execute command. Thanks
对不起的一行代码,我改变了它,并提供了两个执行命令的日志。谢谢
ok, but I think it would be better to post the code for filter params, not just what it prints. Because I see - filter_complex
, is it ok for ffmpeg if it has a space? Anyway, you should test executeAsync() as I suggested earlier. I'd start with a simple conversion and just with a command as string to control what you send to the processor. Then you can take directly the printed filter params, remove all the commas and pass it to executeAsync(). What is the result? Then basically if their example code doesn't work for the simpliest command, you can publish an issue in their project.
好的,但我认为发布过滤器参数的代码会更好,而不仅仅是它打印的内容。因为我看到了-Filter_Complex,如果ffmpeg有空格的话可以吗?无论如何,您应该像我前面建议的那样测试ecuteAsync()。我会从一个简单的转换开始,只使用一个作为字符串的命令来控制您发送给处理器的内容。然后,您可以直接获取打印的筛选器参数,删除所有逗号并将其传递给ecuteAsync()。结果是什么?基本上,如果他们的示例代码对于最简单的命令不起作用,您可以在他们的项目中发布一个问题。
And also I see their project is archived and replaced by FFmpegKit. Maybe you should try using that update.
我还看到他们的项目被存档,并被FFmpegKit取代。也许你应该试着使用那个更新。
我是一名优秀的程序员,十分优秀!