Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not including artwork #10

Open
elnoxgdl opened this issue Feb 9, 2015 · 7 comments
Open

Not including artwork #10

elnoxgdl opened this issue Feb 9, 2015 · 7 comments

Comments

@elnoxgdl
Copy link

elnoxgdl commented Feb 9, 2015

Hi,

I've been using another library to tag my files until I discover yours... however even when I'm able to tag the data the artwork method is not working.

I tried png and jpg files nothing attach the files. I'm using ffmpet 0.10.x and libav 11.x in my server. When I call the method it says it was added so no error or exception is displayed something that I'm might be missing?

@parshap
Copy link
Owner

parshap commented Feb 9, 2015

Can you share your code? How are you determining that it is not working? What is the output of ffprobe on the file after attaching the artwork?

@elnoxgdl
Copy link
Author

elnoxgdl commented Feb 9, 2015

Below my code ... a simple method call... then I just pass the mp3 file (I hardcoded the image name)
ffprobe returns only the metadata, no image info.

Copying the file to Windows OS, OS X and running respective media players did not show the image.

#! /usr/bin/node

require('neon');
require('neon/stdlib');
var ffmetadata = require("ffmetadata");


Class('Tagger').includes(CustomEventSupport)({
    prototype : {

        init : function(){
                //EMPTY
        },

        METADATA_READ : function (file){
            var tg = this;
            ffmetadata.read(file, function (err, data){
                if (err) console.error("Error reading metadata", err);
                else console.log(data);
            });
        },

        METADATA_WRITE : function (file){
            var tg = this;

            var options = {
                attachments: ['cover.jpg'],
                'id3v2.3' : true
            }

            ffmetadata.write(file, {}, options, function (err){
                if (err) console.error("Error writing cover art");
                else console.log("Cover art added");
            });

        }
    }
});

var tg = new Tagger();
// tg.METADATA_READ('test.mp3');
tg.METADATA_WRITE('test.mp3');

@parshap
Copy link
Owner

parshap commented Feb 9, 2015

Something is definitly not working. Here's my test using ffmpeg directly:

$ ffmpeg -y -i test/test-artwork.mp3 -i test/test-cover.jpg -map 0:0 -map 1:0 -codec copy out.mp3
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 26 2014 09:49:36 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mp3 @ 0x17b2860] max_analyze_duration 5000000 reached at 5015510
Input #0, mp3, from 'test/test-artwork.mp3':
  Metadata:
    date            : 2008
    album           : The Slip
    encoded_by      : LAME
    title           : 999,999
    composer        : Trent Reznor
    track           : 1/10
    disc            : 1/1
    artist          : bar
    encoder         : Lavf53.32.100
  Duration: 00:00:09.58, start: 0.000000, bitrate: 254 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
Input #1, image2, from 'test/test-cover.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: mjpeg, yuvj420p, 550x487 [SAR 96:96 DAR 550:487], 25 tbr, 25 tbn, 25 tbc
Output #0, mp3, to 'out.mp3':
  Metadata:
    TDRL            : 2008
    TALB            : The Slip
    TENC            : LAME
    TIT2            : 999,999
    TCOM            : Trent Reznor
    TRCK            : 1/10
    TPOS            : 1/1
    TPE1            : bar
    TSSE            : Lavf53.32.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, 192 kb/s
    Stream #0:1: Video: mjpeg, yuvj420p, 550x487 [SAR 96:96 DAR 550:487], q=2-31, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=    1 fps=  0 q=-1.0 Lsize=     298kB time=00:00:00.04 bitrate=60947.6kbits/s
video:42kB audio:255kB global headers:0kB muxing overhead 0.263871%

$ ffprobe out.mp3
ffprobe version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2007-2014 the FFmpeg developers
  built on Apr 26 2014 09:49:36 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mp3 @ 0x11e8f40] max_analyze_duration 5000000 reached at 5015510
Input #0, mp3, from 'out.mp3':
  Metadata:
    date            : 2008
    album           : The Slip
    encoded_by      : LAME
    title           : 999,999
    composer        : Trent Reznor
    track           : 1/10
    disc            : 1/1
    artist          : bar
    encoder         : Lavf53.32.100
  Duration: 00:00:07.88, start: 0.000000, bitrate: 309 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s

Note that the ffmpeg command indicates that it is writing the jpeg file, but ffprobe only reports the audio stream.

@nucleardreamer any idea why this might not be working?

@nucleardreamer
Copy link
Contributor

So unfortunately, ffprobe will never be able to the embedded cover art, it's actually becomes part of the ID3 metadata! It's incredibly stupid, but mp3 metadata was never designed for binary images, and got kind of bolted on in ID3v2.

Everything seems to be working fine for me running the tests, and using this module in a couple other projects I have. The most reliable way to test for the cover art is eyeD3, here is my output:

$ eyeD3 __test-artwork.mp3
__test-artwork.mp3  [ 2.24 MB ]
-------------------------------------------------------------------------------
Time: 01:25 MPEG1, Layer III    [ ~216 kb/s @ 44100 Hz - Stereo ]
-------------------------------------------------------------------------------
ID3 v2.4:
title: 999,999
artist: bar
album: The Slip
album artist: None
recording date: 2008
track: 1        
disc: 1/1
Publisher/label: 
UserTextFrame: [Description: TRACKTOTAL]
10
OTHER Image: [Size: 42594 bytes] [Type: image/jpeg]
Description: 

-------------------------------------------------------------------------------

and the same file size matches the test cover as well

$ ls -la | grep test-cover.jpg
-rw-r--r--   1 flynnjoffray  staff    42594 Feb  9 15:17 test-cover.jpg

Important note as well, because we are using ffmpeg it causes the album art to not have an official image type, only the default $00, from the frame translation, which equates to 'other' (ideally we would want to specify $03 front cover, and $04 back cover). I don't believe ffmpeg has options to set this :/

@elnoxgdl
Copy link
Author

Well it seems to be working now... how? Easy Instead of building/using yum repo for ffmpeg I download ed the official static builds from FFMPEG after running the same exact set of commands passed by the nodejs module (or using cli) ffprobe was able to detect the image:

ffprobe version 2.5.3-   http://johnvansickle.com/ffmpeg/    Copyright (c) 2007-2015 the FFmpeg developers
  built on Jan 10 2015 09:24:27 with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --disable-ffserver --enable-libass --enable-gnutls --cc=gcc
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[mp3 @ 0x2ff41a0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'out.mp3':
  Metadata:
    title           : Test of MP3 File
    artist          : Me
    album           : Me
    encoder         : Lavf56.15.102
    comment         : test
    track           : 1
    genre           : Other
    date            : 2006
  Duration: 00:00:15.45, start: 0.011995, bitrate: 136 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s
    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 200:200 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           : Album cover
      comment         : Cover (front)

I guess I'll use this ffmpeg binary instead!

@nucleardreamer
Copy link
Contributor

Woa! I guess I've been living a lie! My ffmpeg was outputting the same as before. It does bother me that the metadata comment doesn't translate to the official ID3v2 schema. It's still catagorized as other which negates the option of classifying any other images correctly onto the same file.

@RenautMestdagh
Copy link

The problem is, the tag "comment: Cover (front)" isn't (correctly) set. Don't know how to fix it tho. When I put in a metadata extractor, the value of the field "comment" is "Other".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants