Author Topic: Error while batching  (Read 313 times)

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #15 on: March 26, 2018, 01:12:10 PM »
you mean like this
set PATH=%PATH%;C:\Program Files\ffmpeg\

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #16 on: March 26, 2018, 01:50:30 PM »
still not working

eumagga0x2a

  • Hero Member
  • *****
  • Posts: 1836
Re: Error while batching
« Reply #17 on: March 26, 2018, 02:17:31 PM »
You forgot quotation marks.

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #18 on: March 26, 2018, 02:39:18 PM »
where abouts?

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #19 on: March 26, 2018, 02:43:55 PM »
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

  • Hero Member
  • *****
  • Posts: 1836
Re: Error while batching
« Reply #20 on: March 26, 2018, 03:00:39 PM »
Well, I'll have to try out myself where quotation marks belong to once I get to a PC running Windows.

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #21 on: March 26, 2018, 03:01:21 PM »
ok cheers

eumagga0x2a

  • Hero Member
  • *****
  • Posts: 1836
Re: Error while batching
« Reply #22 on: March 26, 2018, 03:23:23 PM »
It should be

Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #23 on: March 26, 2018, 03:34:18 PM »
I read that Setx was permanent
If it's not working in the current session, how will it work with setx

eumagga0x2a

  • Hero Member
  • *****
  • Posts: 1836
Re: Error while batching
« Reply #24 on: March 26, 2018, 03:56:38 PM »
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

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #25 on: March 26, 2018, 04:53:16 PM »
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

  • Jr. Member
  • **
  • Posts: 92
Re: Error while batching
« Reply #26 on: March 27, 2018, 04:15:34 AM »
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:


Code: [Select]
Converting    "D:\MKV test\test100.mkv"    to    "D:\MKV test\test100.mp4"
27/03/2018  02:05 PM       594,813,410 test100.mp4

Converting    "D:\MKV test\test200.mkv"    to    "D:\MKV test\test200.mp4"
27/03/2018  02:05 PM       594,813,410 test200.mp4

Converting    "D:\MKV test\test300.mkv"    to    "D:\MKV test\test300.mp4"
Truncating packet of size 7245 to 47
[matroska,webm @ 000002626bf2cec0] EBML header parsing failed
D:\MKV test\test300.mkv: Invalid data found when processing input

An error occured when trying to process "D:\MKV test\test300.mkv"
Aborting...


Press any key to continue . . .


Convert_MKV_to_MP4.bat
Code: [Select]
@echo off
cls
set filename=""

:FILES_LOOP
for %%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_OCCURRED
echo.
echo An error occured when trying to process %filename%
echo Aborting...

:FINISHED
echo.
echo.
pause

Dan.
« Last Edit: March 27, 2018, 04:22:32 AM by dosdan »

jonwren

  • Jr. Member
  • **
  • Posts: 59
Re: Error while batching
« Reply #27 on: March 27, 2018, 06:41:39 AM »
Great Thanks Dan