Listbox loop help - ffmpeg gui problem

jdkoops

Member
Joined
Sep 5, 2008
Messages
17
Programming Experience
Beginner
Hi,

Hope i explain this properly. I am trying to merge audio files loaded into a listbox with ffmpeg - that writes to streamwriter and creates batch file.

The syntax for doing this with ffmpeg is
ffmpeg -i concat:"audio1.mp3|audio2.mp3|audio3.mp3" merge.mp3

Can anyone help with a loop that i can use that inserts the listbox items into the commandline where audio1/2/3 etc would go? the files in the listbox maybe 3 to 15 files.

Thank you,
J
 
You want the String.Join method. It allows you to join multiple Strings or objects into a single String with each pair separated by a delimiter String. If you really are using .NET 3.0 then you are a little more limited as to the overloads available, so you actually have to pass it a String array. With .NET 4.0 you can pass it just any generic list or an object array. Assuming that the ListBox contains String objects that contain the file names, this will work in .NET 3.0+:
Dim items(Me.ListBox1.Items.Count - 1) As String

Me.ListBox1.Items.CopyTo(items, 0)

Dim commandline As String = String.Format("ffmpeg -i concat:""{0}"" merge.mp3",
                                          String.Join("|",
                                                      items))
and this will work in .NET 4.0+:
Dim items = Me.ListBox1.Items.Cast(Of String)()
Dim commandline = String.Format("ffmpeg -i concat:""{0}"" merge.mp3",
                                String.Join("|",
                                            items))
 
Back
Top