Experimental Learning

I am making a front-end program for the lame mp3 encoder simply for learning experience. I can get it to handle all the options and output the files perfectly. There are a few questions I still have though.

1. Is there a way to hide the command window that pops up when encoding a file and instead show my own progress window
2. How would I detect the progress of the encoding
3. When I have a list of files to encode the only way I can think of is to encode them all at once. Is there a way to encode them one at a time
4. Is there a way to find the bitrate of a file When I add files to the list i want to show the bitrate of that file.

That is what I have for now. Thank you to anyone that can help.

As an aside, I have thought about contacting authors of previous front-ends but dismissed it immediately because those front-ends were written in different languages.



Answer this question

Experimental Learning

  • nhaas

    Excellent freeware dll for all things lame. Also has a very handy Net wrapper for recording, playing etc.

    Check out the forum.

    http://www.un4seen.com/



  • joeydj

    Thank you for the quick replies.

    I am using the following code:

    Private Sub EncodeFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeFiles.Click
    Dim proc As New ProcessStartInfo

    For Each file As String In FileList.Items
    With proc
    .Arguments = args.Text & file & " " & Settings.tbOutput.Text & "\" & IO.Path.GetFileNameWithoutExtension(file) & ".mp3"
    .CreateNoWindow = True
    .FileName = "lame.exe"
    End With
    Process.Start(proc)
    Next
    End Sub

    FileList is a listbox.

    With that code the command windows still show and all processes are start simultaneously.

    As for showing the bitrate. When I add files to the list I want to get the bitrate from the files and add them to a seperate listbox. How would I do this

    Thank you again I have never even used ProcessStartInfo.


  • msmuser

    1) yes! use the ProcessStartInfo class to customize the way the process will be launched. Example:

    Dim thePSI as new ProcessStartInfo("lame.exe")

    thePSI.Arguments = "args here"

    thePSI.CreateNoWindow = true

    Process.Start(thePSI)

    http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx

    2) good question. Not sure about this to be honest apart from cheating and getting the output given from the lame encoder and some how parsing it to the UI, to do this you need to redirect the standard output which is all shown and linked in the document link above.

    3) you can encode them one at a time, depends how you are obtaining the list of files to encode. Simply go through each item in the collection of items you have which are the files, then for each item, start the process and encode using the solution in number 1). Pseudo:

    for each currentitem in theCollectionOfItems

    Create and run process for current item

    next

    4) by default I think it uses 128KBPS for lame, I think you can specify what bitrate to encode in as an argument for lame. Im not sure exactly how to obtain the bitrate of that file being encoded though



  • nikos_22

    I really don't know as I have not used it like this before but what I did notice is that there is an outputRecieved event which means whenever there is output been written to, it will raise the event so you can get the output and set it to the textbox, maybe this would help

    full example, using the WaitForExit():

    http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.outputdatareceived.aspx

    hope this helps you somewhat! :-)



  • yahu_Hugh

    the reason its doing them all at once, or so i appears to do so, is because its going through each item, one after the other. You may wish to add a proc.WaitForExit() to wait until the current file has finished processing. Example:

    For Each file As String In FileList.Items
                With proc

                    .Arguments = args.Text & file & " " & Settings.tbOutput.Text & "\" & IO.Path.GetFileNameWithoutExtension(file) & ".mp3"
                    .CreateNoWindow = True
                    .FileName = "lame.exe"
                End With
                Process.Start(proc).WaitForExit()
            Next

    in regards to still showing the Window, try doing this:

    with proc

       .....

       proc.WindowStyle = ProcessWindowStyle.Hidden

    end with



  • Jack Spade

    I am having difficulties with Process.StandardOutput

    I am using this:

    Private Sub EncodeFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeFiles.Click
    For Each file As String In FileList.Items
    Dim proc As New Process

    With proc.StartInfo
    .Arguments = args.Text & file & " " & Settings.tbOutput.Text & "\" & IO.Path.GetFileNameWithoutExtension(file) & ".mp3"
    .CreateNoWindow = True
    .FileName = "lame.exe"
    .RedirectStandardOutput = True
    .UseShellExecute = False
    End With
    proc.Start()
    Progress.TextBox1.Text = proc.StandardOutput.ReadToEnd
    proc.WaitForExit()
    Next
    End Sub

    FileList is a listbox. args is a TextBox.
    The file encodes properly but all that is output in the textbox is this:
    Writing LAME Tag...done
    ReplayGain: +0.6dB

    That is output after the file is done encoding. I got the code I used from the page that was linked to a few posts up.

    So, how exactly would I use StandardOutput to display my own progress form.

    Thank you for any help you can provide.
    Troy L.


  • pmail

    Thank you for your answers. The WaitForExit worked. Also, I used UseShellExecute = True to stop the window from showing. It is also necessary to do that in order to use RedirectStandardOutput = True.

    Thanks again.


  • Experimental Learning