Covert FLAC to AIFF while saving tags/metadata
I need a command-line tool to convert a bunch of XXX.flac
files to XXX.aiff
while preserving the tags (artist, title, album, etc.). None of the tools I tried (ffmpeg, sox, flac) seem to do the job well. Here is an example:
ygabuev@core:~/Music/2019 Sun Ra - Crystal Spears [FLAC]$ ffmpeg -loglevel info -i "01 - Crystal Spears.flac" -map_metadata 0 -id3v2_version 3 out.aiff
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, flac, from '01 - Crystal Spears.flac':
Metadata:
ARTIST : Sun Ra
ALBUM : Crystal Spears
DATE : 2019
album_artist : Sun Ra
LABEL : Modern Harmonic
UPC : 0090771808226
GENRE : Jazz
disc : 1
track : 01
TRACKTOTAL : 04
ISRC : USCWY1800460
TITLE : Crystal Spears
DISCTOTAL : 1
Duration: 00:06:09.07, start: 0.000000, bitrate: 750 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 600x600 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
comment : Cover (front)
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> png (native))
Stream #0:0 -> #0:1 (flac (native) -> pcm_s16be (native))
Press [q] to stop, [?] for help
[swscaler @ 0x55bc89a85c40] deprecated pixel format used, make sure you did set range correctly
[aiff @ 0x55bc8999bc00] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Output #0, aiff, to 'out.aiff':
Metadata:
ARTIST : Sun Ra
ALBUM : Crystal Spears
DATE : 2019
album_artist : Sun Ra
LABEL : Modern Harmonic
UPC : 0090771808226
GENRE : Jazz
disc : 1
track : 01
TRACKTOTAL : 04
ISRC : USCWY1800460
TITLE : Crystal Spears
DISCTOTAL : 1
encoder : Lavf57.83.100
Stream #0:0: Video: png, rgb24(progressive), 600x600 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc
Metadata:
comment : Cover (front)
encoder : Lavc57.107.100 png
Stream #0:1: Audio: pcm_s16be (NONE / 0x454E4F4E), 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc57.107.100 pcm_s16be
frame= 1 fps=0.0 q=-0.0 Lsize= 63578kB time=00:06:09.06 bitrate=1411.2kbits/s speed= 796x
video:579kB audio:63578kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
(base) ygabuev@core:~/Music/2019 Sun Ra - Crystal Spears [FLAC]$ ffprobe out.aiff
ffprobe version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2007-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, aiff, from 'out.aiff':
Metadata:
title : Crystal Spears
Duration: 00:06:09.07, start: 0.000000, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16be, 44100 Hz, 2 channels, s16, 1411 kb/s
It can be seen that after conversion the only remaining tag is "title".
Can I do the job with ffmpeg or sox alone? Or should I use some other converting/tagging tools? What can you recommend?
My setup: Ubuntu 18.04.3, ffmpeg 3.4.6, sox v14.4.2.
Solution 1:
Add -write_id3v2 1
output option. This is off by default for the AIFF muxer. See ffmpeg -h muxer=aiff
.
ffmpeg -i input.flac -write_id3v2 1 -c:v copy output.aiff