vb.net - & operator string error with string of arguments to processStartInfo -
i need pass string processstartinfo ffmpeg can call dim.argument , have append strings , variables code parse through files.
i have current filename.mp3 code sees in movedfileinfo won't allow me append string using & operators... help?
i know there may 1 other way utilizing ffmpeg command in separate function loop through directory using "for" i've not found successful command running ffmpeg.exe nor ffprompt in windows. need append carriage return when write merge.txt can't find example... i'm new vba.
these commands work vba complaining & operator in string error the operator '&' not defined types 'string' , 'system.io.fileinfo'.
so understand string i'm passing psi.arguments doesn't fact i'm sending string , variable appended using & operator... use comma or how append variable movedfileinfo ffmpeg -i? psi defined above processstartinfo... i'm not sure types vb recognizes it... haven't found info on processstartinfo kick off ffmpeg exe.
see code below:
imports system imports system.io imports system.text.regularexpressions public class form1 private sub button1_click(byval sender object, byval e eventargs) handles button1.click 'videos sd card on i:\private\avchd\bdmv\stream\ 'store files raid drives in folders structured : ' f:\build\flight#\cam#\<tail_number>_flt_<flt_number>_utc_<start_utc_time>_cam_<cam_number>.mts 'set base dir directory f:\ dim dir string = "c:\" dim video_card_dir string = "c:\1bak\" '"i:\private\avchd\bdmv\stream\" directory.setcurrentdirectory(dir) dim new_flightnum_directory = dir & me.build.text & "\" & flt.text & "\" 'establish new video dir> f: \ build \ flight # \ cam # \ dim new_video_directory = dir & me.build.text & "\" & flt.text & "\" & me.cam.text & "\" 'establish new filename rename video file ' tail # flt # dim new_filename string = tail.text & "_" & flt.text & "_" & utc.text & "_" & cam.text dim ffmpeg string = "c:\ffmpeg\bin\ffmpeg.exe" '****ffmpeg required variables dim psi processstartinfo = new processstartinfo("c:\ffmpeg\bin\ffmpeg.exe") dim proc process = process.start(psi) psi.useshellexecute = true psi.createnowindow = true '****end ffmpeg required variables '!!!!!!!!!!!!!!!!!!!!!!!!!!!need add processing below if statement aboev if folders exist, video processing doesn't attempt run on existing files ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '~~~~~~~~~~~~~~~~~~~~~~~~~~~~start - move down below creation of file structure when doen debugging************ '***start moving files card new directory**** each foundfile string in my.computer.filesystem.getfiles(video_card_dir, microsoft.visualbasic.fileio.searchoption.searchallsubdirectories, "*.mts") dim foundfileinfo new system.io.fileinfo(foundfile) my.computer.filesystem.movefile(foundfile, new_video_directory & foundfileinfo.name) next each foundfile string in my.computer.filesystem.getfiles(video_card_dir, microsoft.visualbasic.fileio.searchoption.searchallsubdirectories, "*.mts") dim movedfileinfo new system.io.fileinfo(foundfile) psi.arguments = "ffmpeg -i " & movedfileinfo & " -vcodec -c libx264 " & movedfileinfo & ".mp4" psi.tostring() 'proc = process.start(psi) '***convert each mts file in new directory mp4**** 'writes filenames merge.txt " path\to\merge.txt , 'file ' f:\path\to\ file1 .mp4 '" ffmpeg can merge, rename 'my.computer.filesystem.writealltext(new_video_directory & "merge.txt", "file '" & movedfileinfo & ".mp4'" & vbcrlf, true) '>>>>need add carriage return text file 'now capture filenames of mp4 , merge 1 mp4 file ' merge f:\path\to\merge.txt merge files & merge them 'psi.arguments = "ffmpeg -f concat -i " & new_video_directory & "merge.txt -c copy " & new_filename & ".mp4" proc = process.start(psi) next '***end merge files*** '~~~~~~~~~~~~~~~~~~~~~~~~~~~~* end - move '***start create storage directory structure *** 'verify if build # directory exists? if my.computer.filesystem.directoryexists(dir & me.build.text) messagebox.show("the build directory exists, moving on create subdirectories") else try 'create new directory f:\ build \ flight # my.computer.filesystem.createdirectory(dir & me.build.text) messagebox.show("the build directory" & dir & me.build.text & " created.") catch ex exception messagebox.show("doh! build directory not created! error: " & ex.message, "error creating directory.", _ messageboxbuttons.ok, messageboxicon.error) end try end if 'verify if flight num directory exists - or create if my.computer.filesystem.directoryexists(new_flightnum_directory) messagebox.show("the flight # folder exists! check have right flight #.") else try 'create new directory f:\ build \ flight # my.computer.filesystem.createdirectory(new_flightnum_directory) 'now create new subdirectories my.computer.filesystem.createdirectory(new_video_directory) messagebox.show("the new flight directory & video cam subdirectories have been created! videos moved , files converted take time.") catch ex exception messagebox.show("doh! flight num or cam directory not created! error: " & ex.message, "error creating directory.", _ messageboxbuttons.ok, messageboxicon.error) end try end if '***end create storage directory structure *** messagebox.show("new merged video file has been created in " & dir & me.build.text & "\" & me.cam.text) end sub end class
the problem & operator in vb used concatenate system.string objects. it's stricter using + concatenate. can't use concatenate string , system.io.fileinfo object together. want file name fileinfo object. has attribute, fileinfo.fullname return full path of file string - documentation.
try instead:
for each foundfile string in my.computer.filesystem.getfiles(video_card_dir, microsoft.visualbasic.fileio.searchoption.searchallsubdirectories, "*.mts") dim movedfileinfo new system.io.fileinfo(foundfile) psi.arguments = "ffmpeg -i " & movedfileinfo.fullname & " -vcodec -c libx264 " & movedfileinfo.fullname & ".mp4" psi.tostring() proc = process.start(psi) next if want replace .mts extension .mp4, instead of appending .mp4 code does, please see this question.
Comments
Post a Comment