node-ffmetadata
node-ffmetadata copied to clipboard
Cover will removed by write data
My mp3 has a cover and i run the code, the cover has removed. ffmetadata.write(p, data, function(err) { if (err) { console.log(err); } else { ffmetadata.read(p, function(err, data) { if (err) console.error("Error reading metadata", err); else console.log(data); }); } });
I have the same problem - I am using ffmetadata to rewrite data to files which have cover images, but after writing, the cover no longer seems to be there.
Same with me.
The current ffmpeg option only copies the first stream from the input file: https://github.com/parshap/node-ffmetadata/blob/c6cb960fc4e4459869246126c1dbf0b93cc6c1e7/index.js#L143
This will be just the audio stream and not any other data encoded in subsequent streams (e.g., cover art). To copy all streams from the input, the map option needs to be changed to -map 0
instead of -map 0:0
. Can anyone try this and let me know if it works for them?
This would have to be an option, as in my own workflow I like to strip all extra data out of audio file and re-attach my own cover art.
Partial success! It worked for the mp3 file I chose, but not an m4a file. Here's the error that I received when trying the m4a:
Error writing metadata Error: ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fd0fa006a00] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/ericb/Desktop/song.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
album_artist : Björk
compilation : 0
disc : 1/1
gapless_playback: 0
sort_artist : Björk
media_type : 1
track : 1/11
artist : Eric B
album : Debut
copyright : ℗ 1993 Bjork Overseas Ltd./One Little Indian Ltd. under exclusive license to Elektra Entertainment Group for North America and Mother Records/PMV for the rest of the world excluding UK and Iceland
date : 1993-01-01T00:00:00Z
genre : Alternative
title : Human Behaviour
encoder : Lavf56.40.101
Duration: 00:04:12.43, start: 0.000000, bitrate: 274 kb/s
Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 250 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1: Video: png, rgb24(pc), 600x600 [SAR 2835:2835 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
[ipod @ 0x7fd0fa803800] Codec for stream 0 does not use global headers but container format requires global headers
[ipod @ 0x7fd0fa803800] Codec for stream 1 does not use global headers but container format requires global headers
[ipod @ 0x7fd0fa803800] Could not find tag for codec png in stream #1, codec not currently supported in container
Output #0, ipod, to '/Users/ericb/Desktop/song.ffmetadata.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
album_artist : Björk
compilation : 0
disc : 1/1
gapless_playback: 0
sort_artist : Björk
media_type : 1
track : 1/11
artist : Eric B
album : Test Album Name
copyright : ℗ 1993 Bjork Overseas Ltd./One Little Indian Ltd. under exclusive license to Elektra Entertainment Group for North America and Mother Records/PMV for the rest of the world excluding UK and Iceland
date : 1993-01-01T00:00:00Z
genre : Alternative
title : Human Behaviour
encoder : Lavf56.40.101
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 250 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1: Video: png, rgb24, 600x600 [SAR 2835:2835 DAR 1:1], q=2-31, 90k tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
And here's the code I have that invokes ffmetadata:
var data = {
album: 'Test Album Name'
}
ffmetadata.write(filepath, data, function(err) {
if (err) console.error("Error writing metadata", err);
else console.log("Data written");
})
Finally, just to be certain that I modified the right code in the package, I now have inside getWriteArgs()
the line maps = ['-map', '0']
rather than maps = ['-map', '0:0']
Yep your change sounds right. Does that m4a file work without the change? I'm not sure what's going on and the ffmpeg output is not very helpful. Can you share your test file? If you want to keep it private my email is [email protected].
From this thread it sounds like ffmpeg may not support cover art for m4a files. https://trac.ffmpeg.org/ticket/2798
3 years ago by jamal
mov/mp4/m4a muxer currently doesn't support cover art. A patch that implements this was submitted to ffmpeg-devel a few weeks ago.
It's 3 years old though so I'm not sure if the status has changed since then.
The issue for the covers on m4a seems to be fixed.
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".