Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start single process in vba 1

Status
Not open for further replies.

patriciaxxx

Programmer
Jan 30, 2012
277
0
0
GB
I have the following code which loops through one or more files and copys audio mp3 from mp4 files using ffmpeg. The code works but the problem is it opens a new ffmpeg window process for each file it processes and this is not good.

Can any one show me how to do this in just one process ie one ffmpeg window opening up, better still one hidden window?

Dim ffmpegpath As String
ffmpegpath = CurrentProject.path & "\"
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")

Dim i As Long
Dim convertedFile As String
For i = 1 To UBound(sourcePaths)
convertedFile = Me.Text0 & "\" & Left(Mid(sourcePaths(i), InStrRev(sourcePaths(i), "\") + 1), InStrRev(Mid(sourcePaths(i), InStrRev(sourcePaths(i), "\") + 1), ".") - 1) & ".mp3"
wsh.Run """" & ffmpegpath & "ffmpeg.exe"" -i """ & sourcePaths(i) & """ -q:a 0 -map a """ & convertedFile & """"
Next i

On the same not but a different approach the following line in a bat file file does process many files but it only works if you click the bat file, i can't make it work from a vba fuction? ie my code above?

for %%a in (*.mp4) do ffmpeg -i "%%a" -q:a 0 -map a "files\%%~na.mp3"
 
You seem more like a handyman
Surely that's handywomen?

Or to be totally PC - Handyperson ;-)

Patricia -> It's called cargo-cult programming, which Mike will enlighten you on if you need a description.

Nothing wrong with it per sae, but eventually you need to break the bonds of others code and understand your problem and how to construct your own solution, it will come with time as long as you truly have the desire.

I do appreciate your help but could do without the frequent quips.

Don't take Mike's jibes too personally, he means well, and is one of the cleverest guys to frequent these forums, it's just his way of giving you the needed and well deserved kick up the behind, to do better, and improve your coding skills.

Hey when have any of us IT bods been socially articulate!

It's not like I understand every line of code in this discussion hence my interest and enthusiasm, stick with TekTips Patricia, you're in good company [thumbsup]





"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top