I make a call to ffmpeg and ffprobe. This issue I have is that Brew installs them in different locations based on architecture. On an Intel machine the binaries are installed in /usr/local/bin, but on the M1 the binaries are installed in /opt/homebrew/bin.
I'd like to do something like:
let ffprobe = Process()
if intel {
ffprobe.executableURL = URL(fileURLWithPath: "/usr/local/bin/ffprobe")
} else {
ffprobe.executableURL = URL(fileURLWithPath: "/opt/homebrew/bin/ffprobe")
}
I have searched for this and cannot find anything.
I got this answer from the Apple Developer Forums:
var systeminfo = utsname()
uname(&systeminfo)
let machine = withUnsafeBytes(of: &systeminfo.machine) {bufPtr->String in
let data = Data(bufPtr)
if let lastIndex = data.lastIndex(where: {$0 != 0}) {
return String(data: data[0...lastIndex], encoding: .isoLatin1)!
} else {
return String(data: data, encoding: .isoLatin1)!
}
}
print(machine)
Here's the link for reference Apple Developer Forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With