Search code examples
linuxaudioffmpegwavflac

Out of ffmpeg and flac which should be used to convert wav files to flac? Why?


Considering:
http://www.commandlinefu.com/commands/view/4045/convert-wav-files-to-flac
and
ffmpeg to convert from flac to wav

Out of ffmpeg and flac which should be used to convert wav files to flac? WHY?


Solution

  • Both will make the same decoded output

    1. Make FLAC from WAV:

      $ ffmpeg -i input.wav ffmpeg.flac
      $ flac -o flac.flac input.wav
      
    2. Compare MD5 hashes of each decoded file:

      • The input file:

        $ ffmpeg -v 1 -i input.wav -f md5 -
          MD5=1a567b5d97e62a6656283d24850b707f
        
      • ffmpeg output:

        $ ffmpeg -v 1 -i ffmpeg.flac -f md5 -
          MD5=1a567b5d97e62a6656283d24850b707f
        
      • flac output:

        $ ffmpeg -v 1 -i flac.flac -f md5 -
          MD5=1a567b5d97e62a6656283d24850b707f
        

    This shows that both ffmpeg and flac make the exact same output when decoded, and the decoded output of the FLAC files are exactly the same as the decoded WAV file.

    Differences

    • flac was slightly faster in my single, lazyass test, but not significantly.

    • ffmpeg can decode a huge variety of formats (not that you should be making FLAC files from lossy inputs).

    • ffmpeg will always attempt to copy any existing metadata (but see --keep-foreign-metadata for flac).

    Summary

    Both are great tools, so use whatever you prefer.