gpt4 book ai didi

ffmpeg:与 macos 和 swift 一起使用

转载 作者:行者123 更新时间:2023-12-04 23:25:41 25 4
gpt4 key购买 nike

我正在尝试从视频中间提取缩略图。但是,我不确定问题出在 Swift 还是 ffmpeg 中。

以下代码编译但不产生任何结果。

    let frameCount = GetVideoFrameCount(itemPath: itemPath)
let framesIn = frameCount / 2
let framesInStr = "\(framesIn)"

let thumbnailTask: Process = Process()

thumbnailTask.launchPath = self.ffmpegLaunchPath
thumbnailTask.arguments = ["-ss", framesInStr, "-i", itemPath.absoluteString.removingPercentEncoding!, "-vf", "scale=-1:120", "-frames:v", "1", thumbnailPath]
thumbnailTask.standardInput = FileHandle.nullDevice

thumbnailTask.launch()
thumbnailTask.waitUntilExit()

let thumbnailStatus = thumbnailTask.terminationStatus

“frameCount”变量确实包含视频中的帧数。该过程“有效”,因为它不会崩溃, .terminationStatus = 0 但不会生成缩略图 .jpg。

我在 中使用了“-ss”选项。字符串(帧输入) , "\(framesIn)" , 我改了 帧数 到实际数字(即 10000),什么都没有。 “-ss”选项 仅限 如果我使用 则有效字符串(10000) 或任何其他号码。

有人有建议吗?

谢谢。

最佳答案

不幸的是我不能,因为进程没有吐出命令(至少我看不到)。

即使设置日志级别也不起作用。我在参数列表中尝试了“-nostats”和“-loglevel”、“quiet”,但 ffmpeg 仍然吐出它的所有输出。

我刚刚尝试使用“-ss”、“1000”,它奏效了。但是,这仍然不能帮助我解释为什么传入 "(framesIn)"或 String(framesIn) 不起作用。

此外,有时 Process 会成功(即 .terminationStatus = 0),但不会将缩略图写入磁盘。

关于ffmpeg:与 macos 和 swift 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48895074/

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