Executing a batch file
Executing a batch file
Hi,
I'm sure there's a simple answer for this. I have a batch file that upon execution will remove audio from an mp4 video file using ffmpeg.
The .bat is this... for %%a in ("*.mp4") do ffmpeg -i "%%a" -acodec copy -vn "%%~na.m4a"
When i run this manually, it works without issue.
My current process is placing an mp4 file in the directory which holds this .bat file and the FFMPEG application files, and double clicking the .bat file to run.
I'd like to use the watchfolder feature of FFAStrans, to see when an mp4 file is placed inside, and run the pre-existing .bat file. That is all I need.
I've setup FFAStrans to use the Monitor Folder processer accepting *.mp4 files.
From there I've setup the Command Executor processor. This is where I'm stuck. The job doesn't produce an error, but it doesn't run the .bat file I need it to.
I've tried
%comspec% /c "C:\_Dropbox\convert\file.bat"
%comspec% /c "\file.bat"
Am I missing something? Aside from using Windows Task Scheduler to kick this off every "x minutes", I'd like to use the Monitor Folder processor to see that there's an mp4, and then kick off the .bat.
Any help would be greatly appreciated.
Thank you
I'm sure there's a simple answer for this. I have a batch file that upon execution will remove audio from an mp4 video file using ffmpeg.
The .bat is this... for %%a in ("*.mp4") do ffmpeg -i "%%a" -acodec copy -vn "%%~na.m4a"
When i run this manually, it works without issue.
My current process is placing an mp4 file in the directory which holds this .bat file and the FFMPEG application files, and double clicking the .bat file to run.
I'd like to use the watchfolder feature of FFAStrans, to see when an mp4 file is placed inside, and run the pre-existing .bat file. That is all I need.
I've setup FFAStrans to use the Monitor Folder processer accepting *.mp4 files.
From there I've setup the Command Executor processor. This is where I'm stuck. The job doesn't produce an error, but it doesn't run the .bat file I need it to.
I've tried
%comspec% /c "C:\_Dropbox\convert\file.bat"
%comspec% /c "\file.bat"
Am I missing something? Aside from using Windows Task Scheduler to kick this off every "x minutes", I'd like to use the Monitor Folder processor to see that there's an mp4, and then kick off the .bat.
Any help would be greatly appreciated.
Thank you
Re: Executing a batch file
Hi vincev100, thank you for using FFAStrans and welcome to the forum!
For your script to work you must either have the working directory set in the script where the ffmpeg.exe resides or the directory is set as a path in the system environment variables. I don't know the rest of your script or your windows environment so I cannot say if your script should work or not. But your first attempt in the "Command executor" is correct:
%comspec% /c "C:\_Dropbox\convert\file.bat"
You can try and put "notepad" as the first line in your script just to see if if the script starts at all from FFAStrans. Just to get a visual...
-steinar
For your script to work you must either have the working directory set in the script where the ffmpeg.exe resides or the directory is set as a path in the system environment variables. I don't know the rest of your script or your windows environment so I cannot say if your script should work or not. But your first attempt in the "Command executor" is correct:
%comspec% /c "C:\_Dropbox\convert\file.bat"
You can try and put "notepad" as the first line in your script just to see if if the script starts at all from FFAStrans. Just to get a visual...
-steinar
Re: Executing a batch file
HI,
I actually tried doing this again after the recent update and still cannot get it to work. Again, I can manually run the .bat file without issue. FFMPEG is installed to the same directory that the .bat file runs. I even tried your advice putting "notepad" at the front of the script. This worked when manually running the .bat file, but once again did not work from FFASTRANS. Oddly, I can see the command prompt window launch, and close immediately. I also have "pause" at the end of the script, and the window still closes completely.
I'm using the command executor to run this:
I have a watch folder that monitors for LXF files, then encodes to mp4 and delivers to the "converted" folder. Then the Command Executor runs the command below:
%comspec% /c""C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat""
It works when I double click it, works from a shortcut on the dekstop, doesn't work in FFASTRANS..
Any other ideas I can try?
Thanks!
I actually tried doing this again after the recent update and still cannot get it to work. Again, I can manually run the .bat file without issue. FFMPEG is installed to the same directory that the .bat file runs. I even tried your advice putting "notepad" at the front of the script. This worked when manually running the .bat file, but once again did not work from FFASTRANS. Oddly, I can see the command prompt window launch, and close immediately. I also have "pause" at the end of the script, and the window still closes completely.
I'm using the command executor to run this:
I have a watch folder that monitors for LXF files, then encodes to mp4 and delivers to the "converted" folder. Then the Command Executor runs the command below:
%comspec% /c""C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat""
It works when I double click it, works from a shortcut on the dekstop, doesn't work in FFASTRANS..
Any other ideas I can try?
Thanks!
Re: Executing a batch file
First, just to make sure, clean your command a bit:
%comspec% /c "C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat"
I just tried it once more to verify and it's working as expected. Notepad jumps up and FFAStrans does not contiune until I close it. My script looks like this:
notepad
That's it.
So can you please try from scratch with the simplest workflow and the simplest batch file just so you can make that work, then add functionality.
You could also send me the workflow and the batch file so I can take look and see if I can find some anomalies.
-steinar
%comspec% /c "C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat"
I just tried it once more to verify and it's working as expected. Notepad jumps up and FFAStrans does not contiune until I close it. My script looks like this:
notepad
That's it.
So can you please try from scratch with the simplest workflow and the simplest batch file just so you can make that work, then add functionality.
You could also send me the workflow and the batch file so I can take look and see if I can find some anomalies.
-steinar
Re: Executing a batch file
Hello, vincev100. What OS are you using? I had exactly the same problem with Windows 2003 Server. All XP-family is too old, outdated and hard to support due to dependencies from compilers, libraries, frameworks and API.
Re: Executing a batch file
Ok, I'm trying this now and will report back with the results.admin wrote: ↑Fri Apr 07, 2017 7:49 am First, just to make sure, clean your command a bit:
%comspec% /c "C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat"
I just tried it once more to verify and it's working as expected. Notepad jumps up and FFAStrans does not contiune until I close it. My script looks like this:
notepad
That's it.
So can you please try from scratch with the simplest workflow and the simplest batch file just so you can make that work, then add functionality.
You could also send me the workflow and the batch file so I can take look and see if I can find some anomalies.
-steinar
thanks!
Re: Executing a batch file
We are using Windows Server 2012 R2. It's installed to an on premise VM. I'm wondering if it has anything to do with service permissions.
Re: Executing a batch file
So running the command with only notepad worked. When I changed the command back to run the ffmpeg commands, it did open up the command window but failed to initiate the process: Here is the output:admin wrote: ↑Fri Apr 07, 2017 7:49 am First, just to make sure, clean your command a bit:
%comspec% /c "C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\nolow.bat"
I just tried it once more to verify and it's working as expected. Notepad jumps up and FFAStrans does not contiune until I close it. My script looks like this:
notepad
That's it.
So can you please try from scratch with the simplest workflow and the simplest batch file just so you can make that work, then add functionality.
You could also send me the workflow and the batch file so I can take look and see if I can find some anomalies.
-steinar
C:\Windows\SysWOW64>for %a in ("*_high.mp4") do md "%~na"
C:\Windows\SysWOW64>for %a in ("*.mp4") do ffmpeg -i "%a" -vf fps=1/10 -s 128x72 "%~na\thumb%04d.jpg"
C:\Windows\SysWOW64>pause
Press any key to continue . . .
--------------------
Is it something in regards to the account that FFASTRANS uses to execute a command? When I launch the command by double clicking, this is the output:
C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted>for %a in ("*_high.mp4") do md "%~na"
C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted>md "nowlow_high"
C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted>for %a in ("*.mp4") do ffmpeg -i "%a" -vf fps=1/10 -s 128x72 "%~na\thumb%04d.
jpg"
C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted>ffmpeg -i "nowlow_high.mp4" -vf fps=1/10 -s 128x72 "nowlow_high\thumb%04d.jpg
"
ffmpeg version N-79143-g8ff0f6a Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --
enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --
enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-l
ibopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enabl
e-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-li
bwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-deckli
nk --enable-zlib
libavutil 55. 19.100 / 55. 19.100
libavcodec 57. 30.100 / 57. 30.100
libavformat 57. 29.101 / 57. 29.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 40.102 / 6. 40.102
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'nowlow_high.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2017-04-07 17:53:03
encoder : Lavf57.66.102
Duration: 00:51:17.60, start: 0.000000, bitrate: 4098 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4023 kb/s, 29.97 fps, 2
9.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
creation_time : 2017-04-07 17:53:03
handler_name : VideoHandler
timecode : 00:00:00:00
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 68 kb/s (default)
Metadata:
creation_time : 2017-04-07 17:53:03
handler_name : SoundHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
creation_time : 2017-04-07 17:53:03
handler_name : TimeCodeHandler
timecode : 00:00:00:00
[swscaler @ 032056a0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'nowlow_high\thumb%04d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.29.101
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 128x72 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 0.10 fps, 0.10 tbn, 0.10 tbc (default)
Metadata:
creation_time : 2017-04-07 17:53:03
handler_name : VideoHandler
timecode : 00:00:00:00
encoder : Lavc57.30.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 18 fps=9.5 q=1.6 Lsize=N/A time=00:03:00.00 bitrate=N/A speed= 95x
video:78kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.
Terminate batch job (Y/N)?
------------
Thanks for your help on figuring this out.
Re: Executing a batch file
Can you please cd to C:\Windows\SysWOW64 in a dos window, run your script from there and see if it works. If not it probably have something to do with relative paths.
FFAStrans is executed with the users logged in permissions.
-steinar
FFAStrans is executed with the users logged in permissions.
-steinar
Re: Executing a batch file
Ok, so what I did to get it to work was move the file to the desktop, and then have it cd to the appropriate directory, where the files and ffmpeg reside. So my final script makes a directory based on the file name, generates thumbnails every 10th frame into the newly created directory, then the directory is renamed via a powershell command. It works flawlessly. Thank you very much for the help! It definitely had something to do with not executing under my user account. I don't know if it was the location of the script that made it run under the default account, but it works now!
cd C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted
for %%a in ("*_high.mp4") do md "%%~na_1"
for %%a in ("*.mp4") do ffmpeg -i "%%a" -vf fps=1/10 -s 128x72 "%%~na_1\thumb%%04d.jpg"
powershell -Command "& 'C:\Users\vincev100\Desktop\FFASTRANS\LXF_Watchfolder\converted\rename.ps1'"