September 23, 2020, 03:09:43 am

--

Error while batching

Started by jonwren, March 25, 2018, 10:57:04 am

jonwren

March 26, 2018, 01:12:10 pm #15
you mean like this
set PATH=%PATH%;C:\Program Files\ffmpeg\

jonwren

March 26, 2018, 01:50:30 pm #16
still not working

eumagga0x2a

March 26, 2018, 02:17:31 pm #17
You forgot quotation marks.

jonwren

March 26, 2018, 02:43:55 pm #19
set PATH="%PATH%;C:\Program Files\ffmpeg"

will not allow me to do so

A path component cannot contain any control character nor any of the following
/"<>

eumagga0x2a

March 26, 2018, 03:00:39 pm #20
Well, I'll have to try out myself where quotation marks belong to once I get to a PC running Windows.

ok cheers

eumagga0x2a

March 26, 2018, 03:23:23 pm #22
It should be

`set PATH=%PATH%;"C:\Program Files\ffmpeg\bin"`

Don't forget that this has effect only in the current cmd.exe session. Use setx if you want the addition to be persistent.

jonwren

March 26, 2018, 03:34:18 pm #23
I read that Setx was permanent
If it's not working in the current session, how will it work with setx

eumagga0x2a

March 26, 2018, 03:56:38 pm #24
It works in the same cmd.exe session (not Windows session!). Or be creative and modify Dan's script so that it uses the absolute path to ffmpeg.exe, it takes so much less time than to type in a forum post.

jonwren

March 26, 2018, 04:53:16 pm #25
I ended up making a Batch file

for %%a in ("*.mkv") do ffmpeg -i "%%a" -vcodec copy -acodec copy "newfiles\%%~na.mp4"
pause

I made a new folder and then placed the Bat file inside and I also copied and pasted ffmpeg inside the same folder
then made a subfolder called newfiles.

I then placed a few MKV files inside and all converted fine and all new MP4 files where inside the folder newfiles

dosdan

March 27, 2018, 04:15:34 am #26 Last Edit: March 27, 2018, 04:22:32 am by dosdan
Note FFMPEG doesn't have to be in the PATH EV, although it makes it more convenient to use. You can hard-wire its path into the batchfile:

e.g c:\program\files\utilities\ffmpeg.exe instead of just ffmpeg.exe.

In Windows Explorer, when you want to get the filename with the full path, use Shift-R.Click instead of just R.clicking on FFMPEG.EXE. Then you will see a "Copy as path" command.

The problem in the original batch file seems to occur when using a directory with a space in its name.   The new version works correctly.

For example, from either the cmd line (assuming this batch file is in the path or the current directory):
Convert_MKV_to_MP4.bat "D:\MKV test\test100.mkv" "D:\MKV test\test200.mkv" "D:\MKV test\test300.mkv"

where test200.mkv is just a renamed copy of test100.mkv, and test300.mkv is an invalid mkv (a renamed text file),

or by dragging-and-dropping these 3 MKVs onto the batch icon, shows this on the screen:

`Converting    "D:\MKV test\test100.mkv"    to    "D:\MKV test\test100.mp4"27/03/2018  02:05 PM       594,813,410 test100.mp4Converting    "D:\MKV test\test200.mkv"    to    "D:\MKV test\test200.mp4"27/03/2018  02:05 PM       594,813,410 test200.mp4Converting    "D:\MKV test\test300.mkv"    to    "D:\MKV test\test300.mp4"Truncating packet of size 7245 to 47[matroska,webm @ 000002626bf2cec0] EBML header parsing failedD:\MKV test\test300.mkv: Invalid data found when processing inputAn error occured when trying to process "D:\MKV test\test300.mkv"Aborting...Press any key to continue . . .`

Convert_MKV_to_MP4.bat
`@echo offclsset filename="":FILES_LOOPfor %%F in (%*) do ( set filename=%%F  echo Converting    %%F    to    "%%~dpnF.mp4" ffmpeg.exe -i %%F -c:v copy -c:a copy  -y -hide_banner -loglevel error "%%~dpnF.mp4" if errorlevel 1 goto ERROR_OCCURRED dir "%%~nF.mp4" | find "/" rem Remove REM from the start of the next line if you wish to delete the original file if no error occured in the conversion. REM del %%F echo. shift)goto FINISHED:ERROR_OCCURREDecho.echo An error occured when trying to process %filename%echo Aborting...:FINISHEDecho.echo.pause`

Dan.

Great Thanks Dan