[英]ffmpeg error "output file #0 does not contain any stream" with FORFILE on command prompt
I'm trying to convert all the songs in a folder from flac to alac.我正在尝试将文件夹中的所有歌曲从 flac 转换为 alac。 All the files in the folder are flac.文件夹中的所有文件都是flac。
What i'm writing:我在写什么:
FORFILES /M *.* /C "ffmpeg -i @fname.flac -c:v copy -c:a alac @fname.m4a"
And the error:和错误:
ffmpeg version 2022-01-13-git-c936c319bd-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 57. 18.100 / 57. 18.100
libavcodec 59. 20.100 / 59. 20.100
libavformat 59. 17.100 / 59. 17.100
libavdevice 59. 5.100 / 59. 5.100
libavfilter 8. 25.100 / 8. 25.100
libswscale 6. 5.100 / 6. 5.100
libswresample 4. 4.100 / 4. 4.100
libpostproc 56. 4.100 / 56. 4.100
Output #0, flac, to '01 リビングデッド・ユース.flac':
Output file #0 does not contain any stream
The forfiles
command is a nasty beast, because there are several caveats:forfiles
命令是一个讨厌的野兽,因为有几个警告:
/M *.*
does not match all files but only such with an extension;它处理通配符的方式与大多数其他命令不同,因此/M *.*
不匹配所有文件,而只匹配带有扩展名的文件; to really match all files, use /M *
or skip it since it is the default anyway;要真正匹配所有文件,请使用/M *
或跳过它,因为它是默认值;\
, like the root directory of a drive /P "D:\"
, which causes a syntax error since the closing quotation mark is considered as escaped;它应用反斜杠转义,这对于以\
结尾的路径特别烦人,例如驱动器的根目录/P "D:\"
,这会导致语法错误,因为右引号被视为已转义; to work around that, preferably append a .
要解决这个问题,最好是 append a .
like /P "D:\."
像/P "D:\."
, or remove the quotation marks like /PD:\
, though this exposes whitespaces or special characters to the parser; , 或删除/PD:\
之类的引号,尽管这会将空格或特殊字符暴露给解析器;@
-variables that return the path and/or name of iterated items provide the values in quoted manner, which is particularly frustrating when it comes to concatenation;所有返回迭代项的路径和/或名称的特殊@
-variables 都以引用的方式提供值,这在连接时尤其令人沮丧;@isdir
variable, but you will need an if
statement for this, which is an internal cmd.exe
command, requiring its explicit instantiation even when you would not need it else;要区分它们,您可以使用特殊的@isdir
变量,但您需要一个if
语句,这是一个内部cmd.exe
命令,即使您不需要它,也需要它的显式实例化;/C
is terribly implemented, leading to the problem that directly running external commands (so without cmd /C
) fails, unless you are aware of the mostly working fix by stating the command name twice (like /C "command.exe command.exe --parameter argument"
);对/C
后面的命令的处理非常糟糕,导致直接运行外部命令(因此没有cmd /C
)失败的问题,除非您通过两次声明命令名称(如/C "command.exe command.exe --parameter argument"
);/D
option to filter for the relative last modification date (but not time) is badly implemented when a positive number (like /D +1
) is used, because this uselessly points to the future;当使用正数(如/D +1
)时,即使它用于过滤相对最后修改日期(但不是时间)的基本不错的/D
选项也很难实现,因为这无用地指向未来; All of this issues lead me to the point that I suggest not to use forfiles
and to use a standard for
loop instead, like this (note also the changed mask *.flac
):所有这些问题都让我想到我建议不要使用forfiles
而是使用标准for
循环,就像这样(还要注意更改的掩码*.flac
):
rem // Loop through all `*.flac` files in the current working directory:
for %%I in ("*.flac") do (
rem // The `~`-modifiers remove quotes and extract path/name parts:
ffmpeg -i "%%~I" -c:v copy -c:a alac "%%~nI.m4a"
)
The ~n
-modifier expands to the base name with the extension .flac
removed. ~n
-修饰符扩展为基本名称,并删除了扩展名.flac
。
If you do insist in using forfiles
, then apply it like this:如果您确实坚持使用forfiles
,请像这样应用它:
forfiles /M "*.flac" /C "ffmpeg ffmpeg -i @file -c:v copy -c:a alac @fname.m4a"
This actually specifies for the output file a quoted base name followed by the new extension, like "video".m4a
, for example, though there seems to be some kind of auto-correction involved so that such a name is accepted.这实际上为 output 文件指定了一个带引号的基本名称,后跟新的扩展名,例如"video".m4a
,尽管似乎涉及某种自动更正以便接受这样的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.