News:

--

Main Menu

Error while batching

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

Previous topic - Next topic

jonwren

Newbie Alert
Am currently learning to Batch MKV to MP4, basic copy video and copy audio
I get an error message, Which is below...
I have to select OK for every file loaded for it to do the conversion, The conversion works great, apart from having to select OK for every file loaded.
I have found this on one website
get_file_size(file)
BUT I don't know what to do with it, or if it will work, I have tried many ways, but I always get the error below

TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50


Here are my Bat file Settings

set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
for %%f in (*.mkv) do %avidemux% --load "%%f" --run pui.py --save "%%~nf.mp4" --quit


Here are my Py file Settings

adm = Avidemux()
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True", "forceAspectRatio=False", "aspectRatio=1")


I have no idea what am doing wrong, Am on the current Nightly version 2.7

Any help would be great, as this is making me go crazy :o

Thanks

jonwren

SOLVED

MKV to MP4
Copy Video
Copy Audio


set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy set audiocodec=Copy
for %%f in (*.mkv) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --force-alt-h264 --load "%%f" --save "%%~nf.mp4" --quit

dosdan

#2
I still think you would be better using FFMPEG here. ADM can do this, but it is an over-complex, even a clumsy way to convert a lot of MKVs to MP4s when all you want to do is remux them.  ADM is better suited when you want to cut, crop and/or resize them.

Here is Convert_MKV_to_MP4.bat:

@echo off

cls
set filename=""

:FILES_LOOP
for %%F in (%1) do (
set filename=%%F 
echo Processing %%F
ffmpeg.exe -i %%F -c:v copy -c:a copy  -y -hide_banner -loglevel error "%%~nF.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 occurred in the conversion.
REM del %%F
echo.
shift
)
if not "%1"=="" goto FILES_LOOP
goto FINISHED

:ERROR_OCCURRED
echo.
echo An error occured when trying to process %filename%
echo Aborting...

:FINISHED
echo.
echo.
pause



This has been designed as a general purpose conversion batchfile (and a a template for other FFMPEG batch operations). It's drag-and-drop. You place the icon of this batch file on your desktop and then drag one or more MKVs on to it. It gives you a rough progress indication which is helpful when you're converting a lot of MKVs.

This next version creates a "converted" sub-directory beneath the original files' location, if it doesn't already exist.  Also it uses a Win32 version of "touch" (http://www.binarez.com/touch_dot_exe/) so that the converted MP4s will have the same date/timestamps as the MKVs.

@echo off

cls
set filename=""

:FILES_LOOP
for %%F in (%1) do (
set filename=%%F 
echo Converting    %%F    to    %%~dpFconverted\%%~nF.mp4
if not exist "%%~dpFconverted\" md "%%~dpFconverted\"
ffmpeg.exe -i %%F -c:v copy -c:a copy -y -hide_banner -loglevel error -map_metadata 0 "%%~dpFconverted\%%~nF.mp4"
if errorlevel 1 goto ERROR_OCCURRED
rem  Next line sets the MP4's file date/time to the same as the original MKV file
touch -r "%%~fF" "%%~dpFconverted\%%~nF.mp4"
rem  Next line shows the MP4 after it has been created, so with
        rem multiple MP4s it acts as a sort of progress indicator.
dir "%%~dpFconverted\%%~nF.mp4" | find "/"
rem  Remove REM from the start of the next line if you wish to
rem  delete the original file if no error occurred in the conversion.
REM del %%F
echo.
shift
)
if not "%1"=="" goto FILES_LOOP
goto FINISHED

:ERROR_OCCURRED
echo.
echo An error occured when trying to process %filename%
echo Aborting...

:FINISHED
echo.
echo.
pause


To test the error handling, use a non-media file. For example, rename readme.doc or hello.txt to test.mkv, and drop it onto the icon.

Dan.



eumagga0x2a

I second Dan's recommendation for ffmpeg for this task. Furthermore, I seriously doubt that your command works as you expect.

jonwren

Thanks
Will give it a try, as I said am new to this and today is my 3rd day of learning, if  Dan's way is better I will def use that  ;D

jonwren

I've just tried both bat and both didn't do anything apart from creating a folder, Is there something that I have to input myself?

eumagga0x2a

Is ffmpeg installed and in PATH?

(Alternatively, you can correct the mistakes outlined in http://avidemux.org/smif/index.php/topic,18268.msg83675.html#msg83572 and use Avidemux.)

eumagga0x2a

By the way, testing scripted saving as MP4 helped to identify and fix a bug which resulted in broken MP4 files when relative path was supplied via command line.

jonwren

ffmpeg is installed, but where do I input the path ?

jonwren

The Error message I get is

Processing "C:\Users\jonwr\Desktop\New folder (3)\Instinct.S01E02.720p.HDTV.2CH.x265.HEVC-PSA - Copy.mkv"
'ffmpeg.exe' is not recognized as an internal or external command,
operable program or batch file.

An error occured when trying to process "C:\Users\jonwr\Desktop\New folder (3)\Instinct.S01E02.720p.HDTV.2CH.x265.HEVC-PSA - Copy.mkv"
Aborting...


Press any key to continue . . .


jonwren

What am I suppose to do?
I have selected Java and did what it said and returned to the bat file and get the same error

eumagga0x2a

#12
Java???

set PATH="%PATH%;DriveLetter:\path\to\the\folder\where\ffmpeg.exe\is\located"

In general, https://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows

(added quotation marks to deal with spaces in the path)

jonwren

#13
Sorry was meant to say ffmpeg not java

I did this but still nothing
set PATH=%PATH%;C:\Program Files\ffmpeg\bin\ffmpeg.exe

eumagga0x2a

It should be the folder containing the executable. Not the path to the executable.

And please mind quotation marks.