views:

727

answers:

3

hi guys, i'm playing with a vb6 gui frontend for ffmpeg and as of now all i can do is to call the ffmpeg via cmd.exe which will shows the command prompt while the whole process is still running. And i thought this was the norm seeing how WinFF, another pascal based frontend gui for ffmpeg works.

But i was blown away when i saw this other GVC gui which has a progress bar and everything.

So basically, i'm looking into a way how i could cleanly hide the whole command prompt and link the transcoding progress to a progress bar into my gui.

So here's my plan, I'm thinking of finding a win32 api function which i can call the cmd line and yet hide it, and from another discussion here, i think i would have to read the log file to get the ffmpeg progress information.

So which function should i call for the win32 api? And does anyone knows of a better/easier way to get this done? thanks

Updates:

In case anybody is interested, i find a nice class module on how to grab the cmd output into my vb6 app, and it's by none other than the great joacim :)

+3  A: 

I have written this exact same thing for Java on OSX. Very minimalist logic:

  • You need to read ffmpeg output as it is produced.
  • Parse the output line by line (both CR and LF)
    • Find the 'Duration' line, store the time value as seconds in an integer. "Duration: 00:03:18.48, start: 0.000000, bitrate: 274 kb/s" (CRLF terminated)
    • From that point onward, parse the CR and look for the time (in seconds) completed values. "frame= 2816 fps=667 q=11.0 Lsize= 13036kB time=187.66 bitrate= 569.1kbits/s" (CR terminated, no LF)
    • Do the division (time / duration) and you have a percentage!

I do not believe having ffmpeg write to a log file is going to work. On *nix at least, ffmpeg writes this output to std err, and the status lines that you need to capture do not have a line feed, and so overwrite the previous status line. This is something you can overcome within your own code.

Sorry, can't help with the VB6 part, but would assume it is straight forward to capture output from a process you shell out.

Stu Thompson
thanks man, i'll look into it after finding out how to get the output back from the cmd window :P
melaos
A: 

First excuse my english i'm speak on spanish. I find the answer. 1/First put in the presets, i have this example "Output format MPEG2 DVD HQ"

"-vcodec mpeg2video -vstats_file MFRfile.txt -r 29.97 -s 352x480 -aspect 4:3 -b 4000k -mbd rd -trellis -mv0 -cmp 2 -subcmp 2 -acodec mp2 -ab 192k -ar 48000 -ac 2"

This instruction can make a txt file don't forget includes the commands "-vstats_file Mitxt.txt" into the presets like the example. this can make a report which it's ubicadet in the folder source of your file Source. you can put any name if you want , then you can read this txt withthis example.

Private Sub Timer1_Timer() Dim strLastLine As String 'For example my ruta "C:\Documents and Settings\Gortiz\Mis documentos\file.txt"

strLastLine = ReadLastLineOfFile("C:\Documents and Settings\Gortiz\Mis _ documentos\file.txt"") Lst1.AddItem strLastLine End Sub

Function ReadLastLineOfFile(sFileName As String) As String Dim objFSO, TS Dim sTmpContents As String Set objFSO = CreateObject("Scripting.FileSystemObject") Set TS = objFSO.OpenTextFile(sFileName, 1) sTmpContents = TS.ReadAll TS.Close Set TS = Nothing Set objFSO = Nothing

ReadLastLineOfFile = Split(sTmpContents, vbCrLf)(UBound(Split(sTmpContents, vbCrLf)) - 1) End Function

in a listbox called Lst1 you can saw the result which is. Bitrate, proceced Frames, Time of process in seconds. etc

Regards.

Ramses1974
A: 

Hello All,

Melaos, I try to work on a VB6 ffmpeg projet two, could you show me your work ? I have already made a prog in realbasic but with no parsing method. I would be intersted in parsing the command line return to make my percentage bar working !

Thanks a lot

LwRed