简体   繁体   English

运行ffmpeg终端命令后OSX / Cocoa应用程序崩溃

[英]OSX/Cocoa app crashing when finished running ffmpeg terminal command

I'm running ffmpeg within my Mac app and it's actually creating the output file successfully. 我在Mac应用程序中运行ffmpeg,实际上正在成功创建输出文件。 The problem is that the app crashes as soon as the ffmpeg command is finished. 问题是ffmpeg命令完成后,应用程序便崩溃了。 Any ideas on how to prevent the crash? 关于如何防止坠机的任何想法?

Here's the code I'm using to run ffmpeg in my Mac app: 这是我用于在Mac应用程序中运行ffmpeg的代码:

char ffm_cmd[512];
NSString *command = [NSString stringWithFormat:@"%@%@ \\\n-filter_complex '[0:0][1:0][2:0][3:0]concat=n=%d:v=0:a=1[out]' \\\n-map '[out]' %@/output.wav", escapedPath, concatFiles, count, self.outputFolderPath];
const char *cString = [command cStringUsingEncoding:NSASCIIStringEncoding];
sprintf(ffm_cmd,cString);
system(ffm_cmd);

Figured it out. 弄清楚了。 My command was longer than 512 characters, so I just needed to change the size of my ffm_cmd character property. 我的命令长于512个字符,因此我只需要更改ffm_cmd字符属性的大小即可。

This sounds like a sandboxing issue, can you have a look at console when you run the app (not via Xcode) but via finder.. 这听起来像一个沙盒问题,您可以在运行应用程序时(不是通过Xcode)而是通过finder来查看控制台。

ie find your app and double click it whilst console is open. 即找到您的应用程序,然后在控制台打开的情况下双击它。

If you've never used console: 如果您从未使用过控制台:

1) Press CMD + Space so spotlight pops up 2) Type in: console [press enter] 3) With All Messages high-lighted on the left, click clear display at the top 4) Run your app 1)按CMD +空格键,以弹出聚光灯2)键入:控制台[按Enter] 3)在左侧突出显示“ All Messages ”,单击顶部的clear display 4)运行您的应用

What comes up in there? 那里发生了什么?

Quite often libs can access some areas that are "off bounds" and sandbox (taskgated)throws a hissy fit killing the thread. lib经常可以访问“越界”的某些区域,而沙箱(任务级)则抛出嘶嘶作风,杀死线程。

Cheers, 干杯,

A 一种

There's no need for ffm_cmd at all in the following sequence: 按以下顺序完全不需要ffm_cmd

char ffm_cmd[512];
…
const char *cString = [command cStringUsingEncoding:NSASCIIStringEncoding];
sprintf(ffm_cmd,cString);
system(ffm_cmd);

The string you get back from -[NSString cStringUsingEncoding:] is already perfectly good: 您从-[NSString cStringUsingEncoding:]返回的字符串已经非常好:

const char *cmd = [command cStringUsingEncoding:NSASCIIStringEncoding];
system(cmd);

This rids you of the buffer overflow that was causing your issue, and will also make your code work correctly with filenames containing % characters. 这消除了引起问题的缓冲区溢出,并且还将使您的代码可以正确处理包含%字符的文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM