problem with SHELL
Posted
#1
(In Topic #466)
Regular

Using ffprobe in a shell command.
Code
Shell "ffprobe " & PathToAudioFile Code
Shell "ffprobe " & PathToAudioFile TO sVar Code
Shell "ffprobe " & PathToAudioFile For Read As "Process" I must be making a simple mistake here but I can't see it. Any help would be welcome.
Posted
Guru

NOTE: - You need to install 'exiftool'. The good part is that you can add the 'exiftool' to your own program as I did with my program PhotoExif.
<IMG src="https://www.cogier.com/gambas/MusicEXIF.png">
</IMG>
Posted
Regular

The line:-
Code
Shell "exiftool " & User.Home &/ "Music/recordings" &/ "'" & GridViewTracks[Last.Row, 0].text & "'" To sDataI'm running Gambas 3.15.1 in Kubuntu 20.04
I'll try to find out why my system is mis-behaving.
Thanks again
Posted
Regular

bill-lancaster said
…I'll try to find out why my system is mis-behaving…
Hi Bill, your variable is probably empty because the process does not complete before your code proceeds to the next step. You may be able to prove this by single stepping through your code in the IDE.
If this is the case, rewrite the Shell command using the Wait keyword.
Posted
Guru

You could do it with redirecting the output in the command and reading in the file…
(dont forget the 'Wait' arg or you might miss the output
Code
Shell "ffprobe " & Quote(PathToAudioFile) & " 2>/tmp/ffoutput" Wait
sVar = File.Load("/tmp/ffoutput")
Kill "/tmp/ffoutput"
Posted
Regular

Thanks also for suggesting the use of WAIT.
I still get a null string when using ffprobe or ffmpeg. If I print the shell command, copy it and run it in console it works. Doesn't make sense.
Anyway, exiftool does the job (probably better) so I'll move on.
Small point, splitting each line of the exiftool output based on the first ":" preserves the format of date/time values, otherwise for example Duration is shown as "3" instead of "3:30:00".
Thanks for all the ideas.
Posted
Guru

I still get a null string when using ffprobe or ffmpeg. If I print the shell command, copy it and run it in console it works. Doesn't make sense.
Yeah ffprobe and ffmpeg output in a non standard way. redirecting 2> often works for that.
Posted
Guru

Posted
Guru

Only the standard output of the process is retrieved. The error output is not redirected.
If you need to mix both output, use the shell redirection syntax:
Shell "command 2>&1" To Result
I tried it and
Code
Shell "ffprobe " & Quote(filename) & " 2>&1" Wait To mStringDID fill mString with the output.
A bit late for the solution there I guess but that lil bit of info could help someone else in a similar situation i think.
1 guest and 0 members have just viewed this.


