From patchwork Fri Apr 21 14:59:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sharpbai X-Patchwork-Id: 3458 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp344547vsd; Fri, 21 Apr 2017 08:07:17 -0700 (PDT) X-Received: by 10.223.174.130 with SMTP id y2mr14889035wrc.79.1492787236995; Fri, 21 Apr 2017 08:07:16 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p191si3338921wmd.27.2017.04.21.08.07.16; Fri, 21 Apr 2017 08:07:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF7A268991E; Fri, 21 Apr 2017 18:07:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E08C2689222 for ; Fri, 21 Apr 2017 18:06:56 +0300 (EEST) Received: by mail-oi0-f65.google.com with SMTP id m34so11999737oik.2 for ; Fri, 21 Apr 2017 08:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7DPx+a8+V5xMYNw6jUSibgq3uuciqtq4FvRNE1/qtHA=; b=g9ip878DP0yxOatWo8/t3zry3NjDQUxpl+UgGiWxrHNfLaCsqfK6T4lLOdkGvZYfPD kX8RwT60agIPLC5p0ib7h7D2ADsXz27tZLHmAp2dwQf3Rin+nMQkTnTw2pkLtIB+9Uhg BaUDNC4M7AhhwPTdMIFH2KIl1toPqUl2v9RuBUZRvP3Z9/t/L/I0UTJdgCPdLY24Rlxc 1CrI/vXWieg4CyLjDywNWGz0G4fI8bQX3gwYAZr3m61/WrLSoV0yLH5kRlCpzCySiTsa tUHacifpRFUDLDOhkGghlwwM+gA/kGxuMe1vndrAn3xEnIkYU98Q6efhMFUsUk7rRMEV M3Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7DPx+a8+V5xMYNw6jUSibgq3uuciqtq4FvRNE1/qtHA=; b=HuMsU8NsTT+xGjrMk/vyBILvUJEvDi/g1uWdLiEgx5O/IAYcFptRRp08r4A9g7Alja YizcHEy/Am8uXHE2QxxEVwwILlKIfgJa2EVLMsYKI2AOIT/lob36kSSDzf0ItwBXdXBe 3KHCVcqNmXSDGU024pFlSTUntFzn8lTRHNl60ea2ibJUYFnQT+1L4N02Xijv+gIx5BWU dqHwZZWF/8MH/lSyZNpf2DaPAwKqZhHt34zsLesXR5gNaQ5xvzwLpWAM5UDxz5AeIxOi FnzMPAs2AeIHqR1lQqZNBb8FT2I8LmnRuGafWdqad+wpsJJnPo1/DDtk35XRwZp/6Isv lvdg== X-Gm-Message-State: AN3rC/7Kfk3xixlN8ZhF4Ci7u/vpCge307rR3gtRadZOFzZNyhTmtGTE IK9hkkAQYj6CSw== X-Received: by 10.84.210.73 with SMTP id z67mr8335082plh.6.1492786795377; Fri, 21 Apr 2017 07:59:55 -0700 (PDT) Received: from localhost.localdomain (li377-58.members.linode.com. [106.187.34.58]) by smtp.gmail.com with ESMTPSA id m19sm16734864pfg.115.2017.04.21.07.59.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 21 Apr 2017 07:59:54 -0700 (PDT) From: sharpbai@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Apr 2017 22:59:41 +0800 Message-Id: <1492786781-77792-1-git-send-email-sharpbai@gmail.com> X-Mailer: git-send-email 2.2.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_Notify_user_when_encode_a_CB?= =?utf-8?q?R_mp3_file_without_=22-write=5Fxing_false=22=2E_This_may?= =?utf-8?q?_result_in_mp3_file_duration_incorect_on_ios_safari_brow?= =?utf-8?q?ser_and_webview=2E_I_try_to_fix_it_but_it_can=E2=80=99t_?= =?utf-8?q?be_done_as_mp3_muxer_don=E2=80=99t_know_it_is_a_CBR_file?= =?utf-8?q?_until_encode_process_finished=2E_And_it=E2=80=99s_hard_?= =?utf-8?q?to_remove_the_first_frame_at_that_time=2E_Only_the_mp3_e?= =?utf-8?q?ncoder=28such_as_libmp3lame=29_know_it_is_CBR_or_not_bef?= =?utf-8?q?ore_encoding_start=2E?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: sharpbai Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: sharpbai Bug example: ffmpeg -i a.mp3 -c:a mp3 -ab 32k -ar 44100 -ac 1 b.mp3 The duration of the generated file b.mp3 is wrong on ios safari browser from ios7 to ios10. --- libavformat/mp3enc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 3cbf7bd..a55dbf4 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -395,8 +395,13 @@ static void mp3_update_xing(AVFormatContext *s) int i, rg_size; /* replace "Xing" identification string with "Info" for CBR files. */ - if (!mp3->has_variable_bitrate) + if (!mp3->has_variable_bitrate) { AV_WL32(mp3->xing_frame + mp3->xing_offset, MKTAG('I', 'n', 'f', 'o')); + av_log(s, AV_LOG_WARNING, + "This is a CBR mp3 file. But its first frame header might be wrong, " + "which result in file duration incorrect on ios browser. " + "Please add \"-write_xing false\" to avoid this problem.\n"); + } AV_WB32(mp3->xing_frame + mp3->xing_offset + 8, mp3->frames); AV_WB32(mp3->xing_frame + mp3->xing_offset + 12, mp3->size);