VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Member
    Join Date
    Nov 2008
    Location
    Australia
    Search Comp PM
    I've got a strange one here that I can't figure out. I basically want to pipe the output from calling ffmpeg to a text file. I am using ffmpeg version SVN-r23607.
    If I create a batch file with the following statement it works. All of the output is saved to the text file.
    Code:
    "C:\ffmpeg\ffmpeg.exe" -i "FileInput.mp4" -vcodec copy -acodec copy "FileOutput.mp4" 2> "LogFile.txt"
    If I then convert the same statement to VBScript it no longer works. It doesn't even run the command.
    Code:
    Set objShell = CreateObject("Wscript.Shell")
    Cmd = Chr(34) & "C:\ffmpeg\ffmpeg.exe" & Chr(34) & " -i " & Chr(34) & "FileInput.mp4" & Chr(34) & " -vcodec copy -acodec copy " & Chr(34) & "FileOutput.mp4" & Chr(34) & " 2> " & Chr(34) & "LogFile.txt" & Chr(34)
    objShell.Run Cmd, 10, True
    If I get rid of the part that outputs the info to a text file, then the VBScript works but obviously doesn't save the output to the text file.
    ie
    Code:
    Set objShell = CreateObject("Wscript.Shell")
    Cmd = Chr(34) & "C:\ffmpeg\ffmpeg.exe" & Chr(34) & " -i " & Chr(34) & "FileInput.mp4" & Chr(34) & " -vcodec copy -acodec copy " & Chr(34) & "FileOutput.mp4" & Chr(34)
    objShell.Run Cmd, 10, True
    Very confused as to why it works in a batch file but the same cmd doesn't work in VBScript.
    Is there another way to capture this output in VBScript instead of dumping it out to a text file. I've heard "stdOut" could be used but I can't get this to work either. If someone has an example of this it would be great.
    Quote Quote  
  2. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    For file redirection to work, you have to run the command shell.
    Code:
    Set objShell = CreateObject("Wscript.Shell")
    Cmd = "cmd.exe /c " & Chr(34) & "C:\ffmpeg\ffmpeg.exe" & Chr(34) & " -i " & Chr(34) & "FileInput.mp4" & Chr(34) & " -vcodec copy -acodec copy " & Chr(34) & "FileOutput.mp4" & Chr(34) & " 2> " & Chr(34) & "LogFile.txt" & Chr(34)
    objShell.Run Cmd, 10, True
    Quote Quote  
  3. Member
    Join Date
    Nov 2008
    Location
    Australia
    Search Comp PM
    Originally Posted by Gavino View Post
    For file redirection to work, you have to run the command shell.
    Code:
    Set objShell = CreateObject("Wscript.Shell")
    Cmd = "cmd.exe /c " & Chr(34) & "C:\ffmpeg\ffmpeg.exe" & Chr(34) & " -i " & Chr(34) & "FileInput.mp4" & Chr(34) & " -vcodec copy -acodec copy " & Chr(34) & "FileOutput.mp4" & Chr(34) & " 2> " & Chr(34) & "LogFile.txt" & Chr(34)
    objShell.Run Cmd, 10, True
    Thanks, that solved the problem. I just had to wrap the command up in quotes in order for it to work. As so...

    Code:
    Set objShell = CreateObject("Wscript.Shell")
    Cmd = "cmd.exe /c " & Chr(34) & Chr(34) & "C:\ffmpeg\ffmpeg.exe" & Chr(34) & " -i " & Chr(34)  & "FileInput.mp4" & Chr(34) & " -vcodec copy -acodec copy "  & Chr(34) & "FileOutput.mp4" & Chr(34) & " 2> " &  Chr(34) & "LogFile.txt" & Chr(34) & Chr(34)
    objShell.Run Cmd, 10, True
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!