Bug 306895 - When copying to a collection: Transcoding ogg to mp3 loses metadata
Summary: When copying to a collection: Transcoding ogg to mp3 loses metadata
Status: CONFIRMED
Alias: None
Product: amarok
Classification: Applications
Component: Transcoding (show other bugs)
Version: 2.8.0
Platform: openSUSE Linux
: VHI major
Target Milestone: 2.9
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-16 17:03 UTC by Franz Häuslschmid
Modified: 2015-11-14 23:06 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Debug output of amarok transcoding ogg to mp3 (9.17 KB, text/plain)
2012-09-16 17:04 UTC, Franz Häuslschmid
Details
Sample of one of my ogg files, shortened using Audacity (159.83 KB, video/ogg)
2012-09-19 19:14 UTC, Franz Häuslschmid
Details
Transcoded version of the sample (167.23 KB, audio/mpeg)
2012-09-19 19:16 UTC, Franz Häuslschmid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franz Häuslschmid 2012-09-16 17:03:14 UTC
Ogg music files that are copied to a collection (e.g. on a USB drive) and transcoded to mp3 lose their metadata.

The command line for transcoding looks like

  ffmpeg -y -i '/home/itsme/Dokumente/Musik/Alben/Radiohead/Kid A/01 - Everything in Its Right Place.ogg' -acodec libmp3lame -aq 3 '/media/CRUZFIT/Radiohead/Kid A/01 - Everything in Its Right Place.mp3'

and doesn't use the -map_metadata switch.

Reproducible: Always
Comment 1 Franz Häuslschmid 2012-09-16 17:04:06 UTC
Created attachment 73963 [details]
Debug output of amarok transcoding ogg to mp3
Comment 2 Matěj Laitl 2012-09-16 18:17:30 UTC
Hi Franz,

(In reply to comment #0)
> Ogg music files that are copied to a collection (e.g. on a USB drive) and
> transcoded to mp3 lose their metadata.
> 
> The command line for transcoding looks like
> 
>   ffmpeg -y -i '/home/itsme/Dokumente/Musik/Alben/Radiohead/Kid A/01 -
> Everything in Its Right Place.ogg' -acodec libmp3lame -aq 3
> '/media/CRUZFIT/Radiohead/Kid A/01 - Everything in Its Right Place.mp3'
> 
> and doesn't use the -map_metadata switch.

ffmpeg doesn't need the -map_metadata switch as can be seen from the debug log:

amarok: ffmpeg: Input #0, ogg, from '/home/itsme/Dokumente/Musik/Alben/Radiohead/Kid A/01 - Everything in Its Right Place.ogg': 
amarok: ffmpeg:   Duration: 00:04:11.42, start: 0.000000, bitrate: 265 kb/s 
amarok: ffmpeg:     Stream #0:0: Audio: vorbis, 44100 Hz, stereo, s16, 256 kb/s 
amarok: ffmpeg:     Metadata: 
amarok: ffmpeg:       KDE-ENCODER     : kio_audiocd 
amarok: ffmpeg:       TITLE           : Everything in Its Right Place 
amarok: ffmpeg:       ARTIST          : Radiohead 
amarok: ffmpeg:       ALBUM           : Kid A 
amarok: ffmpeg:       GENRE           : Electronic 
amarok: ffmpeg:       track           : 1 
amarok: ffmpeg:       DATE            : 2000 
amarok: ffmpeg:       METADATA_BLOCK_PICTURE: AAAAAwAAAAppbWFnZS9qcGVnAAAADEFsYnVtQXJ0LmpwZwAAASwAAAEsAAAAIAAAAAAAAFlV/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjI 
amarok: ffmpeg:  
amarok: ffmpeg: Output #0, mp3, to '/media/CRUZFIT/Radiohead/Kid A/01 - Everything in Its Right Place.mp3': 
amarok: ffmpeg:   Metadata: 
amarok: ffmpeg:     TSSE            : Lavf54.6.100 
amarok: ffmpeg:     Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16 
amarok: ffmpeg:     Metadata: 
amarok: ffmpeg:       KDE-ENCODER     : kio_audiocd 
amarok: ffmpeg:       TITLE           : Everything in Its Right Place 
amarok: ffmpeg:       ARTIST          : Radiohead 
amarok: ffmpeg:       ALBUM           : Kid A 
amarok: ffmpeg:       GENRE           : Electronic 
amarok: ffmpeg:       track           : 1 
amarok: ffmpeg:       DATE            : 2000 
amarok: ffmpeg:       METADATA_BLOCK_PICTURE:  


This looks to me like a duplicate of bug 306827, can you investigate if Amarok can read metadata of tracks you browse through embedded file browser and that Amarok is compiled with TagLib support? How do you get Amarok - do you compile it?
Comment 3 Franz Häuslschmid 2012-09-17 18:13:59 UTC
I got Amarok from packman:
  <http://ftp.uni-erlangen.de/pub/mirrors/packman/suse/12.2/Essentials/x86_64/>

Metadata of tracks that aren't in my collection path are presented correctly.  I now think that it's rather a problem with ffmpeg.  When I execute the command line I mentioned above, no metadata is written to the target file... ffmpeg origins from the same source as Amarok.
Comment 4 Matěj Laitl 2012-09-17 19:00:16 UTC
(In reply to comment #3)
> Metadata of tracks that aren't in my collection path are presented
> correctly.  I now think that it's rather a problem with ffmpeg.  When I
> execute the command line I mentioned above, no metadata is written to the
> target file... ffmpeg origins from the same source as Amarok.

That may be the culprit. This wors for other people AFAIK.
Comment 5 Franz Häuslschmid 2012-09-18 17:12:05 UTC
I performed some additional tests and finally added the -map_metadata switch with parameter "0:s" (default is "0:g"):

$> ffmpeg -y -i 01\ -\ Everything\ in\ Its\ Right\ Place.ogg -acodec libmp3lame -map_metadata 0:s -aq 3 test.mp3
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun 10 2012 22:43:48 with gcc 4.7.1 20120723 [gcc-4_7-branch revision 189773]
  configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --disable-static --enable-debug --disable-stripping --extra-cflags='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/gsm' --enable-gpl --enable-x11grab --enable-version3 --enable-pthreads --enable-avfilter --enable-libpulse --enable-libvpx --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-postproc --enable-libdc1394 --enable-librtmp --enable-libfreetype --enable-avresample
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, ogg, from '01 - Everything in Its Right Place.ogg':
  Duration: 00:04:11.42, start: 0.000000, bitrate: 265 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, s16, 256 kb/s
    Metadata:
      KDE-ENCODER     : kio_audiocd
      TITLE           : Everything in Its Right Place
      ARTIST          : Radiohead
      ALBUM           : Kid A
      GENRE           : Electronic
      track           : 1
      DATE            : 2000
      METADATA_BLOCK_PICTURE: [...]
Output #0, mp3, to 'test.mp3':
  Metadata:
    KDE-ENCODER     : kio_audiocd
    TIT2            : Everything in Its Right Place
    TPE1            : Radiohead
    TALB            : Kid A
    TCON            : Electronic
    TRCK            : 1
    TDRL            : 2000
    METADATA_BLOCK_PICTURE: [...]
    TSSE            : Lavf54.6.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16
Stream mapping:
  Stream #0:0 -> #0:0 (vorbis -> libmp3lame)
Press [q] to stop, [?] for help
size=    5927kB time=00:04:11.45 bitrate= 193.1kbits/s    
video:0kB audio:5897kB global headers:0kB muxing overhead 0.512607%

(The metadata fields are now named differently.)

According to the ffmpeg documentation (<http://ffmpeg.org/ffmpeg.html>) per stream metadata is copied, which results in mp3 files containing the metadata and is different from copying the global metadata.

In the end this is not a problem of Amarok.  However, I would like to know, if my Ogg files lack some critical information for successful transcoding of metadata, or if my installation of ffmpeg is flawed in some obscure way.
Comment 6 Matěj Laitl 2012-09-18 18:27:05 UTC
Interesting, so:

a) Output #0, mp3, to '/media/CRUZFIT/Radiohead/Kid A/01 - Everything in Its Right Place.mp3': 
  Metadata: 
    TSSE            : Lavf54.6.100 
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16 
    Metadata: 
      KDE-ENCODER     : kio_audiocd 
      TITLE           : Everything in Its Right Place 
      ARTIST          : Radiohead 
      ALBUM           : Kid A 
      GENRE           : Electronic 
      track           : 1 
      DATE            : 2000 
      METADATA_BLOCK_PICTURE: [...]
Stream mapping: 
  Stream #0:0 -> #0:0 (vorbis -> libmp3lame)

b) Output #0, mp3, to 'test.mp3':
  Metadata:
    KDE-ENCODER     : kio_audiocd
    TIT2            : Everything in Its Right Place
    TPE1            : Radiohead
    TALB            : Kid A
    TCON            : Electronic
    TRCK            : 1
    TDRL            : 2000
    METADATA_BLOCK_PICTURE: [...]
    TSSE            : Lavf54.6.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16
Stream mapping:
  Stream #0:0 -> #0:0 (vorbis -> libmp3lame)


Where b) works but a) does not, right? Now I wonder how metadata of a) actually look like. Can you use a tool like MP3Diags to diagnose it? Or upload the 2 files somewhere? (there may be copyright problems however) Can you also try older ffmpeg? (your 11.1 is rather new, a version like 0.10.x is more tried)

The thing is that Amarok could use `-map_metadata 0:s`, but I fear that it could break other things. Additionally we try to be compatible with both ffmpeg and avconv (from libav),  and I don't know whether
Comment 7 Matěj Laitl 2012-09-18 18:27:48 UTC
...whether avconv supports -map_metadata the same way as ffmpeg does.
Comment 8 Franz Häuslschmid 2012-09-19 19:14:54 UTC
Created attachment 74034 [details]
Sample of one of my ogg files, shortened using Audacity
Comment 9 Franz Häuslschmid 2012-09-19 19:16:03 UTC
Created attachment 74035 [details]
Transcoded version of the sample
Comment 10 Franz Häuslschmid 2012-09-19 19:16:43 UTC
Sample was transcoded using Amarok's facilities.
Comment 11 Myriam Schweingruber 2012-10-21 11:14:11 UTC
Thank you for the feedback.
Comment 12 Mayank Madan 2012-12-19 17:25:04 UTC
Can reproduce this in v2.6.90-26-gbcdd84c
Comment 13 Myriam Schweingruber 2012-12-21 14:20:22 UTC
Set version and status correctly.
Comment 14 Thiago Jung Bauermann 2013-01-03 18:48:01 UTC
Regarding avconv:

I am affected by this bug on Ubuntu 12.04, using the ffmpeg command from libav-tools package.

Contrary to what Franz said in comment 5, the -map_metadata 0:s option doesn't work here:

hactar% ffmpeg -i Breed.ogg -map_metadata 0:s /tmp/bloh.mp3
ffmpeg version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:50:25 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, ogg, from 'Breed.ogg':
  Duration: 00:03:03.82, start: 0.000000, bitrate: 106 kb/s
    Stream #0.0: Audio: vorbis, 44100 Hz, stereo, s16, 112 kb/s
    Metadata:
      TITLE           : Breed
      ARTIST          : Nirvana
      GENRE           : Grunge
      DATE            : 1991
      ALBUM           : Nevermind
      track           : 04
Output #0, mp3, to '/tmp/bloh.mp3':
  Metadata:
    TSSE            : Lavf53.21.0
    Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 200 kb/s
    Metadata:
      TITLE           : Breed
      ARTIST          : Nirvana
      GENRE           : Grunge
      DATE            : 1991
      ALBUM           : Nevermind
      track           : 04
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
size=    4310kB time=183.88 bitrate= 192.0kbits/s    
video:0kB audio:4310kB global headers:0kB muxing overhead 0.003104%

The output above is exactly the same one I get if I don't add the -map_metadata 0:s option at all.

The ffmpeg command needs a slightly different option, -map_metadata 0:0,s0:

hactar% ffmpeg -i Breed.ogg -map_metadata 0:0,s0 /tmp/blih.mp3
ffmpeg version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:50:25 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, ogg, from 'Breed.ogg':
  Duration: 00:03:03.82, start: 0.000000, bitrate: 106 kb/s
    Stream #0.0: Audio: vorbis, 44100 Hz, stereo, s16, 112 kb/s
    Metadata:
      TITLE           : Breed
      ARTIST          : Nirvana
      GENRE           : Grunge
      DATE            : 1991
      ALBUM           : Nevermind
      track           : 04
Output #0, mp3, to '/tmp/blih.mp3':
  Metadata:
    TIT2            : Breed
    TPE1            : Nirvana
    TCON            : Grunge
    TDRL            : 1991
    TALB            : Nevermind
    TRCK            : 04
    TSSE            : Lavf53.21.0
    Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 200 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
size=    4310kB time=183.88 bitrate= 192.0kbits/s
video:0kB audio:4310kB global headers:0kB muxing overhead 0.005484%

The avconv command, on the other hand, does work with -map_metadata 0:s as seen here:

hactar% avconv -i Breed.ogg -map_metadata 0:s /tmp/irgh.mp3
avconv version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:50:25 with gcc 4.6.3
Input #0, ogg, from 'Breed.ogg':
  Duration: 00:03:03.82, start: 0.000000, bitrate: 106 kb/s
    Stream #0.0: Audio: vorbis, 44100 Hz, stereo, s16, 112 kb/s
    Metadata:
      TITLE           : Breed
      ARTIST          : Nirvana
      GENRE           : Grunge
      DATE            : 1991
      ALBUM           : Nevermind
      track           : 04
Output #0, mp3, to '/tmp/irgh.mp3':
  Metadata:
    TIT2            : Breed
    TPE1            : Nirvana
    TCON            : Grunge
    TDRL            : 1991
    TALB            : Nevermind
    TRCK            : 04
    TSSE            : Lavf53.21.0
    Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 200 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (vorbis -> libmp3lame)
Press ctrl-c to stop encoding
size=    4310kB time=183.88 bitrate= 192.0kbits/s    
video:0kB audio:4310kB global headers:0kB muxing overhead 0.005484%

To summarize: if using the real ffmpeg command or the avconv command, using -map_metadata 0:s solves this bug. On the other hand, if using the deprecated ffmpeg fake command from libav-tools, the slightly different -map_metadata 0:0,s0 is needed.
Comment 15 Matěj Laitl 2013-05-27 10:15:54 UTC
Note to self: solve this by actually writing original metadata to transcoded file, we trust taglib more than ffmpeg.
Comment 16 Mikhail Ivchenko 2013-12-01 17:28:01 UTC
Bug reproducible with v2.8.0