Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 465744 - media-sound/mpg123 - mpg123_getformat() proceeds slowly on broken mp3 streams
Summary: media-sound/mpg123 - mpg123_getformat() proceeds slowly on broken mp3 streams
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo Sound Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-13 07:05 UTC by Paul Osmialowski
Modified: 2014-06-16 21:02 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
first 1000 KB of the movie file (stream.avi,1000.00 KB, application/octet-stream)
2014-06-05 17:01 UTC, Paul Osmialowski
Details
first 1000 KB of the dumped audio - this is not recognised as audio stream! (firstMB.dump,1000.00 KB, application/octet-stream)
2014-06-06 06:15 UTC, Paul Osmialowski
Details
second 1000 KB of the dumped audio - this contains something that you can actually hear (secondMB.dump,1000.00 KB, application/octet-stream)
2014-06-06 06:17 UTC, Paul Osmialowski
Details
patch to mpg123 1.20.0 (mpg123_forget_head_shift.patch,3.64 KB, patch)
2014-06-10 07:45 UTC, Thomas Orgis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Osmialowski 2013-04-13 07:05:23 UTC
After one of mpg123 updates my mplayer compiled with "mp3" USE flag started to hang while opening certain movie files from certain sources. Finally it turned out that it isn't hanging, it's slow on open, here's the whole story:
- last year I found regression: mplayer couldn't open (as I assumed wrongly) certain movies
- now after few months it became annoying enough to start my investigation of the problem
- I opened mplayer in gdb and right after it hung on opening one of affected movies, I killed it with SIGSEGV signal
- I looked at backtrace:
Program received signal SIGSEGV, Segmentation fault.
0xb74c2bb7 in ?? () from /usr/lib/libmpg123.so.0
(gdb) bt
#0  0xb74c2bb7 in ?? () from /usr/lib/libmpg123.so.0
#1  0xb74c2c6d in ?? () from /usr/lib/libmpg123.so.0
#2  0xb74c28d8 in ?? () from /usr/lib/libmpg123.so.0
#3  0xb74ba38b in ?? () from /usr/lib/libmpg123.so.0
#4  0xb74c615a in ?? () from /usr/lib/libmpg123.so.0
#5  0xb74c63ed in ?? () from /usr/lib/libmpg123.so.0
#6  0xb74c6949 in mpg123_getformat () from /usr/lib/libmpg123.so.0
#7  0x081d17ae in ?? ()
#8  0x081d17fd in ?? ()
#9  0x081d18dc in ?? ()
#10 0x080fe20c in ?? ()
#11 0x080fe622 in init_best_audio_codec ()
#12 0x08086345 in reinit_audio_chain ()
#13 0x08076b1d in main ()
- I googled on "mpg123_getformat()" and found this bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677148
- In the bug report it is stated that problem with this function was fixed in mpg123-1.14.3; Gentoo uses 1.14.4 and it still fails; I also unmasked mpg123-1.15.3 and it still suffers from the same bug
- In the thread it is stated that mpg123_getformat() function does not hang on broken mp3 streams, it's just working slowly; I waited patiently and I can confirm that, it takes 5 minutes for mplayer to open a movie with broken (poisoned with virus for windows?) audio stream, but then, it starts to play properly.
Comment 1 Thomas Orgis 2014-05-27 17:49:46 UTC
Hm, I'm undecided between "backtrace with debugging symbols or it didn't happen" or right away "sample file or it didn't happen". Can you extract the audio stream via -dumpaudio and confirm that plain mpg123 also is slow on it? Also current version (mind, that is 1.20.0, not 1.15 or such;-) would be nice. Finally, sending the extracted audio to me shouldn't be a problem (How large is the video? Is it very NSFW?) ... otherwise, a certain range, some dozen KiB from the beginning should be plenty for debugging.
Comment 2 Paul Osmialowski 2014-05-27 18:34:44 UTC
I'm on my vacations now, so I can't give you more specific details this week. The problem was with one particular full-time movie (a British commedy from the 80's - if it is still searchable, I can try to provide you with ed2k link - that's how I got it here). Thing is, I'm not using that 32-bit machine anymore as I've installed 64-bit Gentoo on something much faster, so this problem has no importance for me now.
Comment 3 Paul Osmialowski 2014-06-03 16:49:46 UTC
I copied this movie from my old 32-bit desktop and what I found is:
1. It's still slow on open, even on by brand new x86_64 desktop PC
2. It's the fresh Gentoo system whith following packages installed (among others):
[ebuild   R    ] media-video/ffmpeg-1.0.8  USE="X aac aacplus alsa amr bluray bzip2 cdio encode faac fdk fontconfig frei0r gnutls gsm hardcoded-tables iec61883 ieee1394 jack jpeg2k libass libcaca libv4l mmx modplug mp3 network openal openssl opus oss pic rtmp schroedinger sdl speex ssse3 theora threads truetype twolame v4l vaapi vdpau vorbis vpx x264 xvid zlib -3dnow -3dnowext (-altivec) -avx -bindist (-celt) -cpudetection -debug -doc -examples -flite -mmxext (-neon) -pulseaudio -static-libs {-test} (-vis)" FFTOOLS="aviocat cws2fws ffeval fourcc2pixfmt graph2dot ismindex pktdumper qt-faststart trasher" 0 kB
[ebuild   R    ] media-sound/mpg123-1.18.1  USE="alsa ipv6 jack oss portaudio sdl sse (-3dnow) (-3dnowext) (-altivec) (-coreaudio) -int-quality (-mmx) -nas -pulseaudio" ABI_X86="(64) (-32) (-x32)" 0 kB
[ebuild   R    ] media-video/mplayer-1.1.1-r1  USE="X a52 aalib alsa bidi bl bluray bs2b cdio cdparanoia dts dv dvb dvd dvdnav enca encode faac faad ftp ggi gif gsm iconv ipv6 jack joystick jpeg jpeg2k ladspa libass libcaca libmpeg2 lirc live lzo mad md5sum mmx mng mp3 network nut openal opengl osdmenu oss png pnm pvr quicktime radio rar rtc rtmp samba sdl shm speex sse sse2 ssse3 tga theora toolame tremor truetype twolame unicode v4l vdpau vorbis x264 xanim xinerama xscreensaver xv xvid xvmc -3dnow -3dnowext (-altivec) (-aqua) -bindist -cddb -cpudetection -debug -dga -directfb -doc -dxr3 -fbcon -mmxext -nas -pulseaudio (-selinux) (-vidix) -zoran" VIDEO_CARDS="-mga -s3virge -tdfx" 0 kB

(before you ask about it: I'm not using pulseaudio, it's Audigy - the real sound device with hardware mixer)

3. mplayer produces following output:

libavformat version 54.29.104 (external)
Wykryto format pliku AVI.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [DX50]  640x336  24bpp  25.000 fps  807.5 kbps (98.6 kbyte/s)
Informacje o klipie:
 Software: Nandub v1.0rc2
 Title: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Subject: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Artist: Mel Brooks
 Copyright: doctor_virgin (fileheaven.org * filenexus.com)
 Comments: 
Load subtitles in ./
[vdpau] Error when calling vdp_device_create_x11: 1
==========================================================================
Otwieram dekoder video: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.59.100 (external)
Unsupported PixelFormat 61
Unsupported PixelFormat 53
Unsupported PixelFormat 81
Wybrany kodek video: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Otwieram dekoder audio: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 48000 Hz, 2 ch, s16le, 32.0 kbit/2.08% (ratio: 4000->192000)
Wybrany kodek audio: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Odtwarzam...
[mpeg4 @ 0x7f7b8ef245c0]Invalid and inefficient vfw-avi packed B frames detected
Format filmu to 1.90:1 - zmieniam do poprawnego formatu filmu.
VO: [xv] 640x336 => 640x336 Planar YV12 

Then, after minutes it works as usual:

A: 427.0 V: 427.0 A-V:  0.000 ct: -0.056 10676/10676  1%  0%  0.2% 0 0

(sorry for Polish output, export LC_ALL=C did not help, mplayer still spits messages in Polish).
Comment 4 Thomas Orgis 2014-06-03 17:50:51 UTC
OK, there ist something reproducable. Can you confirm that it's still hanging in the audio part? Quickest test would be switching to another audio decoder:

mpg123 -ac ffmp3 ...

If that decodes normally, mpg123 or the mpg123 binding of MPlayer should be to blame (in both cases, the blame applying to myself, probably). I'd be very much interested in the audio part, extracted via mplayer -dumpaudio, for example. If the stand-alone mpg123 also hangs on this one, I can switftly debug and fix that. Probably.
Comment 5 Paul Osmialowski 2014-06-03 18:40:06 UTC
- mplayer -dumpaudio produced stream.dump a 99MB file in a blink of the eye (no waiting!), this stream.dump file can be played normally (again, with no waiting at all) by mplayer itself:

libavformat version 54.29.104 (external)
Wykryto format pliku libavformat.
[mp3 @ 0x7fbaed52b440]max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x7fbaed52b440]Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: audio (mp3), -aid 0
Load subtitles in ./
==========================================================================
Otwieram dekoder audio: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 48000 Hz, 2 ch, s16le, 32.0 kbit/2.08% (ratio: 4000->192000)
Wybrany kodek audio: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Wideo: brak obrazu
Position: 23 % (<=== I was walking through the file back and forth without any probolems)
A:1943.7 (32:23.6) of 8247.0 ( 2:17:27.0)  0.0%

Unfortunately, mpg123 command does not want to play such a file:

$ mpg123 stream.dump 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.18.1; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Playing MPEG stream 1 of 1: stream.dump ...

[/var/tmp/portage/media-sound/mpg123-1.18.1/work/mpg123-1.18.1/src/libmpg123/parse.c:1101] error: Giving up searching valid MPEG header after 65536 bytes of junk.

[0:01] Decoding of stream.dump finished.

- I checked in gdb that the problem inside of mplayer is still somewhere behind mpg123_getformat() function:

(gdb) bt
#0  0x00007f2a0a4a6eb3 in ?? () from /usr/lib64/libmpg123.so.0
#1  0x00007f2a0a4a6ef0 in ?? () from /usr/lib64/libmpg123.so.0
#2  0x00007f2a0a4a6bbc in ?? () from /usr/lib64/libmpg123.so.0
#3  0x00007f2a0a49f6dc in ?? () from /usr/lib64/libmpg123.so.0
#4  0x00007f2a0a4a9b32 in ?? () from /usr/lib64/libmpg123.so.0
#5  0x00007f2a0a4a9ced in ?? () from /usr/lib64/libmpg123.so.0
#6  0x00007f2a0a4aa32e in mpg123_getformat () from /usr/lib64/libmpg123.so.0
#7  0x000000000056573e in ?? ()
#8  0x000000000056578d in ?? ()
#9  0x000000000056586a in ?? ()
#10 0x000000000049c089 in ?? ()
#11 0x000000000049c4b8 in init_best_audio_codec ()
#12 0x0000000000443d0b in reinit_audio_chain ()
#13 0x00000000004356bf in main ()
(gdb)

- mpg123 -ac produces such an output:

$ mpg123 -ac To\ Be\ Or\ Not\ To\ Be\ \(Mel\ Brooks\,\ 1983\).avi 
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.surround71.0:CARD=0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.modem.0:CARD=0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=0,DEV=0
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.modem.0:CARD=0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=0,DEV=0
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.modem.0:CARD=0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM phoneline
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.Audigy.pcm.modem.0:CARD=0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM phoneline
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm_dmix.c:961:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.18.1; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Playing MPEG stream 1 of 1: To Be Or Not To Be (Mel Brooks, 1983).avi ...

Installed alsa-lib version is:

[ebuild   R    ] media-libs/alsa-lib-1.0.27.2  USE="alisp python -debug -doc" ABI_X86="(64) (-32) (-x32)" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 0 kB

No sound can be heard during that, and it quits after few minutes. I attached gdb to mpg123 pid and it seems to process the file:

(gdb) bt
#0  0x00007f21b7d17ddd in read () from /lib64/libc.so.6
#1  0x00007f21b84fcb0e in ?? () from /usr/lib64/libmpg123.so.0
#2  0x00007f21b84fcbbc in ?? () from /usr/lib64/libmpg123.so.0
#3  0x00007f21b84f5991 in ?? () from /usr/lib64/libmpg123.so.0
#4  0x00007f21b84ffb32 in ?? () from /usr/lib64/libmpg123.so.0
#5  0x00007f21b8500028 in mpg123_decode_frame () from /usr/lib64/libmpg123.so.0
#6  0x000000000040c8cc in ?? ()
#7  0x0000000000404ad1 in ?? ()
#8  0x00007f21b7c5cca5 in __libc_start_main () from /lib64/libc.so.6
#9  0x00000000004051b9 in ?? ()
(gdb)

I checked that mpg123 is able to play normal mp3 files as usual.
Comment 6 Thomas Orgis 2014-06-05 05:59:14 UTC
We got some confusion,  sorry. I was not meanting to write mpg123 -ac ffmp3 ... I meant

mplayer -ac ffmp3 <testfile.avi>

Perhaps you can send me a handful of MiB from the beginning of that video file per eMail. It's a bit confusing that the stream dump can be played normally in mplayer. With mpg123,  you can try this:

mpg123 --resync-limit -1 stream.dump

When MPlayer can play this, mpg123 should be able, too (MPlayer uses --resync-limit -1, effectively, AFAIR).
Comment 7 Paul Osmialowski 2014-06-05 17:01:44 UTC
Created attachment 378324 [details]
first 1000 KB of the movie file
Comment 8 Paul Osmialowski 2014-06-05 17:05:05 UTC
1. mplayer -ac ffmp3 <testfile.avi> - to my surprise, the movie (with soundtrack) started to play immediately:

libavformat version 54.29.104 (external)
Wykryto format pliku AVI.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [DX50]  640x336  24bpp  25.000 fps  807.5 kbps (98.6 kbyte/s)
Informacje o klipie:
 Software: Nandub v1.0rc2
 Title: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Subject: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Artist: Mel Brooks
 Copyright: doctor_virgin (fileheaven.org * filenexus.com)
 Comments: 
Load subtitles in ./
[vdpau] Error when calling vdp_device_create_x11: 1
==========================================================================
Otwieram dekoder video: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.59.100 (external)
Unsupported PixelFormat 61
Unsupported PixelFormat 53
Unsupported PixelFormat 81
Wybrany kodek video: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Wymuszam kodek audio: ffmp3
Otwieram dekoder audio: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, s16le, 126.9 kbit/8.26% (ratio: 15865->192000)
Wybrany kodek audio: [ffmp3] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Odtwarzam...
[mpeg4 @ 0x7f997defe5c0]Invalid and inefficient vfw-avi packed B frames detected
Format filmu to 1.90:1 - zmieniam do poprawnego formatu filmu.
VO: [xv] 640x336 => 640x336 Planar YV12 
A:  30.4 V:   3.9 A-V: 26.556 ct:  0.384  98/ 98  2%  0%  0.4% 0 0

2. mpg123 --resync-limit -1 stream.dump - the dumped soundtrack started to play immediately (!)
3. I took this file to my work where I have Ubuntu x86_64 - mplayer plays it immediately (!) but... ldd shows that Ubuntus mplayer is NOT linked against libmpg123. Note that Gentoos Ubuntu is linked against libmpg123:

$ ldd /usr/bin/mplayer|grep mpg123
	libmpg123.so.0 => /usr/lib64/libmpg123.so.0 (0x00007f592bf64000)

4. I took my old x86_64 laptop with Gentoo not upgraded for ages - mplayer opens this file immediately (!!!) .and. mplayer is linked against libmpg123:

$ ldd /usr/bin/mplayer|grep mpg123
        libmpg123.so.0 => /usr/lib64/libmpg123.so.0 (0x00007f4dc009f000)
Wykryto format pliku AVI.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [DX50]  640x336  24bpp  25.000 fps  807.5 kbps (98.6 kbyte/s)
Informacje o klipie:
 Software: Nandub v1.0rc2
 Title: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Subject: To.be.or.Not.to.be(1983)MBCD2000-fileheaven.org-DiVX5
 Artist: Mel Brooks
 Copyright: doctor_virgin (fileheaven.org * filenexus.com)
 Comments:
Load subtitles in ./
==========================================================================
Otwieram dekoder video: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 53.61.100 (external)
Unsupported PixelFormat 61
Unsupported PixelFormat 53
Unsupported PixelFormat 81
Wybrany kodek video: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Otwieram dekoder audio: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 48000 Hz, 2 ch, s16le, 32.0 kbit/2.08% (ratio: 4000->192000)
Wybrany kodek audio: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
Odtwarzam...
[mpeg4 @ 0x7fd121564ae0]Invalid and inefficient vfw-avi packed B frames detected
Format filmu to 1.90:1 - zmieniam do poprawnego formatu filmu.
A:  30.5 V:   3.9 A-V: 26.552 ct:  0.388  99/ 99  0%  0%  0.2% 0 0

Old packages are:
mpg123-1.13.2 (vs 1.18.1)
mplayer-1.1-r1 (vs 1.1.1-r1)
ffmpeg-0.10.3 (vs 1.0.8)

5. I used dd to get first 1000 KB of the file (the biggest binary chunk I can copy to Gentoo bugzilla). What I observed is:
- it takes aprox. 20 sec. to open on my new Gentoo machine (with newest software versions) - gdb shows it sticks in the same place then
- it opens immediately on my old x86_64 Gentoo machine (with old software versions)
- don't open it on Windows, who knows what binary nasties it contains
Comment 9 Thomas Orgis 2014-06-06 05:04:30 UTC
Eh ... this is somewhat mystical to me: Are you actually _hearing_ something with this beginning piece of video? I get a file consisting entirely of zeroes with -dumpaudio. When does the actual audio start?

$ mpg123  --resync-limit -1 stream.dump 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.20.0; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Playing MPEG stream 1 of 1: stream.dump ...
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 550860.
Note: Trying to resync...
Note: Hit end of (available) data during resync.

[0:01] Decoding of stream.dump finished.

But I also see that stand-alone mpg123 is a lot quicker than mplayer in hitting the end of data. So, I could still debug and optimize that ... but it would help to have some actual audio data :-/ Can you upload the first MiB of the whole stream.dump? Really, I cannot do too much with the audio I got from the first MiB of video:

$ hexdump -C stream.dump 
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000867d0

Raises an interesting question: How much playtime is a sequence of zeroes claiming to be MPEG data worth?
Comment 10 Paul Osmialowski 2014-06-06 06:15:16 UTC
Created attachment 378358 [details]
first 1000 KB of the dumped audio - this is not recognised as audio stream!
Comment 11 Paul Osmialowski 2014-06-06 06:17:06 UTC
Created attachment 378360 [details]
second 1000 KB of the dumped audio - this contains something that you can actually hear
Comment 12 Paul Osmialowski 2014-06-06 06:24:45 UTC
The audio track is silent for the first couple of seconds, so you're right, nothing can be heard from the first 1000 KB chunk that I sent at first.

Next two attachements are as follows:

- firstMB.dump - first megabyte of audio track, both mplayer and mpg123 (with --resync-limit -1) cannot recognise it as audio stream; I've found that it must be at least 2000 KB chunk to be recognised as audio stream and played as such (again, it is played immediately, without any waiting).
- secondMB.dump - I've also found that when I skip first 1000 KB, the next 1000 KB chunk is recognised as audio stream (both mplayer and mpg123) and you got something that you can actually hear.

The fact that whole audio dump can be played without waiting by bare mpg123 suggests me that there must be something wrong at the interface between mplayer and libmpg123 - nasty media stream can fool it and cause side effects - e.g. slow audio stream headers analysis by mpg123_getformat() function.
Comment 13 Thomas Orgis 2014-06-06 06:39:34 UTC
OK, so some brigth soul wanted to introduce an audio shift, inserting silence by prepending zero bytes. Too bad that this is not silence in MPEG audio terms. This is an invalid stream. So, with over a MB of plain zeroes, you cannot mpg123 to initially think that this is no MPEG audio (without the --resync-limit -1 setting).

Concatenating the two pieces to have 2000 KiB of audio date, I don't see much difference between mplayer or mpg123 --resync-limit -1. So the especially nastily slow scanning of the data only occurs in the original muxed video form.

Perhaps you can send me the first 3 minutes of the video per mail. Then I can debug the mpg123 codec inside mplayer. But, well, I presume the fix would be trying less hard to find valid data. My code does goes through the stream in one-byte steps to find valid headers. The MPlayer code already tries to divide the MPEG stream into frames by itself, so I might make the mpg123 codec just rely on that and avoid the single-stepping totally. This might make it less robust in some ways, but would avoid these DoS-style cases.
Comment 14 Thomas Orgis 2014-06-10 07:45:41 UTC
Created attachment 378620 [details, diff]
patch to mpg123 1.20.0

Here is a preliminary patch to mpg123 to speed up things. It makes the I/O mode between mplayer and libmpg123 more efficient by avoiding excessive re-reading of data.

You can also just test http://mpg123.org/snapshot/mpg123-20140610094045.tar.bz2 

It makes the video play a lot quicker for me.
Comment 15 Paul Osmialowski 2014-06-14 15:04:24 UTC
Hi Thomas,

I tried to put this patch to /etc/portage/patches, but soon I had to exclude configure.ac part from it as rebuilding 'configure' script is impossible: mpg123 requires aclocal-1.14 which is not yet available on Gentoo. Anyway, this does not have any impact on the essence of the patch. Now with upraded and patched mpg123, the mplayer indeed opens this movie immediately. Trouble is, due to bug #513004 I had to upgrade mplayer to version media-video/mplayer-1.2_pre20130729 and now, I can't shift the movie back and forth since the audio gets more and more desynced with the video whenever I try to do that. So far it touches this only particular movie. And this time opening it with -ac ffmp3 did not help - it opens fast (as before), but moving back and forth sill causes unrecoverable glitches.
Comment 16 Thomas Orgis 2014-06-15 18:54:35 UTC
So, to summarize:

1. The issue with the slow opening is fixed by the patch.
2. The updated MPlayer has a different issue regardless of used MPEG audio decoder.

Correct? So ... time for an MPlayer bug report? I'll be preparing an mpg123 release, then, unless there is some issue still traceable to mpg123.
Comment 17 Paul Osmialowski 2014-06-16 21:02:00 UTC
Hi Thomas,

I masked affected version ffmpeg and downgraded mplayer to latest stable. Now with your patch to mpg123, I have fully working movie player. I'd like to say thanks for your effort.
I guess we can assume the bug is fixed. As for the new glitch, I can't really say whether it is ffmpeg's new version (which is already known to be buggy) or mplayers fault since I was using mplayer version marked as unstable (following the advice from ffmpeg's bug report). I don't think I'll be able to open new bug before ffmpeg is fixed or newer version of mplayer is stabilized. Also due to the lack of any error message during the glitch, it's hard to figure out what to trace - the bug report would be far from complete.