Oppure

Loading
01/09/09 17:55
BeTmAsTeR
Scusate il titolo poco chiaro, stò creando un piccolo convertitore di formati utilizzando ffmpeg, il codice per la conversione non è stato un grosso problema ma mi sono bloccato qui .....

Vorrei far conincidere l' avanzamento che mostra ffmpeg in una progressbar sul form .....

Come faccio ???

grazie in anticipo :hail:
aaa
01/09/09 18:54
GoLDBeRG
non ho capito nemmeno di cosa stai parlando...
aaa
01/09/09 23:19
BeTmAsTeR
allora hai presente quando esegui una conversione con ffmpeg ?
ti viene mostrato l' avanzamento della conversione
dato che stò facendo un prog in vb.net che sfrutta ffmpeg per la conversione di file in altri formati ..... volevo che l' avanzamento di ffmpeg venisse mostrate sul mio form attraverso la progressbar
aaa
02/09/09 8:04
Il Totem
Devi redirigere l'output del programma ffmpeg sulla tua applicazione. Per far questo si usano alcune proprietà di Process. Io ho fatto la stessa cosa con Lame:
P = New Process
            P.StartInfo.FileName = Lame
            P.StartInfo.Arguments = Info.Arguments & String.Format("{0}{1}{0} {0}{2}{0}", Chr(34), File, Info.Folder & "\" & IO.Path.GetFileNameWithoutExtension(File) & ".mp3")
            P.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            P.StartInfo.UseShellExecute = False
            P.StartInfo.RedirectStandardError = True
            P.StartInfo.CreateNoWindow = True
            AddHandler P.ErrorDataReceived, AddressOf Process_DataReceived

            P.Start()
            P.BeginErrorReadLine() 

Solo che al posto di StandardError e ErrorDataReceived ci vanno StandardOutput e OutputDataReceived. Leggi e manipoli i dati nell'evento relativo; io ho usato le espressioni regolari:
Private Sub Process_DataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
        Dim pfMatch As Match = ProcessedFramesReg.Match(e.Data)
        Dim prMatch As Match = ProcessingRateReg.Match(e.Data)
        Dim tpMatch As Match = TimeToProcessReg.Match(e.Data)
        Dim Infos As New System.Text.StringBuilder()
        Dim Percent As Single = -1

        If (pfMatch.Success) And (prMatch.Success) And (tpMatch.Success) Then
            Infos.AppendFormat("Frames processati: {0:N0}/{1:N0}", CInt(pfMatch.Groups("Proc").Value), CInt(pfMatch.Groups("All").Value))
            Percent = 100 * CSng(pfMatch.Groups("Proc").Value) / CSng(pfMatch.Groups("All").Value)
            Infos.AppendFormat(" - Velocità : {0}", prMatch.Groups("Rate").Value)
            Infos.AppendFormat(" - In coda: {0} min", tpMatch.Groups("Time").Value)
        End If

        bgConvert.ReportProgress(Percent, Infos.ToString)
    End Sub
aaa