Jump to content

[SOLVED] ProgressBar - External software


Recommended Posts

Hi guys, i have some problem with this ProgressBar. The output of the software:

libavutil     51. 39.100 / 51. 39.100
  libavcodec     54.  3.100 / 54.  3.100
  libavformat   54.  1.100 / 54.  1.100
  libavdevice   53.  4.100 / 53.  4.100
  libavfilter    2. 62.100 /  2. 62.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc   52.  0.100 / 52.  0.100
Input #0, flv, from 'C:\Test.flv':
  Metadata:
    starttime      : 0
    totalduration   : 262
    totaldatarate   : 305
    bytelength    : 9979627
    canseekontime   : true
    sourcedata    : B9503B12BHH1329724166020683
    purl            :
    pmsg            :
  Duration: 00:04:21.95, start: 0.000000, bitrate: 304 kb/s
    Stream #0:0: Video: flv1, yuv420p, 400x226, 242 kb/s, 29.92 tbr, 1k tbn, 1k
tbc
    Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
[buffer @ 022477A0] w:400 h:226 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
Output #0, avi, to 'C:\Test.avi':
  Metadata:
    starttime      : 0
    totalduration   : 262
    totaldatarate   : 305
    bytelength    : 9979627
    canseekontime   : true
    sourcedata    : B9503B12BHH1329724166020683
    purl            :
    pmsg            :
    ISFT            : Lavf54.1.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 400x226, q=2-31, 200
kb/s, 29.92 tbn, 29.92 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 22050 Hz, stereo, s16, 128 kb
/s
Stream mapping:
  Stream #0:0 -> #0:0 (flv -> mpeg4)
  Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
frame=  218 fps=  0 q=7.4 size=  416kB time=00:00:07.20 bitrate= 473.2kbits/s
frame=  455 fps=454 q=5.8 size=  726kB time=00:00:15.17 bitrate= 392.0kbits/s
frame=  687 fps=457 q=9.6 size= 1078kB time=00:00:22.88 bitrate= 385.9kbits/s
frame=  927 fps=463 q=17.7 size=    1468kB time=00:00:30.90 bitrate= 389.1kbits/
frame= 1142 fps=456 q=19.2 size=    1786kB time=00:00:38.11 bitrate= 383.9kbits/
frame= 1383 fps=460 q=18.7 size=    2099kB time=00:00:46.18 bitrate= 372.4kbits/
frame= 1632 fps=466 q=21.0 size=    2414kB time=00:00:54.51 bitrate= 362.7kbits/
frame= 1732 fps=340 q=22.8 size=    2543kB time=00:00:57.83 bitrate= 360.2kbits/
frame= 1732 fps= 91 q=22.8 size=    2544kB time=00:00:57.86 bitrate= 360.2kbits/
frame= 1958 fps=101 q=16.3 size=    2866kB time=00:01:05.38 bitrate= 359.1kbits/
frame= 2224 fps=111 q=25.5 size=    3204kB time=00:01:14.29 bitrate= 353.3kbits/
frame= 2484 fps=121 q=13.5 size=    3549kB time=00:01:22.99 bitrate= 350.3kbits/
frame= 2749 fps=131 q=18.1 size=    3892kB time=00:01:31.82 bitrate= 347.2kbits/
frame= 2994 fps=140 q=31.0 size=    4278kB time=00:01:39.99 bitrate= 350.4kbits/
frame= 3237 fps=147 q=28.8 size=    4630kB time=00:01:48.14 bitrate= 350.7kbits/
frame= 3484 fps=155 q=25.7 size=    4941kB time=00:01:56.42 bitrate= 347.6kbits/
frame= 3775 fps=164 q=16.6 size=    5267kB time=00:02:06.11 bitrate= 342.1kbits/
frame= 4065 fps=173 q=14.2 size=    5639kB time=00:02:15.81 bitrate= 340.1kbits/
frame= 4319 fps=180 q=24.0 size=    6008kB time=00:02:24.32 bitrate= 341.0kbits/
frame= 4543 fps=186 q=22.7 size=    6342kB time=00:02:31.79 bitrate= 342.3kbits/
frame= 4786 fps=192 q=28.5 size=    6687kB time=00:02:39.92 bitrate= 342.5kbits/
frame= 5040 fps=198 q=31.0 size=    7075kB time=00:02:48.43 bitrate= 344.1kbits/
frame= 5284 fps=204 q=24.6 size=    7394kB time=00:02:56.58 bitrate= 343.0kbits/
frame= 5516 fps=208 q=31.0 size=    7709kB time=00:03:04.34 bitrate= 342.6kbits/
frame= 5758 fps=214 q=21.2 size=    7995kB time=00:03:12.41 bitrate= 340.4kbits/
frame= 6041 fps=220 q=11.8 size=    8319kB time=00:03:21.84 bitrate= 337.6kbits/
frame= 6279 fps=225 q=31.0 size=    8670kB time=00:03:29.81 bitrate= 338.5kbits/
frame= 6491 fps=228 q=31.0 size=    9071kB time=00:03:36.92 bitrate= 342.6kbits/
frame= 6756 fps=233 q=20.2 size=    9359kB time=00:03:45.77 bitrate= 339.6kbits/
frame= 7004 fps=238 q=18.4 size=    9652kB time=00:03:54.03 bitrate= 337.9kbits/
frame= 7260 fps=242 q=10.3 size=    9940kB time=00:04:02.59 bitrate= 335.7kbits/
frame= 7553 fps=248 q=2.0 size=   10177kB time=00:04:12.42 bitrate= 330.3kbits/s
frame= 7838 fps=254 q=1.6 Lsize=   10652kB time=00:04:21.99 bitrate= 333.1kbits/
video:6124kB audio:4095kB global headers:0kB muxing overhead 4.236753%

The value for the progress bar are:

Duration: 00:04:21.95 --> time=00:04:21.99

The software isn't accurate at 100% but the last line change from:

size= --> Lsize=

So maybe i can use this for stop the ProgressBar.

The script:

#include <Constants.au3>

Local $line, $fulltime, $lastreturn
Local $input = "C:\input.flv"
Local $output = "C:\output.avi"
Local $soft = "C:\ffmpeg.exe"

GUICreate("Progressbar", 220, 100, -1, -1)
$process = GUICtrlCreateProgress(10, 10, 200, 20)
GUISetState()
$CMDDir = $soft & " -i " & $input & " -y " & $output
ConsoleWrite($CMDDir)
Local $PID = Run(@ComSpec & " /c " & $CMDDir, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;run ffmpeg as stdout child
While 1
    $line &= StdoutRead($PID) ;read stdout
    If @error Then ExitLoop ;exit loop when stdout stream ends
    If Not $fulltime Then ;runs if the total length is unknown
        $return = StringRegExp($line,"Duration: (\d{2}):(\d{2}):(\d{2})",1) ;get the full length of the file
  If IsArray($return) Then
            $fulltime = $return[0]*3600 + $return[1]*60 + $return[2] ;convert the length to seconds.
        EndIf
    EndIf
    $array = StringSplit($line,@CRLF)   ;create an array with lines like this: frame= 962 fps=374 q=31.0 size=  2242kB time=40.12 bitrate= 457.7kbits/s
    $return = StringRegExp($array[$array[0]-1],"time=(\d+)",1) ;grab the amount of seconds from the second to last line. (that one is always complete)
If @error Then ContinueLoop
    If $return[0] <> $lastreturn Then ;if the progress changed this is true
        $lastreturn = Number($return[0])
        GUICtrlSetData($process,Int(($lastreturn/$fulltime)*100)) ;set the processbar
    EndIf
WEnd

Not work and i don't know where is the error. Some advice?

If someone want to do a test, can find the software here,

Thanks :)

Edited by johnmcloud
Link to comment
Share on other sites

  • 9 months later...
  • 3 months later...
  • 9 months later...

FYI the console output in #1 is from ffmpeg.exe

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

Guys that was all the code with comment for any line of the script. The only change i have made to the first script for make it "working" you can find on the second post, no mistery or missing part.

Anyway we are talk about 2 years ago and maybe something has change with the console output, if was that is normal that script fails. No time to check it sorry but i'm sure with a little of appointment you can do it, good luck ;)

Edited by johnmcloud
Link to comment
Share on other sites

thanks for posting johnmcloud. I am a beginner trying to understand this so I can figure it out and hopefully know what to do if changes are needed in the future. what does the line look like after the change you made?

$return  = $return[0]*3600 + $return[1]*60 + $return[2]

or

$return = StringRegExp($return[0]*3600 + $return[1]*60 + $return[2],"time=(d+)",1)

or just

$return[0]*3600 + $return[1]*60 + $return[2]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...