B4J Question JShell Problem

Firpas

Active Member
Licensed User
Longtime User
Hello to everybody

I`m trying to execute a command from my application through JShell but i can`t, however if i write it in system symbol window it run ok.

With this code:

B4X:
If File.Exists(FM.FotoDir, "test.mp4") Then
        File.Delete(FM.FotoDir, "test.mp4")
End If
       
Dim Sh As Shell
       
Sh.Initialize("Shell", File.Combine("C:\ffmpeg64\bin", "ffmpeg.exe"), Array As String(" -r 10", "-f image2", "-s 640x480", "-i "& File.Combine(FM.TempDir, "%08d.png"), "-vcodec libx264", "-crf 25", "-pix_fmt yuv420p " & File.Combine(FM.FotoDir, "test.mp4")))

Sh.WorkingDirectory = "C:\ffmpeg64"
Sh.Run(100)

Here is the result


It seems the option "-r 10" is passed as "r 10"

And with this code:

B4X:
If File.Exists(FM.FotoDir, "test.mp4") Then
       File.Delete(FM.FotoDir, "test.mp4")
 End If
       
Dim Sh As Shell
Sh.Initialize("Shell", File.Combine("C:\ffmpeg64\bin", "ffmpeg.exe") & " -r 10 -f image2 -s 640x480 -i "& File.Combine(FM.TempDir, "%08d.png")     & " -vcodec libx264 -crf 25 -pix_fmt yuv420p " & File.Combine(FM.FotoDir, "test.mp4"),Null)

Sh.WorkingDirectory = "C:\ffmpeg64"
Sh.Run(100)

The result is:


But if i copy and paste the command "C:\ffmpeg64\bin\ffmpeg.exe -r 10 -f image2 -s 640x480 -i C:\Users\Fran\AppData\Roaming\IpCam\Temp\%08d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p C:\Users\Fran\AppData\Roaming\IpCam\Images\test.mp4" in a system symbol window it run ok.

Thank in advance
 

stevel05

Expert
Licensed User
Longtime User
I haven't used it for a while, but I think you need to pass all the arguments using the Arguments method.
B4X:
sh.Arguments =

Edit : Sorry, you need to pass them to the intialize method as a list.

B4X:
Dim L As List = Array As String("-r 10","-f image2") 'etc.

sh.Initialize("Shell",File.Combine("C:\ffmpeg64\bin", "ffmpeg.exe"),L)
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Remove the space in front of the -r? You have " -r 10", try "-r 10".
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
"-pix_fmt yuv420p " & File.Combine(FM.FotoDir, "test.mp4")
I think this should be
B4X:
"-pix_fmt yuv420p", File.Combine(FM.FotoDir, "test.mp4")
making it
B4X:
Sh.Initialize("Shell", File.Combine("C:\ffmpeg64\bin", "ffmpeg.exe"), Array As String("-r 10", "-f image2", "-s 640x480", "-i "& File.Combine(FM.TempDir, "%08d.png"), "-vcodec libx264", "-crf 25", "-pix_fmt yuv420p", File.Combine(FM.FotoDir, "test.mp4")))
 
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
Yes, i know the destination file is another option.
I've tried as you say, but it does not work.

Here is the log:


Thanks for you reply
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
It's this
B4X:
Array As String("-r","10", "-f", "image2", "-s", "640x480", "-i", File.Combine(File.DirTemp, "%08d.png"), "-vcodec", "libx264", "-crf", "25", "-pix_fmt", "yuv420p", File.Combine(File.DirApp, "test.mp4")
Anytime you have a space between parameters, even if they are values for the previous parameter, they are separate parameters. And no, it's not just FFmpeg (I also tried GraphicsMagick) and it's not just the new 1.5 version of JShell (the same happens with 1.3). In the end this really makes sense if you think about it.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…