JamesHeinrich / getID3

http://www.getid3.org/
Other
1.15k stars 246 forks source link

[Issue] "invalid mpeg audio header" in each file #163

Closed ffatgit closed 6 years ago

ffatgit commented 6 years ago

Hello James, I have an issue in the software o!mpd, that uses your great piece of software. In my test files (ripped with Rhythmbox V3.3 on a 64 Bit Ubuntu 16.04 LTS os) there is found a "invalid mpeg audio header" in each file. After reporting this issue a feedback from the developer of o!mpd says, that is probaly an issue in getID3. So please could you check the example file in co-working with getID3. Is there an issue in the software OR (what is the next possible reason to the situation:) is ther something "wrong" with my files (ID3 tagging).

Screenshot: ompd_file_error

Zipped-Sample track in format MP3: Tremonti (2018) - A Dying Machine - 11. As The Silence Becomes Me.zip

please check out the original post of the issue in the o!mpd Github repo. https://github.com/ArturSierzant/OMPD/issues/68

Thank you very much! Frank

JamesHeinrich commented 6 years ago

Thanks. The problem would happen only on VBR MP3 files with no VBR header, where getID3 had to scan through the entire file to build an accurate VBR bitrate. When it got to the end of the file it reported a false error. Fixed in https://github.com/JamesHeinrich/getID3/commit/8553baf78653075a9b34687fa732a95399fd2f57

ffatgit commented 6 years ago

Hello James; thank you very much for the fast fixing. Is it right, that I only have to copy in minimum the file getid3.php to my instance in the folder getid3?

Greetings Frank

JamesHeinrich commented 6 years ago

getid3.php is the basic framework. You will almost certainly need getid3.lib.php for everything, and then you will also need the module(s) for the file format(s) you want to analyze. If you're examining MP3 files then you must have module.audio.mp3.php, but you really should also have all the tag modules (module.tag.id3v2.php, module.tag.id3v1.php, module.tag.apetag.php, module.tag.lyrics3.php) because those can appear on MP3 files and if they're not properly parsed first then you may get incorrect results on the MP3 audio portion.

ArturSierzant commented 6 years ago

Hello James, first of all big thank you for your excellent work (I use it in my O!MPD)!

I still have a problem with this issue: when I use your demo.browse.php to read tags from file attached by ffatgit, everything is now OK: there is no info about errors. But when I use this simple code:

<?php

require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;

$getID3->encoding = 'UTF-8';
$getID3->encoding_id3v1 = 'ISO-8859-1';
$getID3->option_tag_id3v1 = false;
$getID3->option_tag_id3v2 = true;
$getID3->option_tag_lyrics3 = false;
$getID3->option_tag_apetag = true;
$getID3->option_tags_process = true;
$getID3->option_tags_html = false;
$getID3->option_extra_info = true;
$getID3->option_save_attachment = true;
$getID3->option_md5_data = false;
$getID3->option_md5_data_source = false;
$getID3->option_sha1_data = false;
$getID3->option_max_2gb_check = null;

$file_d = '/mnt/media/nas/_DSD/tw/corr.mp3';

$ThisFileInfo = $getID3->analyze($file_d);
getid3_lib::CopyTagsToComments($ThisFileInfo); 

if (!empty($ThisFileInfo['error'])) {
    echo implode("<br>", $ThisFileInfo['error']);
}

?>

where corr.mp3 is ffatgit's file, error is still reported: Invalid MPEG audio header (54 41 47 41 ) at offset 11151064

Could you give me please some hints, what I'm doing wrong? Many thanks.

JamesHeinrich commented 6 years ago

This is probably your problem:

$getID3->option_tag_id3v1 = false;
$getID3->option_tag_lyrics3 = false;

If tags at the end of the file (usually ID3v1, sometimes APE, rarely Lyrics3) aren't stripped off the end of the file then they will appear as appended invalid audio data (which, technically, they are, we just understand certain tags can be there by convention). Even if you don't actually need the ID3v1/APE/Lyrics3 data you should let getID3 check for it.

ArturSierzant commented 6 years ago

Thank you for very fast answer - that did a trick for that file. I changed default settings in my project as you suggested and updated whole my music library. Unfortunately update stopped on following file: 01. Annie Lennox - Why.mp3.zip Unfortunately it is also not possible to read tags from this file using demo.browse.php. When I change $getID3->option_tag_id3v1 back to false my program properly reads tags from this file. Would you help, please?

JamesHeinrich commented 6 years ago

Sorry, I don't see any problem with your sample file. It seems to be a standard CBR320 MP3 file with ID3v1 and ID3v2 (with attached cover art). No errors are reported in demo.browse.php What problem are you having?

ArturSierzant commented 6 years ago

Thanks - your answer suggested me something: I tried this on another server and there were no problem with reading tags from my file. So apparently my main server (based on LEDE) is missing something - probably a php-mod. Do you have a list of required php modules?

JamesHeinrich commented 6 years ago

getID3 has low PHP requirements, it's more likely you're missing the module.tag.id3v1.php from your one server installation.

ArturSierzant commented 6 years ago

Unfortunately it's not the problem - I have this module. I took a look into it, did some tests and found the problem. It lies in iconv function in ID3v1 encoding detection hack. Every time I try to execute iconv('KOI8-R', 'KOI8-R','test') or iconv('Windows-1251', 'Windows-1251','test') script stops to execute: in browser Bad Gateway The process did not produce any response is displayed and in php_errors.log following line appears: PHP Notice: iconv(): Unknown error (0) It's surely something wrong with my installation.

But then I started to wonder why, in spite of having mb_convert_encoding up and running, program keeps to execute part with iconv? My idea is that $value in general doesn't have to be a string type, while returned values from incov and mb_convert_encoding functions are the strings. So I changed === to == in lines 73 and 76 and it started to work. Am I on right path?

JamesHeinrich commented 6 years ago

You could try removing the "@" error-suppression on the mb_convert_encoding and iconv functions and see if PHP gives any useful error messages?

ArturSierzant commented 6 years ago

I did my tests without @ and with the following options:

error_reporting(E_ALL);
@ini_set('display_errors', -1);

That gave me PHP Notice: iconv(): Unknown error (0) in log. Additionally I found the following in dmesg:

php-cgi[29600]: segfault at 8fa33d69 ip b740532f sp bf9674e0 error 4 in iconv.so[b7400000+8000]

This happens only on my router:

When I move to other machines (QNAP NAS; RasPi3) everything is OK. So it's look like it's a problem with iconv library on LEDE. Unfortunately no newer version of this lib is available for my installation. Finally I decided to move my http server to RasPi - now it works flawless.

Thank you for your time and help.

tinarooot commented 3 years ago

我在上传文件到 我的springbooot idea编译 target包下面,我使用 System.out.println(AudioUtil.getMp3Duration("/media/tina/Hitachi/springboot/tina-im/target/classes/static/1.mp3"));

报以下错误,本身有文件的

org.jaudiotagger.audio.exceptions.InvalidAudioFrameException: No audio header found within1610520063991.mp3 at org.jaudiotagger.audio.mp3.MP3AudioHeader.(MP3AudioHeader.java:138) at org.jaudiotagger.audio.mp3.MP3File.(MP3File.java:379) at org.jaudiotagger.audio.mp3.MP3FileReader.read(MP3FileReader.java:39) at org.jaudiotagger.audio.AudioFileIO.readFile(AudioFileIO.java:285) at org.jaudiotagger.audio.AudioFileIO.read(AudioFileIO.java:148) at com.tina.utils.AudioUtil.getMp3Duration(AudioUtil.java:55) at com.tina.controller.HomeController.saveVoice(HomeController.java:136) at com.tina.controller.HomeController.uploadVoice(HomeController.java:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1061) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

StudioMaX commented 3 years ago

@xiao-ma-nong this is PHP GetID3 library, not Java. So we have no idea what is wrong in your log.

tinarooot commented 3 years ago

哦哦,抱歉

------------------ 原始邮件 ------------------ 发件人: "Pavel Starosek"<notifications@github.com>; 发送时间: 2021年1月13日(星期三) 下午3:11 收件人: "JamesHeinrich/getID3"<getID3@noreply.github.com>; 抄送: "╰早《…》應該♀放手╯"<3121831267@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [JamesHeinrich/getID3] [Issue] "invalid mpeg audio header" in each file (#163)

@ xiao-ma-nong这是PHP GetID3库,而不是Java。因此,我们不知道您的日志中有什么问题。

— 您收到此邮件是因为有人提到您。 直接回复此电子邮件,在GitHub上查看,或取消订阅。