MSattler 390 Posted February 2, 2016 Posted February 2, 2016 As many of you have seen me complain about rogue ffmpeg processes, I have found a easy way in which to find out which ffmpeg process is being used to transcode a particular movie. This is windows only since the commands are wmi/powershell based. One way is by using a wmi call such as this: Get-WmiObject win32_process -Filter "name like '%ffmpeg.exe'" | select commandline, id While that certainly works, I want to incorporate this into powershell and powershell does not support "commandline" object out of the box. But we can fix this. Create a file named System.Diagnostics.Process.ps1xml and inside of it put this: <?xml version="1.0"?> <Types><Type><Name>System.Diagnostics.Process</Name><Members><ScriptProperty><Name>CommandLine</Name><GetScriptBlock>$id = $this.Id$result = Get-WmiObject win32_process -Filter "ProcessId = $id"$result.CommandLine</GetScriptBlock></ScriptProperty></Members></Type></Types> Save the file. We can now import this powershell extension via the command: Update-TypeData c:\users\administrator\Documents\System.Diagnostics.Process.ps1xml (you will have to tell it the directory where you saved the file) If you have not allowed scripts to run you will have to enable that in powershell via: Set-ExecutionPolicy Unrestricted Now you can run the following command: ps *ffmpeg | select id,commandline | ft -wrap Which will give you output with the process id, and the ffmpeg command which was requested. This will allow you to see which ffmpeg process is rogue and kill it off via its process id. If you want to kill the process type: stop-process -id 4298 (or whatever the process id is) Thanks goes out to this blog, which helped: http://mohundro.com/blog/2010/02/05/quickly-get-the-command-line-arguments-from-processes-with-powershell/ -Marcus 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now