B4J Question ffmpeg command problem with jshell

zed

Active Member
Licensed User
Hi all,
I am making a utility to convert files to another format.
For this, I use FFMPEG and jshell.
My problem is that the FFMPEG command that I send via jShell does not work.
If I use this same command in PowerShell, it works.

An idea of the problem?
B4J:
Dim command As String  = $"ffmpeg -i ${pathIn}${fileNameIn} ${pathOut}\${fileNameOut}"$
LogColor(command,xui.Color_Cyan)
params.Add(command)
        
Dim dir As String = $"${File.DirApp}\ffmpeg"$ 'FFMPEG Folder
    
Dim sh As Shell
sh.InitializeDoNotHandleQuotes("ffmpeg", File.Combine(dir,"ffmpeg.exe"),params)
sh.WorkingDirectory = dir
sh.Run(-1)
wait for ffmpeg_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)

For this test, FFMPEG must be located in File.DirApp \ffmpeg\.
Download FFMPEG to my Dropbox (44Mb)

 

Attachments

  • Project.zip
    16.7 KB · Views: 55

JackKirk

Well-Known Member
Licensed User
Longtime User
Hi Zed, I have a similar exercise that I have had running for several years.

I have tried to extract the essence of it as:
B4X:
        Public Gen_crlf As String = Chr(13) & Chr(10)
                      
        'Set up batch file d:\VideoCreator Tools\ffmpeg\ffmpeg.bat
        'echo off
        'cd /d d:\VideoCreator Tools\ffmpeg
        'ffmpeg.exe wrk_ffmpeg_parms
        'exit
        wrk_str = "echo off" & Gen_crlf & _
                  "cd /d d:\VideoCreator Tools\ffmpeg" & Gen_crlf & _
                  "ffmpeg.exe " & wrk_ffmpeg_parms & Gen_crlf & _
                  "exit"

        File.WriteString("d:\VideoCreator Tools\ffmpeg", "ffmpeg.bat", wrk_str)

        'Set up shell to ffmpeg process Gen_video_rec.vrec_videoid & ".mpeg"
        Private wrk_sh As Shell
        Private wrk_args As List
        wrk_args.Initialize
        wrk_args.Add("/c")
        wrk_args.Add("d:\VideoCreator Tools\ffmpeg\ffmpeg.bat")

        wrk_sh.Initialize("Event_shell3", "cmd.exe", wrk_args)
                      
        wrk_err_flag = False
                              
        Try
                          
            'make timeout a parameter in camera control (VideoCreator Download Timeout)?
                                  
            'Run shell with a 60 sec timeout
            wrk_sh.Run(60 * DateTime.TicksPerSecond)
                              
        Catch
                                  
            Logger("Run", Gen_crlf & "Error at shell run (ffmpeg)..." & Gen_crlf & "LastException.Message " & LastException.Message)
                                  
            wrk_err_flag = True
                              
        End Try

d:\VideoCreator Tools\ffmpeg\ contains ffmpeg.exe

I haven't tested this in any way but I can assure you it works in my full project.

I hope it helps...
 
Last edited:
Upvote 0

zed

Active Member
Licensed User
I see that your command to launch FFMPEG is different.
Maybe my FFMPEG location is not correct.
I'm going to test that.
Thank you so much
 
Upvote 0

zed

Active Member
Licensed User
I didn't have time to test it immediately. I just did this and it works fine. Thanks again
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…