Log in

View Full Version : ffmpeg.exe -y does not overwrite, maybe a bug


UFOxyz
19th December 2024, 02:44
@ECHO OFF
SET FSPEC=*.BMP *.GIF *.JPG *.PCX *.PNG *.TIF *.WEBP
SET "F2=-sws_flags lanczos"
SET "F3=-sws_flags bicubic"
SET "GG=%F2%"
SET "F4=-q:v 3"
SET "FF1=%GG% %F4%"

REM AAA
FOR /F "TOKENS=*" %%V IN ('DIR %FSPEC% /A-D /B /S') DO (
"%FF%" -y -display_rotation 270 -i "%%~V" %FF1% "%%~dpV%%~nV%%~xV"
ECHO.
ECHO "%%~V"
ECHO "%%~dpV%%~nV%%~xV"
ECHO.
)


REM BBB
FOR /F "TOKENS=*" %%V IN ('DIR %FSPEC% /A-D /B') DO (
"%FF%" -y -display_rotation 270 -i "%%~V" %FF1% "%%~dpV%%~nV%%~xV"
ECHO.
ECHO "%%~V"
ECHO "%%~dpV%%~nV%%~xV"
ECHO.
)

REM AAA does not overwrite as -y is supposed to do, but sometimes rarely does overwrite the files
REM BBB does not overwrite as -y is supposed to do, but quite often overwrites the files
so i do not know how to control exactly, it seems that it got mind of its own, but far more towards "doesnt overwrite side"
this is a strange bug maybe related to OS OR "-y" option in ffmpeg.exe, i dont know which caused it
PS: %FF1% will be bypassed if the command sees BMP files instead of JPGs, so i found no problem if i included %FF1% or not

URL has the screenshot of it
https://mega.nz/file/qIAnBSTT#xFbzTMAaKwYEYUfl1TdhI5WLBJLK9Piz4LkEI2He1o0

Z2697
19th December 2024, 04:17
You used same file name for input and output, FFmpeg does not support this, as the error repoted by it.

UFOxyz
19th December 2024, 06:17
>same name for input and output, FFmpeg does not support this
then this is still a weird bug. it should not behave it works sometimes and doesnt work sometimes
if dealing with JPGs it overwrites the same input and out filenames almost always, replacement is possible
but
if dealing with BMPs. it works sometimes, it kind of works if you reboot your pc and do not explore the directories much, then it could work kind of ok for 1st few times maybe but still less than a comfort level.

i also made a script to restrict the local drive letters for "-y" to be used with a sound effect and a colored batch as to when to overwrite and replace the source files, or renaming many files will be cumbersome, so that a destruction due to "-y" may not happen that easily

URL has the screenshot of the same input and same output files that "-y" worked.
https://mega.nz/file/uE4W3DLT#M5O-CsW-liOthAP1sM_I4cNI5iib0o2UnH0j4stPQS4

GeoffreyA
19th December 2024, 07:10
A better system might be to create a directory in the script and write the new files there. That way, there won't be conflicts.

microchip8
19th December 2024, 10:13
-y should be placed after -i, preferrably just before the output name/file. Options that come *before* -i are meant for decoders/input filters/etc

Z2697
19th December 2024, 17:25
-y should be placed after -i, preferrably just before the output name/file. Options that come *before* -i are meant for decoders/input filters/etc

That's my first thought too, but according to the help message the -y option is global.

UFOxyz
23rd December 2024, 10:04
>same name for input and output, FFmpeg does not support this
relocation of converted files.... an idea of writing the converted mp4s or BMPs to a different drive with same dir names didnt work at the end.

i realized that my JPGs had many TXTs associated with them as below
abc.jpg
abc.txt
abc.trc which is my true basic's support graphics
and my MP4s had SRTs and some SMIs and a few SUBs associated with them
i had to abandon this idea.
the attempted code is below
SET "FSPEC=*.AVI *.MP4" &REM for doing CurrentDir and Branch
SET "MTemp=M:\ZZFFmpeg"
set FF=ffmpeg.exe
FOR /F "Delims=" %%V IN ('DIR %FSPEC% /A-D /B') DO (
SET /A CC=CC+1
IF NOT EXIST "%MTemp%%%~pV" MKDIR "%MTemp%%%~pV"
%FF%" -y -i "%%~fV" "%MTemp%%%~pV%%~nV.mp4"
REM "%FF%" -y -i "%%~fV" "%%~dpV%%~nV.mp4"
ECHO.
ECHO "%%~V"
ECHO "%%~fV"
ECHO "%%~dpV%%~nV.mp4"
ECHO "%MTemp%%%~pV%%~nV.mp4"
)

i think i will do like next way
FFmpeg converts abc.mp4 to abc--.mp4 in the same directory
then delete abc.mp4 then rename abc--.mp4 to abc.mp4

when the batch is done, 100s MP4s and 1000s AVIs have to be done with 1 click, this could save me 800 Giga byte spaces in a USB HDD for the time being.

because 20 years ago a USB HDD had 2 tera byte, after 20 years later the same HDD size is STILL ~2.5 tera bytes and they stacked two of them called it a 5TB. i need a small size higher capacity USB HDD and not more USB HDDs. i ran out of USB HDD spaces and i dont want to split backup data into more USB HDDs. because i use two USB HDD backup copies of HDDs inside the pc, if i decide to split data someday.. yes eventually... i have to use four USB HDDs to backup a pc.

my wish for FFmpeg is .... FFmpeg could consider to be able to replace the source files someday.

i attached a graphic URL... about if irfanview can replace source files, why not FFmpeg too?
https://mega.nz/file/fcg1UZSA#eUTzD4kI_M6nUELw1TaMrUmFYRh2ekIi-mptts1Yknw