Command Executor | FFAStrans service

Questions and answers on how to get the most out of FFAStrans
Post Reply
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Command Executor | FFAStrans service

Post by taner »

Hi Admin Team,

I have a question.
Concerning command executor.
Shall it also work when running FFAStrans as service?
Because it actually does work.
In every of my workflows when I use command executor to run ffmpeg, sox ect..
But it does not work when I want to execute for example a bat file.
Even executing the most simple commands (explorer, notepad ect.) are not working.
Those works all fine when running FFAStrans as application but not as a service.

Best
Taner
emcodem
Posts: 1669
Joined: Wed Sep 19, 2018 8:11 am

Re: Command Executor | FFAStrans service

Post by emcodem »

Hey taner!

Of course, cmd executor is after populate my most used processor and all my ffastrans farms run as service (running stuff with autologin users on servers is so 90' style ^^).

Just paste your command inside the double quotes of cmd /C "".
The command executor even sais this in its default value (%comspec% is cmd):

Code: Select all

%comspec% /C "<place your command line here>"
Example: we want to start notepad. It works to just write notepad when not running as application but it does not work as service. However cmd /C notepad works when running as a service. Unfortunately i cannot explain why this is as it is, maybe the win32 API createprocess docs has some explaination for it.
Anyway, you would not see notpad running on your desktop when it was started from a background service. That is because background services have their own windows session which you cannot access (anymore since windows 7). But you will see notepad.exe process in task manager running under the username you did set for the service.

So far so good, we cannot really start GUI applications because it makes no sense when we cannot access the gui. But we can execute any batch or program. All we have to do for it is to wrap our command in cmd /C.
When using cmd /C we have to take care about the parameters doubplequotes. What i usually do is to first develop my commandline using the commandline of course, then copy it into cmd /C like this:

Before:

Code: Select all

C:\path\mycommand.exe "param 1" "param 2"
After:

Code: Select all

cmd /c "C:\path\mycommand.exe  "param 1" "param 2""
What i did above was to copy the before into the doubplequotes of cmd /C "", this creates a little brainfuck because we have " in a non closed " but that is how cmd /C wants it to be.

Also, we need to take care about the System variable %PATH%. Look up the Path variable in the internet if you like but the point is that you should usually provide full paths to everything. E.g. instead of notepad you write C:\windows\system32\notepad.exe. Well ok, notepad is maybe a bad example because c:\windows\system32 is in the PATH variable of every user but the path to other commands and 3rdparty software might not be in the path of your service user, so it is good practice to always provide the full path.
You can even investigate and compare the path variable from your logged in user vs. ffastrans as service by running cmd /C "echo %PATH%" or cmd /C "set"
emcodem, wrapping since 2009 you got the rhyme?
User avatar
FranceBB
Posts: 237
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: Command Executor | FFAStrans service

Post by FranceBB »

emcodem wrote: Thu Apr 13, 2023 7:10 am background services have their own windows session which you cannot access (anymore since windows 7).
*coff coff* PsExec *coff coff*

No seriously, with PsExec you can bring back cmd windows started in background that you wouldn't otherwise see.
I very rarely do it with cmd windows started by FFAStrans containing ffmpeg when the encode hangs and I have to debug.
I found out this technique back when I had an issue with avstp.dll and my encodes were "frozen as ice" (to quote Ferenc Pinter, the current Avisynth core maintainer).
It works on Server 2016 and 2019 just fine.
emcodem
Posts: 1669
Joined: Wed Sep 19, 2018 8:11 am

Re: Command Executor | FFAStrans service

Post by emcodem »

Hehe thats not accessing the session, but instead acess one process of the session. In former times we were able to get the wohle session to the main screen, e.g. Beging literally logged on as the backround service. This made debugging a lot easier than it is these days
emcodem, wrapping since 2009 you got the rhyme?
User avatar
FranceBB
Posts: 237
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: Command Executor | FFAStrans service

Post by FranceBB »

emcodem wrote: Fri Apr 14, 2023 9:12 pm Hehe thats not accessing the session, but instead acess one process of the session. In former times we were able to get the wohle session to the main screen, e.g. Beging literally logged on as the backround service. This made debugging a lot easier than it is these days
Ah really? The whole background session? O_O Wow
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Re: Command Executor | FFAStrans service

Post by taner »

Thanks both to you for your help!

Particularly I have a problem to run an anaconda python command via Command Executor.
In foreground it works, in background it fails.
ModuleNotFound blah blah dora

You really don't have to react to that.
It it is clearly not FFAStrans related.
Just wanted to inform you.

Thanks again!
Taner
emcodem
Posts: 1669
Joined: Wed Sep 19, 2018 8:11 am

Re: Command Executor | FFAStrans service

Post by emcodem »

Yeah python in general tends to install stuff only for the current user profile or even just for the current python "environment". You'll need to check how to make your stuff portable. For example i tend to use auto-py-to-exe which can collect all dependencies and pack everything including python interpreter into a single executeable.
If you dont want to or cannot package to single executeable, you can check how to install all dependencies globally, e.g. in nodejs i do "npm i -g mydependency" instead of "just npm i mydependency"
If it's accidently about using whisper, you could just switch to Const-me version which steinar and i use :D
emcodem, wrapping since 2009 you got the rhyme?
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Re: Command Executor | FFAStrans service

Post by taner »

Hi emcodem,

Thanks for your advice!

I‘m pretty sure with that information I‘ll manage to get it work.
Afterwards I’ll rename my workflow to emcodemmakespythoncryhard.
Anyway.
I‘ve seen in another post that you were recommending a gpu accelerated whisper fork.
Didn‘t waste time.
Got it.
Works like a charm, just missing autodetect language feature.
But the python workflow is actually about vocal isolation.
Pretty good results.
Even more worthful after integrating it into the whisper workflow.
Makes the transcription in some cases more precise.
Especially when you have massive natural sounds which have to be filtered out.

Best
Taner
Post Reply