Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
R128
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Conrad Zelck
R128
Commits
27b19e63
Commit
27b19e63
authored
5 years ago
by
Conrad Zelck
Browse files
Options
Downloads
Patches
Plain Diff
add functionality channel layout mono or stereo in video file
Signed-off-by:
Conrad Zelck
<
git@simpel.cc
>
parent
1b0ffcae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R128.au3
+113
-11
113 additions, 11 deletions
R128.au3
with
113 additions
and
11 deletions
R128.au3
+
113
−
11
View file @
27b19e63
...
...
@@ -2,7 +2,7 @@
#AutoIt3Wrapper_Icon=Icons\peakmeter.ico
#AutoIt3Wrapper_Res_Comment=Measure loudness with ffmpeg according to R128.
#AutoIt3Wrapper_Res_Description=Measure loudness with ffmpeg according to R128.
#AutoIt3Wrapper_Res_Fileversion=1.
0
.0.
8
#AutoIt3Wrapper_Res_Fileversion=1.
1
.0.
9
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_CompanyName=Norddeutscher Rundfunk
#AutoIt3Wrapper_Res_LegalCopyright=Conrad Zelck
...
...
@@ -15,44 +15,125 @@
#Au3Stripper_Parameters=/mo
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <Date.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <StringConstants.au3>
#include <TrayCox.au3> ; source: https://github.com/SimpelMe/TrayCox - not needed for functionality
FileDelete(@TempDir & '\output.wav')
FileInstall('K:\ffmpeg\bin\ffmpeg.exe', @TempDir & "\ffmpeg.exe", $FC_OVERWRITE)
Local $sPathFFmpeg = @TempDir & "\"
FileInstall('K:\ffmpeg\bin\ffprobe.exe', @TempDir & "\ffprobe.exe", $FC_OVERWRITE)
Local $sPathFFprobe = @TempDir & "\"
Global $g_sStdErrAll
Local $bSendTo = False
Local $sFile
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\zelckc\Test.mxf"
;~ Local $sFile = "M:\Ue_Schnitt_Ton\ton_fertig\G59031_005_Film-Tip-Wie-vi_E_190612_DAS18_M02_B.mxf"
;~ Local $sFile = "M:\Ue_Schnitt_Ton\ton_fertig\G55969_002_Die-wunderbare-_S_190610_E1440_MS1_B.mxf"
; Testfiles
;~ Local $sFile = "M:\MFT\MFT-OUT\43051753.mp4" ; 4x Stereo
;~ Local $sFile = "M:\MFT\MFT-OUT\43051753_Logo.mp4" ; 2x Stereo
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\zelckc\A10829_081_Test-TNB-------_E_160926_TESTX_SVT_B.mxf" ; 8x Mono
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\zelckc\M83_We_own_the_sky.wav" ; 1x Stereo
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\seidemann_social\ES_Backstabbers Waltz - Etienne Roussel.mp3"
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\Gitta\SoundFX\Short Skid Whoosh - kurz.aif"
;~ Local $sFile = "T:\Maus\VPN\AUDIO~4T~\zelckc\A10829_ohne-Ton.mxf" ; NO AUDIO
Local $sFile
If FileExists($cmdlineraw) Then
$sFile = $cmdlineraw
$bSendTo = True
Else
$sFile = FileOpenDialog("Choose a file", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Alle (*.*)", $FD_FILEMUSTEXIST)
If @error Then
MsgBox($MB_TOPMOST, "Error", "File selection failed" & @CRLF & @CRLF & "
Program
exits.")
MsgBox($MB_TOPMOST, "Error", "File selection failed
.
" & @CRLF & @CRLF & "
Application
exits.")
Exit
EndIf
EndIf
; how many video streams to increase stream counter
Local $sCommand = '-i "' & $sFile & '" -v 0 -show_entries stream=codec_type -of default=nw=1:nk=1'
Local $sCodecs = _runFFprobe('ffprobe ' & $sCommand, $sPathFFprobe)
ConsoleWrite("Codecs: " & $sCodecs & @CRLF)
StringReplace($sCodecs, "video", "video") ; just to get the count
Local $iCounterVideo = Number(@extended)
ConsoleWrite("Counter video: " & $iCounterVideo & @CRLF)
; is audio inside?
StringReplace($sCodecs, "audio", "audio") ; just to get the count
If @extended = 0 Then
MsgBox($MB_TOPMOST, "Error", "No audio channels found.")
Exit
EndIf
; channel layout for all audio streams
$sCommand = '-i "' & $sFile & '" -v 0 -select_streams a -show_entries stream=channels -of default=nw=1:nk=1'
Local $sChannels = _runFFprobe('ffprobe ' & $sCommand, $sPathFFprobe)
Local $aChannels = StringSplit($sChannels, @CRLF, $STR_ENTIRESPLIT)
If Not IsArray($aChannels) Then
MsgBox($MB_TOPMOST, "Error", "No audio channels found.")
Exit
EndIf
For $i = 0 To $aChannels[0]
$aChannels[$i] = Number($aChannels[$i])
Next
ConsoleWrite("Streams: " & $aChannels[0] & @CRLF)
For $i = 1 To $aChannels[0]
ConsoleWrite("Channels: " & $aChannels[$i] & @CRLF)
Next
; are all streams mono or stereo
Local Enum $eMONO = 1, $eSTEREO
Local $iMonoCount = 0, $iStereoCount = 0
Local $iLayout = 0
StringReplace($sChannels, "1", "1") ; just to get the count
If @extended > 0 Then
$iMonoCount = @extended
If $iMonoCount = $aChannels[0] Then
$iLayout = $eMONO
EndIf
ConsoleWrite("Monofiles: " & @extended & @CRLF)
EndIf
StringReplace($sChannels, "2", "2") ; just to get the count
If @extended > 0 Then
$iStereoCount = @extended
If $iStereoCount = $aChannels[0] Then
$iLayout = $eSTEREO
EndIf
ConsoleWrite("Stereofiles: " & @extended & @CRLF)
EndIf
Local $iMeasuringPairs = 0
Switch $iLayout
Case $eMONO
$iMeasuringPairs = $iMonoCount / 2
ConsoleWrite("All MONO" & @CRLF)
Case $eSTEREO
$iMeasuringPairs = $iStereoCount
ConsoleWrite("All STEREO" & @CRLF)
Case Else
ConsoleWrite("UNDEFINED Layout" & @CRLF)
MsgBox($MB_TOPMOST, "Error", "Track layout is undefined." & @CRLF & "Application exits.")
Exit
EndSwitch
ConsoleWrite("Pairs for measuring: " & $iMeasuringPairs & @CRLF)
Local $bShowTrackSelection = True
If $iMeasuringPairs = 1 Then $bShowTrackSelection = False ; then there is no choice of tracks
Local $iTrackL = 1
Local $iTrackR = 2
If
Not $bSendTo
Then
If
$bShowTrackSelection
Then
GUICreate("Tracks", 300, 50)
Local $idTracks12 = GUICtrlCreateRadio("1+2", 10, 10, 50, 30)
GUICtrlSetState(-1, $GUI_CHECKED)
Local $idTracks34 = GUICtrlCreateRadio("3+4", 60, 10, 50, 30)
Local $idTracks56 = GUICtrlCreateRadio("5+6", 110, 10, 50, 30)
Local $idTracks78 = GUICtrlCreateRadio("7+8", 160, 10, 50, 30)
If $iMeasuringPairs < 3 Then
GUICtrlSetState($idTracks56, $GUI_HIDE)
GUICtrlSetState($idTracks78, $GUI_HIDE)
ElseIf $iMeasuringPairs < 4 Then
GUICtrlSetState($idTracks78, $GUI_HIDE)
EndIf
Local $idButtonOK = GUICtrlCreateButton("OK", 210, 10, 80, 30, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)
...
...
@@ -101,7 +182,13 @@ GUISetState(@SW_SHOW)
Global $hTimerStart = TimerInit()
Local $sCommand = '-i "' & $sFile & '" -filter_complex "[0:' & $iTrackL & '][0:' & $iTrackR & '] amerge" -c:a pcm_s24le -y ' & @TempDir & '\output.wav'
Switch $iLayout
Case $eMONO
$sCommand = '-i "' & $sFile & '" -filter_complex "[0:' & $iTrackL - 1 + $iCounterVideo & '][0:' & $iTrackR - 1 + $iCounterVideo & '] amerge" -c:a pcm_s24le -y ' & @TempDir & '\output.wav'
Case $eSTEREO
$sCommand = '-i "' & $sFile & '" -map 0:' & $iTrackR / 2 - 1 + $iCounterVideo & ' -c:a pcm_s24le -y ' & @TempDir & '\output.wav'
EndSwitch
_runFFmpeg('ffmpeg ' & $sCommand, $sPathFFmpeg, 1)
GUICtrlSetData($Progress1, 100) ; if ffmpeg is done than set progress to 100 - sometimes last StderrRead with 100 is missed
...
...
@@ -127,7 +214,7 @@ While 1
WEnd
Exit
Func _runFFmpeg($command
, $wd, $iProgress)
Func _runFFmpeg($command, $wd, $iProgress)
Local $hPid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD)
Local $sStdErr, $sTimer
Local $iTicksDuration = 0, $iTicksTime = 0, $iTimer
...
...
@@ -135,6 +222,7 @@ Func _runFFmpeg($command , $wd, $iProgress)
Sleep(500)
$sStdErr = StderrRead($hPid)
If @error Then ExitLoop
;~ ConsoleWrite("FFmpeg: " & $sStdErr & @CRLF)
$g_sStdErrAll &= $sStdErr
If StringLen($sStdErr) > 0 Then
If Not $iTicksDuration Then $iTicksDuration = _GetDuration($sStdErr)
...
...
@@ -155,6 +243,20 @@ Func _runFFmpeg($command , $wd, $iProgress)
WEnd
EndFunc
Func _runFFprobe($command, $wd)
Local $sStdErrAll
Local $sStdErr
Local $hPid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD)
While 1
Sleep(50)
$sStdErr = StdoutRead($hPid)
If @error Then ExitLoop
$sStdErrAll &= $sStdErr
WEnd
$sStdErrAll = StringRegExpReplace($sStdErrAll, "\R$", "") ; delete last new line sequence
Return $sStdErrAll
EndFunc
Func _GetDuration($sStdErr)
If Not StringInStr($sStdErr, "Duration:") Then Return SetError(1, 0, 0)
Local $aRegExp = StringRegExp($sStdErr, "(?i)Duration.+?([0-9:]+)", 3)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment