我正在Node.js制作一个歌曲下载器应用程序。我设法让一切工作,应用程序下载歌曲并下载其艺术作品(图像)。所以我有mp3文件和jpg文件。唯一的问题是将jpg文件附加到mp3文件。
我正在使用ffmetadata node.js模块。我下载并安装了它的依赖“ffmpeg”cli。
现在,当我尝试将元数据写入mp3文件并附加图片时,它会发出此错误:
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
我的代码:
ffmetadata.write('test.mp3', {}, {attachments: ['test.jpg']}, function(err) {
if (err) console.error(err);
});
错误:
[Error: ffmpeg version N-73872-g6b96c70 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 28.100 / 54. 28.100
libavcodec 56. 50.101 / 56. 50.101
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 25.100 / 5. 25.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'songs/Irresistible - Fall Out Boy (Lyrics).mp3':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6mp41
creation_time : 2015-04-03 10:45:25
Duration: 00:03:26.94, start: 0.000000, bitrate: 128 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2015-04-03 10:45:25
handler_name : SoundHandler
Input #1, image2, from 'songs/albumart/Irresistible - Fall Out Boy (Lyrics).jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 24578 kb/s
Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 640x640 [SAR 300:300 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0000000004865d80] Invalid audio stream. Exactly one MP3 audio stream is required.
Output #0, mp3, to 'songs\Irresistible - Fall Out Boy (Lyrics).ffmetadata.mp3':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6mp41
dryRun : true
encoder : Lavf56.40.101
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 125 kb/s (default)
Metadata:
creation_time : 2015-04-03 10:45:25
handler_name : SoundHandler
Stream #0:1: Video: mjpeg, yuvj444p, 640x640 [SAR 300:300 DAR 1:1], q=2-31, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
]
答案 0 :(得分:0)
阅读输出:
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
[mp3 @ 0000000004865d80] Invalid audio stream. Exactly one MP3 audio stream is required
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
您的输入文件不是MP3而是MP4A / AAC。它有错误的扩展名。然后,您尝试将AAC流复制为MP3,这显然会失败。检查下载程序中的源文件。