1

How do I get an mp3 output without any distortion using ffmpeg?

I am utilizing ffmpeg on AWS Lambda linux using the static build provided by https://www.johnvansickle.com/ffmpeg/ (x86_64 build).

After running the following command, the mp3 output has terrible clipping/distortion.

ffmpeg -loglevel verbose -ss 0 -t 30 -y -i /tmp/ick_20180323005225.wav -codec:a libmp3lame -qscale:a 7 /tmp/ick_20180323005225-opa.mp3

Edit: here is the sample file that I used:

http://www.brainybetty.com/FacebookFans/Feb112010/strings.wav

Here is the log coming from Lambda:

Executing command '/tmp/ffmpeg -loglevel verbose -ss 0 -t 30 -y -i /tmp/ick_20180323005225.wav -codec:a libmp3lame -qscale:a 7 /tmp/ick_20180323005225-opa.mp3' ...
STDERR:
ffmpeg version 3.4.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enab
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[wav @ 0x4bbdf40] parser not found for codec pcm_s16le, packets or times may be invalid.
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from '/tmp/ick_20180323005225.wav':
Duration: 00:00:05.00, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[graph_0_in_0_0 @ 0x4bc64e0] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[format_out_0_0 @ 0x4bc6360] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[auto_resampler_0 @ 0x4bd2ee0] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2 chl:stereo fmt:s16p r:44100Hz
Output #0, mp3, to '/tmp/ick_20180323005225-opa.mp3':
Metadata:
TSSE : Lavf57.83.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, delay 1105
Metadata:
encoder : Lavc57.107.100 libmp3lame
size= 11kB time=00:00:00.73 bitrate= 119.5kbits/s speed=1.41x
size= 23kB time=00:00:01.67 bitrate= 114.5kbits/s speed=1.61x
size= 36kB time=00:00:02.61 bitrate= 113.4kbits/s speed=1.65x
size= 48kB time=00:00:03.55 bitrate= 111.0kbits/s speed=1.69x
size= 60kB time=00:00:04.46 bitrate= 109.6kbits/s speed=1.71x
No more output streams to write to, finishing.
size= 67kB time=00:00:05.01 bitrate= 108.9kbits/s speed=1.75x
video:0kB audio:66kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.371917%
Input file #0 (/tmp/ick_20180323005225.wav):
Input stream #0:0 (audio): 216 packets read (881988 bytes); 216 frames decoded (220497 samples);
Total: 216 packets (881988 bytes) demuxed
Output file #0 (/tmp/ick_20180323005225-opa.mp3):
Output stream #0:0 (audio): 192 frames encoded (220497 samples); 193 packets muxed (68026 bytes);
Total: 193 packets (68026 bytes) muxed
Executed command '/tmp/ffmpeg -loglevel verbose -ss 0 -t 30 -y -i /tmp/ick_20180323005225.wav -codec:a libmp3lame -qscale:a 7 /tmp/ick_20180323005225-opa.mp3' with code: 0.
Eric Amshukov
  • 223
  • 3
  • 9
  • How does it work when you run it outside of a Lambda? – stdunbar Mar 23 '18 at 01:24
  • 1
    Provide the input file so we can attempt to duplicate the issue. – llogan Mar 23 '18 at 02:53
  • Thanks for replying, I have added the sample file. – Eric Amshukov Mar 23 '18 at 15:50
  • I hear no problems using the same `ffmpeg` build as you. What are you using to play the output file? Does `lame` also create a bad output? – llogan Mar 23 '18 at 17:22
  • I used iTunes to play back the mp3, but also heard the same issue on Window media player. I'm wonderinh, did you test to see if it worked on a Lambda instance? It works when I run a ffmpeg for Mac, but not the static build on Lambda – Eric Amshukov Mar 23 '18 at 17:39
  • No, I don't have access to a Lambda instance. Trying `lame` could rule out any issue with `ffmpeg`. (If you use @LordNeckbeard I'll get a notification of your replies.) – llogan Mar 23 '18 at 18:32

0 Answers0