Button script for FFMPEG help needed

Hello.

I write videos using Captura. Then I use the following script to compress a created video:

$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4

I found this script here: https://gist.github.com/lukehedger/277d136f68b028e22bed

I'd like to create button. First I select one and only one file and press my button. This should open conemu (or cmd.exe at least) and run the script above. Also this button should create render folder in current one if such folder isn't exists.

I know how to create a new button in DO. Bun I have problems with:

  1. How to check if folder exists.
  2. How to run some script in conemu (that is I should see console window).
  3. How to make my button work with one and only one file.
  4. How to make my button inactive when no files are not selected.

Also I have difficulties with if-then-else when scripting. I see in help that there is @if instruction, but I don't see smth like @else one.

It seems to me that this should be easy for those who knows scripting. Please help me to script this too.

Best regards,
Andrey.

Which folder?

What do you want it to do if the folder does or doesn't exist?

I think this is what you want (at least for the compression, not sure about the scripting):

@firstfileonly 
CreateFolder render
ffmpeg.exe -i {filepath} -vcodec h264 -acodec mp2 render\{file|ext=mp4}

Set Function to MS-DOS and enter the path to ffmpeg.exe if needed.

If folder with my video file also contain render folder, I will not create this folder, just use it.
If folder with my video file doesn't contains render folder, I must create render folder.
FFMPEG will create new compressed video file. I want to put this new file in render folder.

It seems to me your solution is very close to my needs.
If my source folder already has render folder, what it will be after CreateFolder function? Will it create smth. like render (1) folder? How should I modify your script to use CreateFolder function only when render folder isn't exists? Thanks!

You obviously haven't tried the script :neutral_face:

Sorry, but your code doesn't work for me, because there are whitespaces in file name and folder name. I still need help, because double quotes didn't help me.

Try this maybe:

@firstfileonly 
@nofilenamequoting
CreateFolder render
ffmpeg.exe -i "{filepath}" -vcodec h264 -acodec mp2 "render\{file|ext=mp4}"

This didn't helped me too. The console window is shown and hide very fast, so I don't have enough time to read anything...

Add a pause command at the end to see what the error message is.

@firstfileonly 
@nofilenamequoting
CreateFolder render
"C:\Portable Apps\FFMPEG\bin\ffmpeg.exe" -i "{filepath}" -vcodec h264 -acodec mp2 "render\{file|ext=mp4}"
pause

I got "Cannot find command pause".

Set the Function drop-down to MS-DOS Batch Function.

Thanks for advice! This works for ffmpeg, but not for dopus functions...

I'm not sure what you mean. It changes how external commands/programs are run, but still allows Opus commands to be run as well, in the same button.

Does it work now or not? If it doesn't work, what goes wrong?

This really didn't work for the first, but next day this began to work! Many thanks!

Ooops... I didn't see this line before... So your solution works! Many thanks!)