Lihn ha
asked on
How to run cmd.exe with over 8191 characters in VB
Hi, I've been dealing with over 8000 video files every month. And I need to quick write a program to pass a ffmpeg command to cmd.exe
Txtcommand ="timeout 5"
For i=0 to 8000
Txtcommand = Txtcommand & "&& ffmpeg -i " & Filelist.List(i) & " -vf ''"drawtext=fontfile=arial.ttf: text='wartermark'"" -f mp4 " & """" & "output" & i &".mp4"""
Next
Shell "C:\Windows\system32\cmd.exe /k " & Txtcommand & "&&EXIT", vbMinimizedNoFocus
It works perfectly If my file list contains less than 20~30 files (depends on path & file name length). More than 30 files, cmd won't launch, because of the maximum length of one command is limited by 8191 characters. Tried to put shell in For...next loop and 8000 cmd windows open at the same time.
For i = 0 to 8000
Shell "C:\Windows\system32\cmd.exe /k ffmpeg -i " & Filelist.List(i) & " -vf ''"drawtext=fontfile=arial.ttf: text='wartermark'"" -f mp4 " & """" & "output" & i &".mp4"" &&EXIT", vbMinimizedNoFocus
Next
I need a solution to separate Txtcommand to multiple run, each run 8k characters.
And how to make VB to know when the current shell command is done and run the next command.
Thanks you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
https://www.experts-exchange.com/questions/29162471/How-to-run-cmd-exe-with-over-8191-characters-in-VB.html?anchorAnswerId=42968930#a42968930
This is your script I tested in Powershell before putting it in to vb, works like a charm.
By the way, can you do me a favor, the final solution to make my job easier and prolly put an end to it.
I want powershell to get-child from one input video folder and run 5 differ ffmpeg to drawtext "watermarkA" to output folder A, drawtext "wartermarkB" to output B and "watermarkC" to output C...
Is it possible?
Thanks.
Hi Mr.Alex, I'm thankful for having your solution
Powershell is so powerful, no escape character needed like cmd. Except $File only contains files name in a directory, no path. It takes time to figure out why ffmpeg get the file name but still show error: no such file or folder This is your script I tested in Powershell before putting it in to vb, works like a charm.
$Files = get-Childitem "E:\input"
Foreach ($File in $Files){ E:\ffmpeg.exe -i E:\input\$File -vf "drawtext=fontfile=arial.ttf:text='wartermark':fontsize=30:fontcolor=white:x=260:y=445" -crf 31 -c:a copy -f mp4 E:\output\$File}
By the way, can you do me a favor, the final solution to make my job easier and prolly put an end to it.
I want powershell to get-child from one input video folder and run 5 differ ffmpeg to drawtext "watermarkA" to output folder A, drawtext "wartermarkB" to output B and "watermarkC" to output C...
Is it possible?
Thanks.
So
You want it like this
E:\output\$File
Would then be
E:\output\"$File + WatermarkB"
I don't quite understand what it is you want me to do, I know it's doable I just don't understand.
Thanks,
Alex
You want it like this
E:\output\$File
Would then be
E:\output\"$File + WatermarkB"
I don't quite understand what it is you want me to do, I know it's doable I just don't understand.
Thanks,
Alex
@linh ha,
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
Open in new window
»bp