Help with batch conversion - "Could not open the file"

Started by makosipper, September 26, 2017, 01:11:03 PM

Previous topic - Next topic

makosipper

Hello

I just wanted to convert videos in bulk in order to change just the audio codec, without changing the video at all, since my TV doesn't run some audio formats, but it handles video formats well.

set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy
set audiocodec=FDK_AAC
mkdir output
for %%f in (*.mkv,*.avi) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --load "%%f" --save "output\%%f" --quit


This is what I've been trying for a while (also tried changing audiocodec to MP3 and other formats, I'm not sure which of them are valid. My TV can't run AC3, but it can run AAC.)

The problem is that Avidemux ALWAYS fails to load the file ("Could not open the file"), so it doesn't work. If I remove --quit and try to load the same file after I get the error message, it works fine. The file is successfully loaded, and I can manually convert it.

I also tried removing the mkdir command, just in case, but it didn't work.

Any ideas? Thanks in advance

Jan Gruuthuse

perhaps here you can find more info: Simple Command line usage with Tinpy Project

I'm not certain this is correct for the path:
--save "output\%%f"
think you better use fixed paths.

makosipper

Thnak you for the reply, but I'm not sure how the link you posted relates to my question.

The problem is not the saving part. Avidemux fails to load the file in the first place, so it doesn't even try to save.

Jan Gruuthuse

you did cd into the folder with the videos?
I don't have windows, other users will probably jump in.
the link describes some batch processing.

kimcheng

Your code works on my computer. It loads the file although not change audio code dueto the order of code.

Let's try to use the filename directly instead of --load. Avidemux should load it.


%avidemux% %%f --video-codec %videocodec% --audio-codec %audiocodec%

makosipper

#5
Quoteyou did cd into the folder with the videos?

The bat file is in the folder with videos, so I'm in the right directory. The prompt even sends the right name for files, it's just that the program doesn't load them.

QuoteLet's try to use the filename directly instead of --load. Avidemux should load it.

Nope. Same problem.

Am I missing something? Should my code be longer than what it says right now? Should I enter the file's full path even if I'm at the right directory?

EDIT: "Yes" to my last question!
I changed --load "%%f" to --load "%cd%\%%f" and it worked now. I'm not sure why, but it did.

kimcheng

QuoteI changed --load "%%f" to --load "%cd%\%%f" and it worked now. I'm not sure why, but it did.

It's related to the OS environment. Well, it's a good habit to write code in absolute path. However, we don't alway coding in "good ways" as scripts are writen by lazy people who make computers/devices/phone/etc does things for them.


makosipper

Now I need help setting up my audio-codec. It seems to always copy, no matter what I use.

Also, is there a way to preserve subtitles? It seems that I can't do that, not even when converting manually.

QuoteIt's related to the OS environment. Well, it's a good habit to write code in absolute path. However, we don't alway coding in "good ways" as scripts are writen by lazy people who make computers/devices/phone/etc does things for them.
I want to be able to paste the same bat file to multiple folders and do the same there, so that's why I didn't set an absolute path.

kimcheng

QuoteNow I need help setting up my audio-codec. It seems to always copy, no matter what I use.

Change your code order. Otherwise, the audio-codec will switch back to copy by loading file.

%avidemux% --load "%cd%\%%f" --audio-codec %audiocodec%  --save "output\%%f" --quit