简体   繁体   English

如何使用 FFMPEG 全长将 AAC/MP4A 转换为 MP3? 音频文件在 1 秒后被切断

[英]How to convert AAC/MP4A to MP3 using FFMPEG in full length? Audio file gets cut off after 1 second

I have recorded an audio file with MediaRecorder on iPhone.我在 iPhone 上用 MediaRecorder 录制了一个音频文件。 Here is a copy of an example:https://github.com/q2apro/shared/blob/main/18380889311644327118 (click on download)这是一个示例的副本:https://github.com/q2apro/shared/blob/main/18380889311644327118 (点击下载)

As ffmpeg command I am using:作为 ffmpeg 命令,我正在使用:

ffmpeg -i 18380889311644327118 -ar 44100 -ac 2 -b:a 128k -c:a libmp3lame -q:a 0 18380889311644327118.mp3
-i specifies the input file
-vn disables all video-streams from the input
-ar audio sampling frequency
-ac number of audio channels
-b:a bit rate
-c:a libmp3lame - codec of target file
-q:a quality set audio quality (codec-specific) (lower is better), see https://superuser.com/a/1515841

-sn disables all subtitle-streams from the input
-dn disables all data-streams from the input

The console output looks like this:控制台 output 如下所示:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '18380889311644327118':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2021-12-08T15:44:06.000000Z
  Duration: 00:00:01.00, start: 0.000000, bitrate: 2258 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 2234 kb/s (default)
    Metadata:
      creation_time   : 2021-12-08T15:44:06.000000Z
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))

Output #0, mp3, to '18380889311644327118.mp3':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    TSSE            : Lavf58.29.100
    Stream #0:0(und): Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2021-12-08T15:44:06.000000Z
      handler_name    : Core Media Audio
      encoder         : Lavc58.54.100 libmp3lame
size=      17kB time=00:00:01.01 bitrate= 135.5kbits/s speed=37.2x
video:0kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.343701%

As you can see, the duration is 01.00 second.如您所见,持续时间为01.00秒。 And this happens with all recorded files.所有录制的文件都会发生这种情况。

How to convert the entire file (which is 12 seconds long) to its full length?如何将整个文件(12 秒长)转换为全长?



Note: It seems that the recorded file does not have a length specified.注意:录制的文件似乎没有指定长度。 Under Windows I renamed the file, adding an extension ".m4a" and opened the file properties:在 Windows 我重命名文件,添加扩展名“.m4a”并打开文件属性:

m4a 属性

The length attribute is empty.长度属性为空。

As Gyan wrote, the conversion works with ffmpeg v4.4 which does not come with the recent Ubuntu update.正如Gyan所写,该转换适用于ffmpeg v4.4 ,该版本未随最近的 Ubuntu 更新一起提供。

However, you can install it customly, see instructions here:但是,您可以自定义安装它,请参阅此处的说明:

Safest way to install latest stable ffmpeg (>= 4.3) on Ubuntu 20.04 (ppa not working)?在 Ubuntu 20.04 上安装最新稳定 ffmpeg (>= 4.3) 的最安全方法(ppa 不工作)?

Then the conversion from audio/mp4 (codec AAC) to mp3 works.然后从audio/mp4 (编解码器 AAC)到mp3的转换工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM