2

In Swift 4, I try to launch a command line to know the frame rate of a video. I use mediainfo tool.

The command to execute is (tested in Terminal)

"/Users/Lorenzo/mediainfo  --Inform="Video;%FrameRate%" /Users/Lorenzo/Desktop/1.mov"

And my swift code for that purpose is:

        let taskfindfps = Process()

        taskfindfps.launchPath = "/Users/Lorenzo/mediainfo"
        taskfindfps.arguments = ["--Inform=\"Video;%FrameRate%\"", myVideo]

        let pipefindfps = Pipe()
        taskfindfps.standardOutput = pipefindfps

But the first argument isn't valid, and I don't know why... The result I have is like the result of the command without the optional argument:

"/Users/Lorenzo/mediainfo /Users/Lorenzo/Desktop/1.mov"

Is there something wrong in "--Inform=\"Video;%FrameRate%\"" ?

DePa
  • 31
  • 4

2 Answers2

1

Without knowing Swift exactly, I would try without escaped quotes, quotes are used on e.g. command line only for forcing the command to not handle the semi column as something for the command line (the command line removes them during processing. Process.arguments being a list, the language is expected to handle correctly itself characters to escape, and if it escapes quotes (instead of processing them as it is done on the command line) MediaInfo will not understand the command.

Jérôme, developer of MediaInfo.

Jérôme Martinez
  • 1,118
  • 5
  • 10
0

You are right, I have my fps number! With the code:

taskfindfps.arguments = [ "--Inform=Video;%FrameRate%", myVideo]

Thank you for your help. And thanks for the powerful MediaInfo tool.

DePa
  • 31
  • 4