Monitoring rtmpdump channels using powershell and rtmpdump

I am trying to control RTT channel channels in real time using powershell and rtmpdump. the streams that I want to track are saved in the "streams.txt" file, which follows the csv format.

Name,feed,file tv1,rtmp://server/live/tv1,tv1.flv tv2,rtmp://server/live/tv1,tv2.flv tv3,rtmp://server/live/tv1,tv3.flv tv4,rtmp://server/live/tv1,tv4.flv 

After importing the csv file and converting the data into objects, I move each object and using the feed property, I run the rmtpdump command after this process works, the rest of powershell is stopped.

to decide that I am trying to use a timer, but even they do not solve my problem when rtmpdump captures the first channel inside the loop.

 Register-ObjectEvent -InputObject $timer -EventName elapsed –SourceIdentifier thetimer -Action $action $colStats = Import-CSV streams.txt foreach ($objBatter in $colStats) { $timer.start() $objBatter.feed + "," + $objBatter.file .\rtmpdump.exe -r $objBatter.feed -o $objBatter.file } #to stop run $timer.stop() #cleanup Unregister-Event thetimer #loop through flv files and all 0 bytes files are faulty channel #deleting files with 0 size #dir | ? {$_.length -eq 0} | del 

I need to capture the feed output within 30 seconds of playback, and then kill the rtmpdump process, and in the next iteration of the loop I want to capture the second channel in 30 seconds.

If one thread does not work, it will generate a flv file from 0 bytes, so that later it will receive a notification

+4
source share
2 answers
 cls; Set-Location "C:\users\najam.sikander\Desktop\rtmpdump" #deleting flv files dir *.flv | del get-process -name rtmp* | kill <# $timer = new-object timers.timer $action = { write-host "Time to kill rtmp: $(get-date -Format 'HH:mm:ss')" #get-process -name rtmp* | kill } $timer.Interval = 30000 #3 seconds Register-ObjectEvent -InputObject $timer -EventName elapsed –SourceIdentifier thetimer -Action $action #> $colStats = Import-CSV streams.txt $files = (dir *.flv | measure).Count Write-Host $files While ($files -lt $colStats.Length) { $arguments = "-r " + $colStats[$files].feed + " -o " + $colStats[$files].file + " -m 20 -v" Start-Process "C:\users\najam.sikander\Desktop\rtmpdump\rtmpdump.exe" $arguments do { Write-Host $colStats[$files].feed Write-Host $colStats[$files].file $streaming = $true; $fileCh = (dir $colStats[$files].file | measure).Count Write-Host $files if($fileCh -gt 0) { while ((dir $colStats[$files].file).Length -lt 1000){ $dump = (get-process -name rtmp* | measure).Count if($dump -eq 0) { break } } $streaming = $false get-process -name rtmp* | kill } } while ( $streaming -eq $true) $files = (dir *.flv | measure).Count Write-Host $files } #getting working and not workign streams sets based on flv files $working = dir *.flv | ? {$_.length -ge 1000} $notworking = dir *.flv | ? {$_.length -eq 0} Write-Host "working = " ($working |measure).Count $working Write-Host "not working = " ($notworking |measure).Count $notworking #deleting flv files dir *.flv | del 
+3
source

I believe this does what you want ... It will scroll through the csv file, start the rempdump process for 30 seconds, kill it, and then move on to the next feed.

 #Import the streams $colStats = Import-CSV streams.txt #Loop through the streams foreach ($objBatter in $colStats) { $Process = ".\rtmpdump.exe" $arguments = "-r $objBatter.feed -o $objBatter.file" #Launch Process $Ps = Start-Process -FilePath $Process -ArgumentList $Arguments -PassThru #Wait 30 seconds Sleep -Seconds 30 #Kill the process $Ps.Kill() } #loop through flv files and all 0 bytes files are faulty channel #deleting files with 0 size #dir | ? {$_.length -eq 0} | del 
+2
source

Source: https://habr.com/ru/post/1499094/


All Articles