Opened 23 months ago

#9824 new defect

Trimming mp3 using start time+copy makes audio stutter in VLC

Reported by: undone Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I was trying to remove the first couple of seconds of an mp3-file using ffmpeg without re-encoding the audio when I noticed it will start stuttering on playback in VLC.

This could be an issue in VLC too, but I can't find a way to trim mp3-audio (using copy) that doesn't create this issue when playback in VLC.

  • It doesn't happen when the mp3-file is encoded by ffmpeg / lame.
  • It also happens when setting the starttime to 00:00:00.000 (as long as it's not before -i).

Video example: https://undone.se/misc/chirp_vlc_video.mp4

How to reproduce:

ffmpeg -i chirp.wav -codec:a libmp3lame -qscale:a 0 chirp_ffmpeg_1.mp3
ffmpeg -i chirp_ffmpeg_1.mp3 -ss 00:00:00.000 -codec:a copy chirp_ffmpeg_2.mp3

Wav-file: https://undone.se/misc/chirp.wav (source material doesn't seem to matter)

ffmpeg was built today (2022-07-07). VLC is VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2) with default configuration (playlist view enabled in video)

Console output:

$ ffmpeg -v 9 -loglevel 99 -i chirp.wav -codec:a libmp3lame -qscale:a 0 chirp_ffmpeg_1.mp3
ffmpeg version N-107317-g85bc6b5abf Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/home/undone/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/undone/ffmpeg_build/include --extra-ldflags=-L/home/undone/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/undone/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse
  libavutil      57. 27.100 / 57. 27.100
  libavcodec     59. 36.100 / 59. 36.100
  libavformat    59. 26.100 / 59. 26.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 41.100 /  8. 41.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input url with argument 'chirp.wav'.
Reading option '-codec:a' ... matched as option 'codec' (codec name) with argument 'libmp3lame'.
Reading option '-qscale:a' ... matched as option 'qscale' (use fixed quality scale (VBR)) with argument '0'.
Reading option 'chirp_ffmpeg_1.mp3' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url chirp.wav.
Successfully parsed a group of options.
Opening an input file: chirp.wav.
[NULL @ 0x556051683800] Opening 'chirp.wav' for reading
[file @ 0x556051683fc0] Setting default whitelist 'file,crypto,data'
Probing wav score:99 size:2048
[wav @ 0x556051683800] Format wav probed with size=2048 and score=99
[wav @ 0x556051683800] Before avformat_find_stream_info() pos: 44 bytes read:65580 seeks:1 nb_streams:1
[wav @ 0x556051683800] probing stream 0 pp:32
[wav @ 0x556051683800] probing stream 0 pp:31
[wav @ 0x556051683800] probing stream 0 pp:30
[wav @ 0x556051683800] probing stream 0 pp:29
[wav @ 0x556051683800] probing stream 0 pp:28
[wav @ 0x556051683800] probing stream 0 pp:27
[wav @ 0x556051683800] probing stream 0 pp:26
[wav @ 0x556051683800] probing stream 0 pp:25
[wav @ 0x556051683800] probing stream 0 pp:24
[wav @ 0x556051683800] probing stream 0 pp:23
[wav @ 0x556051683800] probing stream 0 pp:22
[wav @ 0x556051683800] probing stream 0 pp:21
[wav @ 0x556051683800] probing stream 0 pp:20
[wav @ 0x556051683800] probing stream 0 pp:19
[wav @ 0x556051683800] probing stream 0 pp:18
[wav @ 0x556051683800] probing stream 0 pp:17
[wav @ 0x556051683800] probing stream 0 pp:16
[wav @ 0x556051683800] probing stream 0 pp:15
[wav @ 0x556051683800] probing stream 0 pp:14
[wav @ 0x556051683800] probing stream 0 pp:13
[wav @ 0x556051683800] probing stream 0 pp:12
[wav @ 0x556051683800] probing stream 0 pp:11
[wav @ 0x556051683800] probing stream 0 pp:10
[wav @ 0x556051683800] probing stream 0 pp:9
[wav @ 0x556051683800] probing stream 0 pp:8
[wav @ 0x556051683800] probing stream 0 pp:7
[wav @ 0x556051683800] probing stream 0 pp:6
[wav @ 0x556051683800] probing stream 0 pp:5
[wav @ 0x556051683800] probing stream 0 pp:4
[wav @ 0x556051683800] probing stream 0 pp:3
[wav @ 0x556051683800] probing stream 0 pp:2
[wav @ 0x556051683800] probing stream 0 pp:1
[wav @ 0x556051683800] probed stream 0
[wav @ 0x556051683800] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav @ 0x556051683800] All info found
[wav @ 0x556051683800] stream 0: start_time: NOPTS duration: 3
[wav @ 0x556051683800] format: start_time: NOPTS duration: 3 (estimate from stream) bitrate=705 kb/s
[wav @ 0x556051683800] After avformat_find_stream_info() pos: 204844 bytes read:294956 seeks:1 frames:50
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'chirp.wav':
  Duration: 00:00:03.00, bitrate: 705 kb/s
  Stream #0:0, 50, 1/44100: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Successfully opened the file.
Parsing a group of options: output url chirp_ffmpeg_1.mp3.
Applying option codec:a (codec name) with argument libmp3lame.
Applying option qscale:a (use fixed quality scale (VBR)) with argument 0.
Successfully parsed a group of options.
Opening an output file: chirp_ffmpeg_1.mp3.
[file @ 0x5560516ce780] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
detected 8 logical cores
[graph_0_in_0_0 @ 0x5560516d1c80] Setting 'time_base' to value '1/44100'
[graph_0_in_0_0 @ 0x5560516d1c80] Setting 'sample_rate' to value '44100'
[graph_0_in_0_0 @ 0x5560516d1c80] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_0 @ 0x5560516d1c80] Setting 'channel_layout' to value 'mono'
[graph_0_in_0_0 @ 0x5560516d1c80] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:mono
[format_out_0_0 @ 0x5560516d2e40] Setting 'sample_fmts' to value 's32p|fltp|s16p'
[format_out_0_0 @ 0x5560516d2e40] Setting 'sample_rates' to value '44100|48000|32000|22050|24000|16000|11025|12000|8000'
[format_out_0_0 @ 0x5560516d2e40] Setting 'channel_layouts' to value 'mono|stereo'
[format_out_0_0 @ 0x5560516d2e40] auto-inserting filter 'auto_aresample_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[AVFilterGraph @ 0x5560516978c0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_aresample_0 @ 0x5560516d4800] picking s16p out of 3 ref:s16
[auto_aresample_0 @ 0x5560516d4800] [SWR @ 0x5560516d4980] Using s16p internally between filters
[auto_aresample_0 @ 0x5560516d4800] ch:1 chl:mono fmt:s16 r:44100Hz -> ch:1 chl:mono fmt:s16p r:44100Hz
Output #0, mp3, to 'chirp_ffmpeg_1.mp3':
  Metadata:
    TSSE            : Lavf59.26.100
  Stream #0:0, 0, 1/44100: Audio: mp3, 44100 Hz, mono, s16p, delay 1105
    Metadata:
      encoder         : Lavc59.36.100 libmp3lame
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[out_0_0 @ 0x5560516d2a80] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
[libmp3lame @ 0x5560516cd3c0] Trying to remove 227 more samples than there are in the queue
size=      37kB time=00:00:03.00 bitrate= 100.2kbits/s speed= 150x    
video:0kB audio:37kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.606903%
Input file #0 (chirp.wav):
  Input stream #0:0 (audio): 65 packets read (264600 bytes); 65 frames decoded (132300 samples); 
  Total: 65 packets (264600 bytes) demuxed
Output file #0 (chirp_ffmpeg_1.mp3):
  Output stream #0:0 (audio): 115 frames encoded (132300 samples); 116 packets muxed (37403 bytes); 
  Total: 116 packets (37403 bytes) muxed
[AVIOContext @ 0x5560516ceb00] Statistics: 37630 bytes written, 0 seeks, 1 writeouts
65 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x55605168c3c0] Statistics: 330180 bytes read, 1 seeks


$ ffmpeg -v 9 -loglevel 99 -i chirp_ffmpeg_1.mp3 -ss 00:00:00.000 -codec:a copy chirp_ffmpeg_2.mp3
ffmpeg version N-107317-g85bc6b5abf Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/home/undone/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/undone/ffmpeg_build/include --extra-ldflags=-L/home/undone/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/undone/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse
  libavutil      57. 27.100 / 57. 27.100
  libavcodec     59. 36.100 / 59. 36.100
  libavformat    59. 26.100 / 59. 26.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 41.100 /  8. 41.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input url with argument 'chirp_ffmpeg_1.mp3'.
Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '00:00:00.000'.
Reading option '-codec:a' ... matched as option 'codec' (codec name) with argument 'copy'.
Reading option 'chirp_ffmpeg_2.mp3' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url chirp_ffmpeg_1.mp3.
Successfully parsed a group of options.
Opening an input file: chirp_ffmpeg_1.mp3.
[NULL @ 0x55ec83eef800] Opening 'chirp_ffmpeg_1.mp3' for reading
[file @ 0x55ec83eeffc0] Setting default whitelist 'file,crypto,data'
Probing mp3 score:25 size:2003
Probing mp3 score:51 size:4051
[mp3 @ 0x55ec83eef800] Format mp3 probed with size=4096 and score=51
id3v2 ver:4 flags:00 len:35
[mp3 @ 0x55ec83eef800] pad 576 756
[mp3 @ 0x55ec83eef800] Skipping 0 bytes of junk at 227.
[mp3 @ 0x55ec83eef800] Before avformat_find_stream_info() pos: 227 bytes read:32768 seeks:0 nb_streams:1
[mp3 @ 0x55ec83eef800] demuxer injecting skip 1105 / discard 0
[mp3float @ 0x55ec83ef0f80] skip 1105 / discard 0 samples due to side data
[mp3float @ 0x55ec83ef0f80] skip 1105/1152 samples
[mp3 @ 0x55ec83eef800] All info found
[mp3 @ 0x55ec83eef800] stream 0: start_time: 0.0250567 duration: 3.0302
[mp3 @ 0x55ec83eef800] format: start_time: 0.025057 duration: 3.0302 (estimate from stream) bitrate=99 kb/s
[mp3 @ 0x55ec83eef800] After avformat_find_stream_info() pos: 17635 bytes read:32768 seeks:0 frames:50
Input #0, mp3, from 'chirp_ffmpeg_1.mp3':
  Metadata:
    encoder         : Lavf59.26.100
  Duration: 00:00:03.03, start: 0.025057, bitrate: 99 kb/s
  Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, mono, fltp, 99 kb/s
Successfully opened the file.
Parsing a group of options: output url chirp_ffmpeg_2.mp3.
Applying option ss (set the start time offset) with argument 00:00:00.000.
Applying option codec:a (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: chirp_ffmpeg_2.mp3.
[file @ 0x55ec83f02240] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Output #0, mp3, to 'chirp_ffmpeg_2.mp3':
  Metadata:
    TSSE            : Lavf59.26.100
  Stream #0:0, 0, 1/14112000: Audio: mp3, 44100 Hz, mono, fltp, 99 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[mp3 @ 0x55ec83eef800] demuxer injecting skip 0 / discard 227
No more output streams to write to, finishing.
size=      36kB time=00:00:03.00 bitrate=  98.3kbits/s speed=8.1e+03x    
video:0kB audio:36kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.978998%
Input file #0 (chirp_ffmpeg_1.mp3):
  Input stream #0:0 (audio): 116 packets read (37403 bytes); 
  Total: 116 packets (37403 bytes) demuxed
Output file #0 (chirp_ffmpeg_2.mp3):
  Output stream #0:0 (audio): 115 packets muxed (36568 bytes); 
  Total: 115 packets (36568 bytes) muxed
[AVIOContext @ 0x55ec83f02400] Statistics: 36926 bytes written, 0 seeks, 1 writeouts
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x55ec83ef83c0] Statistics: 37630 bytes read, 0 seeks

Change History (0)

Note: See TracTickets for help on using tickets.