Keep audio metadata (incl. cover art) when transcoding audio files

Issue #650 resolved
Will Lunniss created an issue

The -vn option removes any video streams which are usually used to store album artwork. This may be needed for some devices (seems like the only reason it would be there now), but it isn't needed for CDS clients and results in the transcoded audio files not having any artwork. Here is an example mp3 showing a video stream that contains the album artwork.

#!

Input #0, mp3, from '01 Intro.mp3':
  Metadata:
    TLEN            : 22800
    publisher       : Warner Music
    title           : Intro
    artist          : Muse
    album_artist    : Muse
    album           : Absolution
    track           : 1
    genre           : Rock
    date            : 2003
  Duration: 00:00:23.42, start: 0.000000, bitrate: 127 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Stream #0:1: Video: mjpeg, yuvj420p, 200x200 [SAR 300:300 DAR 1:1], 90k tbr, 90k tbn, 90k tbc

Comments (7)

  1. Will Lunniss reporter

    Just did a quick test starting with an m4a files.

    This is what Serviio ran (changed output file)

    #!
    
     ffmpeg -i "/mnt/data0/media/music/Cream/Wheels Of Fire [Disc 1]/09 Deserted Cities Of The Heart.m4a" -y -b:a 192k -ac 2 -vn -f mp3 /mnt/data0/tmp/no_art.stf
    ffmpeg version N-50554-gcada996 Copyright (c) 2000-2013 the FFmpeg developers
      built on Mar  7 2013 15:46:47 with gcc 4.4.5 (Debian 4.4.5-8)
      configuration: --enable-ssse3 --enable-gpl --enable-libmp3lame --enable-version3 --enable-nonfree --enable-librtmp --enable-runtime-cpudetect --enable-pthreads --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-libass --enable-libfreetype --enable-fontconfig
      libavutil      52. 18.100 / 52. 18.100
      libavcodec     54. 92.100 / 54. 92.100
      libavformat    54. 63.104 / 54. 63.104
      libavdevice    54.  3.103 / 54.  3.103
      libavfilter     3. 42.103 /  3. 42.103
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xa64b3e0] stream 0, timescale not set
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xa64b3e0] max_analyze_duration 5000000 reached at 5015510 microseconds
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/data0/media/music/Cream/Wheels Of Fire [Disc 1]/09 Deserted Cities Of The Heart.m4a':
      Metadata:
        major_brand     : M4A
        minor_version   : 0
        compatible_brands: M4A mp42isom
        creation_time   : 2010-12-05 17:03:29
        title           : Deserted Cities Of The Heart
        artist          : Cream
        composer        : Peter Brown/Jack Bruce
        album           : Wheels Of Fire [Disc 1]
        genre           : Rock
        track           : 9/9
        disc            : 1/1
        date            : 1968
        gapless_playback: 0
        encoder         : iTunes 10.1.0.54, QuickTime 7.6.8
        album_artist    : Cream
      Duration: 00:03:38.34, start: 0.000000, bitrate: 287 kb/s
        Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 282 kb/s
        Metadata:
          creation_time   : 2010-12-05 17:03:29
        Stream #0:1: Video: mjpeg, yuvj420p, 600x595 [SAR 72:72 DAR 120:119], 90k tbr, 90k tbn, 90k tbc
    Output #0, mp3, to '/mnt/data0/tmp/no_art.stf':
      Metadata:
        major_brand     : M4A
        minor_version   : 0
        compatible_brands: M4A mp42isom
        TPE2            : Cream
        TIT2            : Deserted Cities Of The Heart
        TPE1            : Cream
        TCOM            : Peter Brown/Jack Bruce
        TALB            : Wheels Of Fire [Disc 1]
        TCON            : Rock
        TRCK            : 9/9
        TPOS            : 1/1
        TDRL            : 1968
        gapless_playback: 0
        TSSE            : Lavf54.63.104
        Stream #0:0(und): Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
        Metadata:
          creation_time   : 2010-12-05 17:03:29
    Stream mapping:
      Stream #0:0 -> #0:0 (aac -> libmp3lame)
    Press [q] to stop, [?] for help
    size=    5118kB time=00:03:38.35 bitrate= 192.0kbits/s
    video:0kB audio:5117kB subtitle:0 global headers:0kB muxing overhead 0.018951%
    

    And it had no artwork, Removing the -vn option gives the following which did have artwork, so -vn does effect some types of conversions

    #!
    
    ffmpeg -i "/mnt/data0/media/music/Cream/Wheels Of Fire [Disc 1]/09 Deserted Cities Of The Heart.m4a" -y -b:a 192k -ac 2 -f mp3 /mnt/data0/tmp/with_art.stf
    ffmpeg version N-50554-gcada996 Copyright (c) 2000-2013 the FFmpeg developers
      built on Mar  7 2013 15:46:47 with gcc 4.4.5 (Debian 4.4.5-8)
      configuration: --enable-ssse3 --enable-gpl --enable-libmp3lame --enable-version3 --enable-nonfree --enable-librtmp --enable-runtime-cpudetect --enable-pthreads --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-libass --enable-libfreetype --enable-fontconfig
      libavutil      52. 18.100 / 52. 18.100
      libavcodec     54. 92.100 / 54. 92.100
      libavformat    54. 63.104 / 54. 63.104
      libavdevice    54.  3.103 / 54.  3.103
      libavfilter     3. 42.103 /  3. 42.103
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xaf343c0] stream 0, timescale not set
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xaf343c0] max_analyze_duration 5000000 reached at 5015510 microseconds
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/data0/media/music/Cream/Wheels Of Fire [Disc 1]/09 Deserted Cities Of The Heart.m4a':
      Metadata:
        major_brand     : M4A
        minor_version   : 0
        compatible_brands: M4A mp42isom
        creation_time   : 2010-12-05 17:03:29
        title           : Deserted Cities Of The Heart
        artist          : Cream
        composer        : Peter Brown/Jack Bruce
        album           : Wheels Of Fire [Disc 1]
        genre           : Rock
        track           : 9/9
        disc            : 1/1
        date            : 1968
        gapless_playback: 0
        encoder         : iTunes 10.1.0.54, QuickTime 7.6.8
        album_artist    : Cream
      Duration: 00:03:38.34, start: 0.000000, bitrate: 287 kb/s
        Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 282 kb/s
        Metadata:
          creation_time   : 2010-12-05 17:03:29
        Stream #0:1: Video: mjpeg, yuvj420p, 600x595 [SAR 72:72 DAR 120:119], 90k tbr, 90k tbn, 90k tbc
    [mp3 @ 0xaf62540] 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, mp3, to '/mnt/data0/tmp/with_art.stf':
      Metadata:
        major_brand     : M4A
        minor_version   : 0
        compatible_brands: M4A mp42isom
        TPE2            : Cream
        TIT2            : Deserted Cities Of The Heart
        TPE1            : Cream
        TCOM            : Peter Brown/Jack Bruce
        TALB            : Wheels Of Fire [Disc 1]
        TCON            : Rock
        TRCK            : 9/9
        TPOS            : 1/1
        TDRL            : 1968
        gapless_playback: 0
        TSSE            : Lavf54.63.104
        Stream #0:0: Video: png, rgb24, 600x595 [SAR 1:1 DAR 120:119], q=2-31, 200 kb/s, 90k tbn, 90k tbc
        Stream #0:1(und): Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
        Metadata:
          creation_time   : 2010-12-05 17:03:29
    Stream mapping:
      Stream #0:1 -> #0:0 (mjpeg -> png)
      Stream #0:0 -> #0:1 (aac -> libmp3lame)
    Press [q] to stop, [?] for help
    frame=    1 fps=0.0 q=0.0 Lsize=    5574kB time=00:03:38.35 bitrate= 209.1kbits/s
    video:456kB audio:5117kB subtitle:0 global headers:0kB muxing overhead 0.017803%
    
  2. Will Lunniss reporter

    And it also needs -id3v2_version 3 added to the options to force ID3v2.3 tags as artwork in 2.4 tags won't seem to be supported under Android (Windows doesn't support 2.4 either).

  3. Will Lunniss reporter

    I think -map_metadata 0 is only needed for flac. I don't have any to test at the moment.

  4. Log in to comment