Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8886 closed defect (invalid)

ID3 headers in segmented mp3 files despite -id3v2_version 0

Reported by: thefsb Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mp3 segment id3v2
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

(I prepared the examples here with 3.2.14 in my dev env but I see the same behavior with 4.3.1)

I am trying to save the mp3 data from an shout/icecast-type stream to segmented MP3 files.
I want each MP3 file to have no ID3, XING or other metadata header blocks so that it
would be possible to concatenate a sub-sequence of them to produce a valid mp3 file/stream.

The ffmpeg mp3 muxer docs http://ffmpeg.org/ffmpeg-all.html#mp3 says,
"Setting id3v2_version to 0 disables the ID3v2 header completely." and has an example:

Write a "clean" MP3 without any extra features:

ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3

But I find an ID3 block at the beginning of every segment output file.

--------------------------------------------------------------------------------------------------------

% ffmpeg -v 9 -loglevel 99 \
> -multiple_requests 1 \
> -reconnect_at_eof 1 \
> -reconnect_streamed 1 \
> -reconnect_delay_max 60 \
> -icy 0 \
> -i http://107.182.231.73:7170/ \
> -map 0:a \
> -c copy \
> -map_metadata -1 \
> -write_xing 0 \
> -id3v2_version 0 \
> -write_id3v1 0 \
> -f segment \
> -segment_time 60 \
> -segment_atclocktime 1 \
> -segment_clocktime_wrap_duration 1 \
> -strftime 1 \
> ./FOO-%G%m%dT%H%M%SZ.mp3
ffmpeg version 3.2.14-1~deb9u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.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 '-multiple_requests' ... matched as AVOption 'multiple_requests' with argument '1'.
Reading option '-reconnect_at_eof' ... matched as AVOption 'reconnect_at_eof' with argument '1'.
Reading option '-reconnect_streamed' ... matched as AVOption 'reconnect_streamed' with argument '1'.
Reading option '-reconnect_delay_max' ... matched as AVOption 'reconnect_delay_max' with argument '60'.
Reading option '-icy' ... matched as AVOption 'icy' with argument '0'.
Reading option '-i' ... matched as input url with argument 'http://107.182.231.73:7170/'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:a'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map_metadata' ... matched as option 'map_metadata' (set metadata information of outfile from infile) with argument '-1'.       
Reading option '-write_xing' ... matched as AVOption 'write_xing' with argument '0'.
Reading option '-id3v2_version' ... matched as AVOption 'id3v2_version' with argument '0'.
Reading option '-write_id3v1' ... matched as AVOption 'write_id3v1' with argument '0'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'segment'.
Reading option '-segment_time' ... matched as AVOption 'segment_time' with argument '60'.
Reading option '-segment_atclocktime' ... matched as AVOption 'segment_atclocktime' with argument '1'.
Reading option '-segment_clocktime_wrap_duration' ... matched as AVOption 'segment_clocktime_wrap_duration' with argument '1'.
Reading option '-strftime' ... matched as AVOption 'strftime' with argument '1'.
Reading option './FOO-%G%m%dT%H%M%SZ.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 http://107.182.231.73:7170/.
Successfully parsed a group of options.
Opening an input file: http://107.182.231.73:7170/.
[NULL @ 0x7fffe09b1100] Opening 'http://107.182.231.73:7170/' for reading
[http @ 0x7fffe09b1a00] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x7fffe09b1a00] request: GET / HTTP/1.1
User-Agent: Lavf/57.56.101
Accept: */*
Range: bytes=0-
Connection: keep-alive
Host: 107.182.231.73:7170


[http @ 0x7fffe09b1a00] header='HTTP/1.0 200 OK'
[http @ 0x7fffe09b1a00] http_code=200
[http @ 0x7fffe09b1a00] header='icy-notice1:<BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>'
[http @ 0x7fffe09b1a00] header='icy-notice2:SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>'
[http @ 0x7fffe09b1a00] header='Accept-Ranges:none'
[http @ 0x7fffe09b1a00] header='Access-Control-Allow-Origin:*'
[http @ 0x7fffe09b1a00] header='Cache-Control:no-cache,no-store,must-revalidate,max-age=0'
[http @ 0x7fffe09b1a00] header='Connection:close'
[http @ 0x7fffe09b1a00] header='icy-name:WNMC :: Traverse City'
[http @ 0x7fffe09b1a00] header='icy-genre:Eclectic'
[http @ 0x7fffe09b1a00] header='icy-br:192'
[http @ 0x7fffe09b1a00] header='icy-sr:44100'
[http @ 0x7fffe09b1a00] header='icy-url:http://www.wnmc.org/'
[http @ 0x7fffe09b1a00] header='icy-pub:1'
[http @ 0x7fffe09b1a00] header='content-type:audio/mpeg'
[http @ 0x7fffe09b1a00] header='X-Clacks-Overhead:GNU Terry Pratchett'
[http @ 0x7fffe09b1a00] header=''
Probing mp3 score:25 size:2048
Probing mp3 score:51 size:4096
[mp3 @ 0x7fffe09b1100] Format mp3 probed with size=4096 and score=51
[mp3 @ 0x7fffe09b1100] Skipping 0 bytes of junk at 0.
[mp3 @ 0x7fffe09b1100] Before avformat_find_stream_info() pos: 0 bytes read:25746 seeks:0 nb_streams:1
[mp3 @ 0x7fffe09b1100] All info found
[mp3 @ 0x7fffe09b1100] stream 0: start_time: 0.000 duration: -653583619391.637
[mp3 @ 0x7fffe09b1100] format: start_time: 0.000 duration: -9223372036854.775 bitrate=192 kb/s
[mp3 @ 0x7fffe09b1100] After avformat_find_stream_info() pos: 31744 bytes read:34524 seeks:0 frames:50
Input #0, mp3, from 'http://107.182.231.73:7170/':
  Metadata:
    icy-notice1     : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
    icy-notice2     : SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
    icy-name        : WNMC :: Traverse City
    icy-genre       : Eclectic
    icy-br          : 192
    icy-sr          : 44100
    icy-url         : http://www.wnmc.org/
    icy-pub         : 1
  Duration: N/A, start: 0.000000, bitrate: 192 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
Successfully opened the file.
Parsing a group of options: output url ./FOO-%G%m%dT%H%M%SZ.mp3.
Applying option map (set input stream mapping) with argument 0:a.
Applying option c (codec name) with argument copy.
Applying option map_metadata (set metadata information of outfile from infile) with argument -1.
Applying option f (force format) with argument segment.
Successfully parsed a group of options.
Opening an output file: ./FOO-%G%m%dT%H%M%SZ.mp3.
Successfully opened the file.
[segment @ 0x7fffe09b5b20] Selected stream id:0 type:audio
[segment @ 0x7fffe09b5b20] Opening './FOO-20200906T161345Z.mp3' for writing
[file @ 0x7fffe09b6d60] Setting default whitelist 'file,crypto'
Output #0, segment, to './FOO-%G%m%dT%H%M%SZ.mp3':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0, 0, 1/14112000: Audio: mp3, 44100 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[segment @ 0x7fffe09b5b20] segment:'./FOO-20200906T161345Z.mp3' starts with packet stream:0 pts:0 pts_time:0 frame:0
[segment @ 0x7fffe09b5b20] stream:0 start_pts_time:0 pts:0 pts_time:0 dts:0 dts_time:0 -> pts:0 pts_time:0 dts:0 dts_time:0
[segment @ 0x7fffe09b5b20] stream:0 start_pts_time:0 pts:368640 pts_time:0.0261224 dts:368640 dts_time:0.0261224 -> pts:368640 pts_time:0.0261224 dts:368640 dts_time:0.0261224

--------------------------------------------------------------------------------------------------------

% ffprobe -hide_banner -report -i FOO-20200906T161600Z.mp3
ffprobe started on 2020-09-06 at 16:24:21
Report written to "ffprobe-20200906-162421.log"
Input #0, mp3, from 'FOO-20200906T161600Z.mp3':
  Metadata:
    encoder         : Lavf57.56.101
  Duration: 00:00:29.34, start: 0.011995, bitrate: 192 kb/s  
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
    Metadata:
      encoder         : Lavf

--------------------------------------------------------------------------------------------------------

% cat ffprobe-20200906-162421.log
ffprobe started on 2020-09-06 at 16:24:21
Report written to "ffprobe-20200906-162421.log"
Command line:
ffprobe -hide_banner -report -i FOO-20200906T161600Z.mp3
[NULL @ 0x7fffea820420] Opening 'FOO-20200906T161600Z.mp3' for reading
[file @ 0x7fffea820ba0] Setting default whitelist 'file,crypto'
[mp3 @ 0x7fffea820420] Format mp3 probed with size=4096 and score=51
[mp3 @ 0x7fffea820420] id3v2 ver:4 flags:00 len:35
[mp3 @ 0x7fffea820420] pad 0 0
[mp3 @ 0x7fffea820420] Skipping 0 bytes of junk at 671.
[mp3 @ 0x7fffea820420] Before avformat_find_stream_info() pos: 671 bytes read:32768 seeks:0 nb_streams:1
[mp3 @ 0x7fffea820420] demuxer injecting skip 529 / discard 0
[mp3 @ 0x7fffea8218a0] skip 529 / discard 0 samples due to side data
[mp3 @ 0x7fffea8218a0] skip 529/1152 samples
[mp3 @ 0x7fffea820420] All info found
[mp3 @ 0x7fffea820420] After avformat_find_stream_info() pos: 32415 bytes read:32768 seeks:0 frames:50
Input #0, mp3, from 'FOO-20200906T161600Z.mp3':
  Metadata:
    encoder         : Lavf57.56.101
  Duration: 00:00:29.34, start: 0.011995, bitrate: 192 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
    Metadata:
      encoder         : Lavf
[AVIOContext @ 0x7fffea828f40] Statistics: 32768 bytes read, 0 seeks

--------------------------------------------------------------------------------------------------------

% xxd FOO-20200906T161600Z.mp3 | head -n 20 
00000000: 4944 3304 0000 0000 0023 5453 5345 0000  ID3......#TSSE..
00000010: 000f 0000 034c 6176 6635 372e 3536 2e31  .....Lavf57.56.1
00000020: 3031 0000 0000 0000 0000 0000 00ff fbb0  01..............
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0049 6e66 6f00 0000 0f00 0004 6300 0ac0  .Info.......c...
00000060: a600 0205 080b 0d0f 1215 171a 1c1f 2124  ..............!$
00000070: 2729 2b2e 3134 3538 3b3e 4042 4548 4a4d  ')+.1458;>@BEHJM
00000080: 4f52 5457 5a5c 5e61 6467 686b 6e71 7375  ORTWZ\^adghknqsu
00000090: 787b 7d80 8285 878a 8d8f 9194 979a 9c9e  x{}.............
000000a0: a1a4 a6a8 abae b0b3 b5b8 babd c0c2 c5c7  ................
000000b0: cacd cfd1 d4d7 d9db dee1 e3e6 e8eb eef0  ................
000000c0: f3f5 f8fa fd00 0000 004c 6176 6600 0000  .........Lavf...
000000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000e0: 0000 0000 0000 0ac0 a6b6 4b32 5d00 0000  ..........K2]...
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000100: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000110: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000120: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................

Change History (3)

comment:1 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavformat
Reproduced by developer: set
Version: 3.2.13git-master

For future tickets: Please remember that only current FFmpeg git head is supported on this bug tracker.

comment:2 by mkver, 4 years ago

Resolution: invalid
Status: newclosed

When using the segment muxer the options for the child muxer need to be specified via the segment_format_options option.

Btw: Setting the segment muxer's individual_header_trailer option to zero might be even better for you.

Last edited 4 years ago by mkver (previous) (diff)

comment:3 by thefsb, 4 years ago

Thank you!

Note: See TracTickets for help on using tickets.