When I append a silent audio (mp3) to an existing list of audio it garbles the final audio?

一个人想着一个人 提交于 2020-02-08 10:38:09

问题


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)

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

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%

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   
========================  

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

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

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.

Additional Hints Debugging:

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

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.

Thank you.


回答1:


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

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

The parameters above are:

  • sample rate (24000 Hz)
  • channel layout (mono)
  • sample format (fltp)
  • bitrate (32 kb/s)

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.

Example command:

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


来源:https://stackoverflow.com/questions/60089210/when-i-append-a-silent-audio-mp3-to-an-existing-list-of-audio-it-garbles-the-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!