Sign in to follow this  
Followers 0
ajenkins

Run FFMPEG for all files in scriptdir with prog bar

13 posts in this topic

I have been trying to create an autoit frontend to replace my .bat files for ffmpeg. I have tried what I could find in past posts here, but couldn't get any working. I need a script that will run all files in the dir reguardless of type, like the [for %a in ("*.*")] command in .bat. I would also like a progress bar for the current ffmpeg encode (not folder progress). Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <File.au3>

$somefolder = "C:\videos\test"
$start = 0
$length = 30

$Afiles = _FileListToArray($somefolder)

for $i = 1 to $Afiles[0]
   $file = $Afiles[$i]
   runwait("ffmpeg -sameq -ss " & $start & " -t " & $length & " -i " & $file & " " & stringtrimright($file , 4) & "_output.mp4")
next

This would try to convert every item of the array into a 30 second mp4.  Look at progresson,  and just increment the bar 1/$Array[0] each time through the loop.

*edit:  changed that to runwait in case your array is more than a few.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

hey boththose thanks for the answer. but I have tried for the past hour and all I get is a ffmpeg screen popup real fast (i can't see what the error is). then nothing. I have tried with other settings, like the ones from your posts in "easy video trimmer", with same results.

Share this post


Link to post
Share on other sites

I got it working a little. your settings "-Sameq" is deprecated in newer ffmpeg builds. then the script doesn't work with files containing spaces in the name. Is there a way to add handling for spaces?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i imagine its just a quotes issue, i will download the new ffmpeg and see if i can break it in the same fashion.  can we see your code and work with that so we are only fixing it once?

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I also think it should be a quote issue. but still can't get it. Here is a piece of what I'm dealing with. Thanks for the help, it is really nice that experts take time to help us beginners

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

gui4()
Func gui4()
#Region ### START Koda GUI section ### Form=manualencodesettings.kxf
$ManualEncodeSettings = GUICreate("Manual Encode Settings", 472, 420)
GUISetFont(8, -1, "Arial")
GUISetBkColor(0x3E3E3E)
$MAN_VGroup1 = GUICtrlCreateGroup("Video Settings", 16, 16, 169, 353)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$MAN_VCodecCombo1 = GUICtrlCreateCombo("", 24, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "libx264|copy|none")
$MAN_VSizeCombo1 = GUICtrlCreateCombo("", 24, 272, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "1920x1080|1792x1008|1664x936|1536x864|1408x792|1280x720|1152x648|1024x576|896x504|768x432|640x360|512x288|384x216|256x144|128x72")
$MAN_VCropInput1 = GUICtrlCreateInput("", 24, 328, 121, 21)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_AGroup1 = GUICtrlCreateGroup("Audio Settings", 192, 16, 169, 137)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$MAN_ACodecCombo1 = GUICtrlCreateCombo("", 200, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "copy|aac|ac3|mp3|none")
$MAN_AChannelCombo1 = GUICtrlCreateCombo("", 200, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "6|5|4|3|2|1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_GlobalGroup1 = GUICtrlCreateGroup("Global Settings", 192, 160, 169, 241)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$MAN_ContainerCombo1 = GUICtrlCreateCombo("", 200, 200, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "mkv|mp4")
$MAN_OffsetInput1 = GUICtrlCreateInput("", 200, 312, 121, 21)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_DurrationInput1 = GUICtrlCreateInput("", 200, 368, 121, 21)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_SubCombo1 = GUICtrlCreateCombo("", 200, 256, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "copy|none|ass|dvdsub|mov_text|srt|subrip")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_EncodeButton1 = GUICtrlCreateButton("ENCODE", 376, 376, 75, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0x808080)
$Pic1 = GUICtrlCreatePic(@TempDir&"\All-Encode GUI\risa1.jpg", 369, -2, 100, 140)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetState(-1, $GUI_DISABLE)
$MAN_VCodecLabel1 = GUICtrlCreateLabel("Video Codec", 24, 40, 65, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_SpeedLabel1 = GUICtrlCreateLabel("Encode Speed", 24, 96, 75, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_VRateRadio1 = GUICtrlCreateRadio("", 32, 176, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_VRateRadio2 = GUICtrlCreateRadio("", 32, 192, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_VSIzeLabel1 = GUICtrlCreateLabel("Change Video Size", 48, 248, 94, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_VCropCheckbox1 = GUICtrlCreateCheckbox("", 24, 304, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_VRate = GUICtrlCreateGroup("Video Rate", 24, 152, 145, 89)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$MAN_VRateInput1 = GUICtrlCreateInput("", 32, 216, 121, 21)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_ACodecLabel1 = GUICtrlCreateLabel("Audio Codec", 200, 40, 65, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_AChannelLabel1 = GUICtrlCreateLabel("Audio Channels", 200, 96, 78, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_ContainerLabel1 = GUICtrlCreateLabel("Output Container", 200, 184, 84, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_OffsetLabel1 = GUICtrlCreateLabel("Offset Time [hh:mm:ss]", 224, 288, 111, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_DurrationLabel1 = GUICtrlCreateLabel("Durration [hh:mm:ss]", 224, 344, 100, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_OffsetCheckbox1 = GUICtrlCreateCheckbox("", 200, 288, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_DurrationCheckbox1 = GUICtrlCreateCheckbox("", 200, 344, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_VCropLabel1 = GUICtrlCreateLabel("Crop Video e.g. 720:352", 48, 304, 119, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_VRateLabel1 = GUICtrlCreateLabel("CRF [0-51]", 56, 176, 55, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_VRateLabel2 = GUICtrlCreateLabel("BitRate e.g. 1000k", 56, 192, 93, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_VSizeCheckbox1 = GUICtrlCreateCheckbox("", 24, 248, 17, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
$MAN_SubLabel1 = GUICtrlCreateLabel("Subtitle Codec", 200, 232, 73, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetColor(-1, 0xFFFFFF)
$MAN_SpeedCombo1 = GUICtrlCreateCombo("", 24, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKALL)
GUICtrlSetData(-1, "veryslow|slower|slow|medium|fast|faster|veryfast|superfast|ultrafast")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            exitprog()
        Case $MAN_VRateRadio1
            Global $MAN_VrateType1 = '-crf'
        Case $MAN_VRateRadio2
            Global $MAN_VrateType1 = '-b:v'
        Case $MAN_VCropCheckbox1
            If GUICtrlRead($MAN_VCropCheckbox1) = $GUI_CHECKED Then
                Run("C:\WINDOWS\system32\cmd.exe")
                WinWaitActive("C:\WINDOWS\system32\cmd.exe")
                send('set path=' & @TempDir & "{ENTER}")
                Send('for %a in ("*.*") do ffmpeg.exe -ss 00:45:00 -t 00:00:01 -i "%a"  -vf cropdetect -f null /dev/null' & "{ENTER}")
                Send(' for %a in ("*.*") do ffmpeg.exe -i "%a"  -vf cropdetect -ss 00:00:01 -t 00:00:01 -f null /dev/null' & "{ENTER}")
                Send(' exit')
            EndIf
        Case $MAN_EncodeButton1
            Global $MAN_VCodecVal1 = GUICtrlRead($MAN_VCodecCombo1)
            Global $MAN_SpeedVal1 = GUICtrlRead($MAN_SpeedCombo1)
            Global $MAN_VrateVal1 = GUICtrlRead($MAN_VRateInput1)
            Global $MAN_ACodecVal1 = GUICtrlRead($MAN_ACodecCombo1)
            Global $MAN_ContainerVal1 = GUICtrlRead($MAN_ContainerCombo1)

            Global $MAN_AChannelVal1 = GUICtrlRead($MAN_AChannelCombo1)
            Global $MAN_ArateVal1 = $MAN_AChannelVal1 * 64
            Global $MAN_SubVal1 = GUICtrlRead($MAN_SubCombo1)
            If GUICtrlRead($MAN_VCropCheckbox1) = $GUI_CHECKED Then
                Global $MAN_VCropVal1 = '  -vf crop=' & GUICtrlRead($MAN_VCropInput1)
            Else
                Global $MAN_VCropVal1 = ' '
            EndIf
            If GUICtrlRead($MAN_VSizeCheckbox1) = $GUI_CHECKED Then
                Global $MAN_VSizeVal1 = GUICtrlRead($MAN_VSizeCombo1)
                Global $MAN_VSizeVal2 = '-s:v  ' & $MAN_VSizeVal1
            Else
                Global $MAN_VSizeVal2 = ' '
            EndIf
            If GUICtrlRead($MAN_OffsetCheckbox1) = $GUI_CHECKED Then
                Global $MAN_OffsetVal1 = '  -ss  ' & GUICtrlRead($MAN_OffsetInput1)
            Else
                Global $MAN_OffsetVal1 = ' '
            EndIf
            If GUICtrlRead($MAN_DurrationCheckbox1) = $GUI_CHECKED Then
                Global $MAN_DurrationVal1 = '  -t  ' & GUICtrlRead($MAN_DurrationInput1)
            Else
                Global $MAN_DurrationVal1 = ' '
            EndIf
            If $MAN_VCodecVal1 = "libx264" Then
                Global $MAN_VCodecString1 = '  -c:v libx264 -preset  ' & $MAN_SpeedVal1 & '  ' & $MAN_VrateType1 & '  ' & $MAN_VrateVal1 & '  ' & $MAN_VSizeVal2 & '  -refs 4 -profile:v baseline  ' & $MAN_VCropVal1
            ElseIf $MAN_VCodecVal1 = "copy" Then
                Global $MAN_VCodecString1 = '  -c:v copy  '
            ElseIf $MAN_VCodecVal1 = "none" Then
                Global $MAN_VCodecString1 = '  -vn  '
            EndIf
            If $MAN_ACodecVal1 = "copy" Then
                Global $MAN_ACodecString1 = '  -c:a copy  '
            ElseIf $MAN_ACodecVal1 = "none" Then
                Global $MAN_ACodecString1 = '  -an  '
            Else
                Global $MAN_ACodecString1 = '  -c:a  ' & $MAN_ACodecVal1 & '  -ac  ' & $MAN_AChannelVal1 & '  -b:a   ' & $MAN_ArateVal1 & 'k'
            EndIf
            If $MAN_SubVal1 = "copy" Then
                Global $MAN_SubString1 = '  -c:s copy  '
            ElseIf $MAN_SubVal1 = "none" Then
                Global $MAN_SubString1 = '  -sn  '
            Else
                Global $MAN_SubString1 = '  -c:s  ' & $MAN_SubVal1
            EndIf
            GUISetState(@SW_HIDE, $ManualEncodeSettings)
            manencode()
    EndSwitch
WEnd
EndFunc

Func manencode()

$somefolder = FileSelectFolder("Select Encode Folder", "")

$Afiles = _FileListToArray($somefolder)

for $i = 1 to $Afiles[0]
   $file = $Afiles[$i]
   RunWait('ffmpeg.exe -i ' & $file & ' -map 0  ' & $MAN_VCodecString1 & $MAN_ACodecString1 & $MAN_OffsetVal1 & $MAN_DurrationVal1 & $MAN_SubString1 & ' -dn -y "' & stringtrimright($file , 4) & '_output.' & $MAN_ContainerVal1 & '"')

next

EndFunc

Func exitprog()
    if ProcessExists("ffmpeg.exe") Then
        ProcessClose("ffmpeg.exe")
    EndIf
Exit
EndFunc
Edited by ajenkins

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

try 

RunWait('ffmpeg.exe -i ' & " & $file & " & ...

and thats a helluva "beginner" script.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

you were on the right track. This was the answer. Now I can't quite get my head wrapped around how the progress bar works. I have seen several scripts in the forum giving examples, but none work for me. I will keep trying, but welcome any help if you can give it. Thanks again.

$ffmpeg = @ScriptDir & "\ffmpeg.exe"
$somefolder = FileSelectFolder("Select Encode Folder", "")

$Afiles = _FileListToArray($somefolder)

for $i = 1 to $Afiles[0]
   $file = $Afiles[$i]
   RunWait($ffmpeg & ' -i "' & $file & '" [ffmpeg encode settings] "' & stringtrimright($file , 4) & '_output.mp4"', $somefolder)
next

Share this post


Link to post
Share on other sites

$ffmpeg = @ScriptDir & "\ffmpeg.exe"
$somefolder = FileSelectFolder("Select Encode Folder", "")

$Afiles = _FileListToArray($somefolder)
progresson("TEST" , "TEST")

for $i = 1 to $Afiles[0]
   $file = $Afiles[$i]
   RunWait($ffmpeg & ' -i "' & $file & '" [ffmpeg encode settings] "' & stringtrimright($file , 4) & '_output.mp4"', $somefolder)
   progressset(($i/$Afiles[0]) * 100)
next


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Really nice boththose! I was able to take it and figure out how to set progress in a bar on my gui. But what about another progress for the individual encodes (current process), I have been looking into it and I know it includes stdout, But the examples for this with ffmpeg give me a progress bar that doesn't move.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

depends on what you are doing.  Not all output is useful for progress bars.

add this to the end of your ffmpeg cmd  "1> test.txt 2>&1" so it looks something like:

run("ffmpeg -ss " & $start & " -t " & $length & " -i " & '"' & $file & '"' & " " & stringtrimright($file , 4) & "_output.mp4 1> test.txt 2>&1")

that will dump the contents of the cmd window to test.txt, (i suppose you could read that on the fly if you really dont care about speed) that should give you a static set of data to see if you could reasonably walk a progress from the StdOut

 

for instance the output as it converts from .3gp to .mp4 is.....not terribly useful for progress from what i can tell.  Math would be fairly easy if it was giving up the frame or time as it worked. 

 

[libx264 @ 0000000005600640] frame I:1     Avg QP:24.04  size: 94124

[libx264 @ 0000000005600640] frame P:88    Avg QP:24.82  size: 35337
[libx264 @ 0000000005600640] frame B:16    Avg QP:26.91  size: 12428
[libx264 @ 0000000005600640] consecutive B-frames: 74.3% 11.4% 14.3%  0.0%
[libx264 @ 0000000005600640] mb I  I16..4: 14.8% 72.0% 13.1%
[libx264 @ 0000000005600640] mb P  I16..4:  1.5%  4.5%  0.9%  P16..4: 52.0% 12.2%  6.4%  0.0%  0.0%    skip:22.5%
[libx264 @ 0000000005600640] mb B  I16..4:  0.1%  0.2%  0.1%  B16..8: 49.1%  3.8%  0.6%  direct: 1.5%  skip:44.6%  L0:49.1% L1:48.0% BI: 2.9%
[libx264 @ 0000000005600640] 8x8 transform intra:65.5% inter:64.2%
[libx264 @ 0000000005600640] coded y,uvDC,uvAC intra: 63.6% 47.7% 8.5% inter: 22.2% 22.4% 0.6%
[libx264 @ 0000000005600640] i16 v,h,dc,p: 16% 29% 29% 26%
[libx264 @ 0000000005600640] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 17% 33%  5%  5%  4%  6%  5%  7%
[libx264 @ 0000000005600640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 17% 23%  5%  5%  5%  5%  4%  5%
[libx264 @ 0000000005600640] i8c dc,h,v,p: 61% 20% 15%  3%
[libx264 @ 0000000005600640] Weighted P-Frames: Y:1.1% UV:0.0%
[libx264 @ 0000000005600640] ref P L0: 71.7% 22.4%  4.4%  1.5%  0.0%
[libx264 @ 0000000005600640] ref B L0: 93.3%  6.2%  0.5%
[libx264 @ 0000000005600640] ref B L1: 95.4%  4.6%
[libx264 @ 0000000005600640] kb/s:7777.43
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

what about something like this? But maybe a working version... I found the stdout script on an old post, but can't get it working.

#include <Constants.au3>
 #include <File.au3>
 #include <MsgBoxConstants.au3>

Local $line, $fulltime, $lastreturn


$somefolder = @ScriptDir
$Afiles = _FileListToArray($somefolder)
$ffmpeg = @ScriptDir & "ffmpeg.exe"

GUICreate("My GUI Progressbar", 220, 100, 100, 200)
$process = GUICtrlCreateProgress(10, 10, 200, 20)
GUISetState()

for $i = 1 to $Afiles[0]
    $file = $Afiles[$i]
    $PID = RunWait($ffmpeg & ' -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"')
Next
While 1
    $line &= StdoutRead($PID)
    If @error Then ExitLoop
    If Not $fulltime Then
        $return = StringRegExp($line,"Duration: (\d{2}):(\d{2}):(\d{2})",1)
        If IsArray($return) Then
            $fulltime = $return[0]*3600 + $return[1]*60 + $return[2]
        EndIf
    EndIf
    $array = StringSplit($line,@CRLF)
    $return = StringRegExp($array[$array[0]-1],"time=(\d+)",1)
    If @error Then ContinueLoop
    If $return[0] <> $lastreturn Then
        $lastreturn = Number($return[0])
        GUICtrlSetData($process,Int(($lastreturn/$fulltime)*100))
    EndIf
WEnd

Share this post


Link to post
Share on other sites

Here Is a working solution for this. hope it helps someone.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ProgressConstants.au3>
#include <Constants.au3>
#include <GuiEdit.au3>
#include <Date.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 16, 16, 577, 329)
GUICtrlSetData(-1, "")
$Progress1 = GUICtrlCreateProgress(16, 368, 577, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$somefolder = FileSelectFolder("Select Encode Folder", "")
$Afiles = _FileListToArray($somefolder)
$sStdErr = ""
$iTicksDuration = 0
$iTicksTime = 0
$ffmpeg = $somefolder&"\ffmpeg.exe"

for $i = 1 to $Afiles[0]
    $file = $Afiles[$i]
    $hPid = Run($ffmpeg & ' -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"', $somefolder, @SW_HIDE, 0x4)

While 1
    Sleep(500)
    $sStdErr &= StderrRead($hPid)
    If @error Then ExitLoop
    GUICtrlSetData($Edit1,$sStdErr)
    If StringLen($sStdErr) > 0 Then
        If Not $iTicksDuration Then $iTicksDuration = _GetDuration($sStdErr)
        $iTicksTime = _GetTime($sStdErr)
        If Not @error Then $sStdErr = ""
        GUICtrlSetData($Progress1, $iTicksTime * 100 / $iTicksDuration)
    EndIf
WEnd
ProgressOff()
Next

Func _GetDuration($sStdErr)
    If Not StringInStr($sStdErr, "Duration:") Then Return SetError(1, 0, 0)
    Local $aRegExp = StringRegExp($sStdErr, "(?i)Duration.+?([0-9:]+)", 3)
    If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, 0)
    Local $sTime = $aRegExp[UBound($aRegExp) - 1]
    Local $aTime = StringSplit($sTime, ":", 2)
    If @error Or Not IsArray($aTime) Then Return SetError(1, 0, 0)
    Return _TimeToTicks($aTime[0], $aTime[1], $aTime[2])
EndFunc   ;==>_GetDuration

Func _GetTime($sStdErr)
    If Not StringInStr($sStdErr, "time=") Then Return SetError(1, 0, 0)
    Local $aRegExp = StringRegExp($sStdErr, "(?i)time.+?([0-9:]+)", 3)
    If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, 0)
    Local $sTime = $aRegExp[UBound($aRegExp) - 1]
    Local $aTime = StringSplit($sTime, ":", 2)
    If @error Or Not IsArray($aTime) Then Return SetError(1, 0, 0)
    Return _TimeToTicks($aTime[0], $aTime[1], $aTime[2])
EndFunc   ;==>_GetTime
1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0