cmdffmpegm4aforfilesaudio-converter

ffmpeg error "output file #0 does not contain any stream" with FORFILES


I'm trying to convert all the songs in a folder from flac to alac. All the files in the folder are 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

Solution

  • The forfiles command is a nasty beast, because there are several caveats:

    All of these 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):

    The ~n-modifier expands to the base name with the extension .flac removed.

    If you do insist in using forfiles, then apply it like this:

    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.