当我在现有的音频列表中添加无声音频(mp3)时,最终音频会乱码吗? [英] When I append a silent audio (mp3) to an existing list of audio it garbles the final audio?

查看:120
本文介绍了当我在现有的音频列表中添加无声音频(mp3)时,最终音频会乱码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个小时后,我将出现乱码的问题缩小为我要添加的2秒静音音频mp3(我想我是用Wavelab制作的)

After several hours I have narrowed down the issue with the garbled audio to be the 2-seconds silence audio mp3 I am appending (I think I had produced it once with Wavelab)

但是,我尝试根据帖子使用ffmpeg来产生类似的2秒音频,但是在最终的音频文件连接中,它也会破坏/乱码/斩断声音.

However, I tried using ffmpeg according to a post to produce a similar 2 seconds audio but it too will corrupt/garble/chop voice in the final concatenation of audio files.

ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t 2 -q:a 9 -acodec libmp3lame SILENCE_2sec.MP3

通常,我将有多个音频文件串联在一起,但为简单起见,我能够将其缩小为几个文件,从而简化为以下脚本.一个简单的Windows批处理文件,您应该可以在最后使用和重现该问题.

I typically will have several audio files to concatenate together but for simplicity I have able to narrow it to a couple of files simplifying to the following script. A simple Windows batch file you should be able to use and reproduce the issue at your end.

rem 
rem  
SET EXE="S:\_BINS\FFmpeg 4.2.1 20200112\bin\ffmpeg.exe"

SET ROOTPATH=.\

SET IN_FILE="%ROOTPATH%MyList.txt"

ECHO file '%ROOTPATH%HELLO.mp3' > MyList.txt
ECHO file 'SILENCE_2sec.MP3' >> MyList.txt

SET OPTIONS= -f concat -safe 0 -i  %IN_FILE%  -c copy -y

SET OUT_FILE="%ROOTPATH%CONCATENATED_AUDIO_2.MP3"

SET INFO_FILE="INFO.TXT"

%EXE% %OPTIONS%  %OUT_FILE% 1> %INFO_FILE% 2>&1 

ECHO ======================== >> %INFO_FILE%
ECHO IN_FILE=%IN_FILE%  >> %INFO_FILE% 
ECHO EXE=%EXE%  >> %INFO_FILE% 
ECHO OPTIONS=%OPTIONS%  >> %INFO_FILE% 
ECHO ======================== >> %INFO_FILE%

这是ffmpeg的控制台信息输出,如果您需要其他输出,包括ffprobe的输出,请告诉我

Here is the console info output from the ffmpeg, let me know if you need other output include ones from ffprobe

ffmpeg version git-2020-01-10-3d894db Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 70.101 /  7. 70.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mp3 @ 000000000036af80] Estimating duration from bitrate, this may be inaccurate
Input #0, concat, from '.\MyList.txt':
  Duration: N/A, start: 0.000000, bitrate: 32 kb/s
    Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s
Output #0, mp3, to '.\CONCATENATED_AUDIO_2.MP3':
  Metadata:
    TSSE            : Lavf58.35.101
    Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp3 @ 0000000000372d00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 17280 >= 17255
size=      11kB time=00:00:02.73 bitrate=  33.2kbits/s speed=2.73e+03x    
video:0kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.137446%
======================== 
IN_FILE=".\MyList.txt"   
EXE="S:\_BINS\FFmpeg 4.2.1 20200112\bin\ffmpeg.exe"   
OPTIONS= -f concat -safe 0 -i  ".\MyList.txt"  -c copy -y   
========================  

我相信我正在运行FFmpeg 4.2.1,最近安装了(20200112)

I believe I am running FFmpeg 4.2.1, recently installed (20200112)

您可以通过保存以下链接来制作HELLO.mp3

You may produce the HELLO.mp3 by saving the following link

https://translate.google.com.vn/translate_tts?en=UTF-8&q=Hello+&tl=en&client=tw-ob

仅供参考,我仍然是ffmpeg的新手,在这个超级论坛上得到的帮助下,它更像是黑匣子.
请使用命令行选项尽可能明确地说明如何解决此问题. 谢谢.

FYI, I am still a novice of ffmpeg and using it more like a black box with the help I received in this very super forum.
Please be as explicit as you can with command line options on how I can fix this issue. Thank you.

其他提示调试:

如果我在无声音频之后添加更多文件,则似乎无声音频会影响(乱码,斩断)先前的音频. 您可以尝试以下输入音频文件的列表.

If I append more files after the silence audio it seems that the silence audio impacts (garbles, chops) the previous audio. You may try the following for the list of audio files input.

ECHO file '%ROOTPATH%HELLO.mp3' > MyList.txt
ECHO file 'SILENCE_2sec.MP3' >> MyList.txt
ECHO file '%ROOTPATH%HELLO.mp3' >> MyList.txt
ECHO file '%ROOTPATH%HELLO.mp3' >> MyList.txt

我通常添加一个或多个静音文件,以在实际音频之后获得后静音效果.那就是我目前的逻辑.但是,如果您可以选择在连接多个音频文件的过程中添加静默或将x秒静默添加到现有音频文件中,则可以选择其他方法.我也可以从编码中使用该方法.

I typically add one or more silence file to derive a post silence effect after the actual audio. That's my current logic. However if you have an alternative to appending a silence in the process of concatenating several audio files or appending x-seconds silence to an existing audio file. I can use that method as well from my coding.

谢谢.

推荐答案

无声音频需要与主音频的参数匹配:

The silent audio needs to match the parameters of the main audio:

Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s

上面的参数是:

  • 采样率(24000 Hz)
  • 渠道布局(单声道)
  • 样本格式(fltp)
  • 比特率(32 kb/s)
  • sample rate (24000 Hz)
  • channel layout (mono)
  • sample format (fltp)
  • bitrate (32 kb/s)

重要参数是采样率频道布局.在 anullsrc过滤器中,您可以使用r/sample_rate进行设置cl/channel_layout选项,如ffmpeg -h filter=anullsrc所示.

The important parameters are sample rate and channel layout. In the anullsrc filter you can set these with the r/sample_rate and cl/channel_layout options as shown in ffmpeg -h filter=anullsrc.

示例命令:

ffmpeg -f lavfi -i anullsrc=r=24000:cl=mono -t 2 -b:a 32k -c:a libmp3lame SILENCE_2sec.MP3

这篇关于当我在现有的音频列表中添加无声音频(mp3)时,最终音频会乱码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆