audioread icon indicating copy to clipboard operation
audioread copied to clipboard

gstreamer not getting duration

Open matthysk opened this issue 9 years ago • 9 comments
trafficstars

Hi,

I've installed beets on linux mint 17.3.

I'm trying to get the chroma plugin to work but I got an error during import with every mp3 file saying

'''chroma: fingerprinting of 'music_raw/foo.mp3' failed: audio could not be decoded'''

I tried digging a bit in ipython and got to this point:

In [10]: f = gstdec.GstAudioFile("Pearl Jam - I Am Mine.mp3")
---------------------------------------------------------------------------
MetadataMissingError                      Traceback (most recent call last)
<ipython-input-10-ae222d97b34d> in <module>()
----> 1 f = gstdec.GstAudioFile("Leona Lewis - Bleeding in Love.mp3")

/usr/local/lib/python2.7/dist-packages/audioread/gstdec.pyc in __init__(self, path)
    256             # An error occurred before the stream became ready.
    257             self.close(True)
--> 258             raise self.read_exc
    259 
    260     # Gstreamer callbacks.

MetadataMissingError: duration not available

I am able to play these files in other music players.

Not sure what information you need to reproduce the error but if you let know I'll post it.

Python libs:

$pip freeze
BeautifulSoup==3.2.1
Mako==0.9.1
MarkupSafe==0.18
PAM==0.4.2
Pillow==2.3.0
PyBluez==0.18
PyYAML==3.11
Twisted-Core==13.2.0
Twisted-Names==13.2.0
Twisted-Web==13.2.0
Unidecode==0.04.19
apt-xapian-index==0.45
apturl==0.4.1ubuntu4
argparse==1.2.1
audioread==2.1.2
beets==1.3.17
ccsm==0.9.11.3
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
compizconfig-python==0.9.11.3
configglue==1.1.2
configobj==4.7.2
debtagshw==0.1
decorator==3.4.0
defer==1.0.6
dirspec==13.10
dnspython==1.11.1
duplicity==0.6.23
enum34==1.1.6
feedparser==5.1.3
html5lib==0.999
httplib2==0.8
iotop==0.6
ipython==1.2.1
jellyfish==0.5.4
lockfile==0.8
lxml==3.3.3
munkres==1.0.7
musicbrainzngs==0.6
mutagen==1.32
oauthlib==0.6.1
oneconf==0.3.7.14.04.1
paramiko==1.10.1
pexpect==3.1
piston-mini-client==0.7.5
protobuf==2.5.0
pyOpenSSL==0.13
pyacoustid==1.1.0
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygobject==3.12.0
pyinotify==0.9.4
pyserial==2.6
pysmbc==1.0.14.1
python-apt==0.9.3.5ubuntu2
python-debian==0.1.21-nmu2ubuntu2
python-xlib==0.14
pyxdg==0.25
reportlab==3.0
requests==2.2.1
sessioninstaller==0.0.0
simplegeneric==0.8.1
simplejson==3.3.1
six==1.5.2
system-service==0.1.6
trimage==1.0.2
uTidylib==0.2
urllib3==1.7.1
vboxapi==1.0
virtualenv==1.11.4
wsgiref==0.1.2
zope.interface==4.0.5

Gstreamer version:

$gst-play-1.0 --version
gst-play-1.0 version 1.2.4
GStreamer 1.2.4
https://launchpad.net/distros/ubuntu/+source/gst-plugins-base1.0

Any help will be appreciated!

matthysk avatar May 16 '16 20:05 matthysk

I've noticed that GStreamer 1.0 has trouble parsing some MP3 files that other software deals with fine. Can you check whether gst-play and gst-inspect complain when directed toward the same file?

sampsyo avatar May 16 '16 20:05 sampsyo

Hey,

I just looked at the installed packages on my sytem and there is a mix of 0.1 and 1.0 gstreamer packages. Is that normal? I had python-gst 0.1, then I tried installing both, then removing 0.1 and no combination worked.

Here is output from gst-play and gst-inspect:

$ gst-play-1.0 Pearl\ Jam\ -\ I\ Am\ Mine.mp3 
Now playing /home/roxthys/lanshare/media/music_raw/Pearl Jam - I Am Mine.mp3
^C00:01.8 / 0:03:33.3

$ gst-inspect-1.0 Pearl\ Jam\ -\ I\ Am\ Mine.mp3 

(gst-inspect-1.0:9474): GStreamer-WARNING **: Failed to load plugin 'Pearl Jam - I Am Mine.mp3': Pearl Jam - I Am Mine.mp3: cannot open shared object file: No such file or directory
Could not load plugin file: Opening module failed: Pearl Jam - I Am Mine.mp3: cannot open shared object file: No such file or directory

$ gst-inspect-0.10 Pearl\ Jam\ -\ I\ Am\ Mine.mp3 
(gst-inspect-0.10:9475): GStreamer-WARNING **: Failed to load plugin 'Pearl Jam - I Am Mine.mp3': Pearl Jam - I Am Mine.mp3: cannot open shared object file: No such file or directory
Could not load plugin file: Opening module failed: Pearl Jam - I Am Mine.mp3: cannot open shared object file: No such file or directory

Playing works fine but inspect is missing some library it seems.

matthysk avatar May 16 '16 21:05 matthysk

They should coexist peacefully—but audioread only uses 1.0 these days.

Hmm; maybe I was wrong about gst-inspect being the right thing to try. There's some commentary on similar issues on the thread about implementing gst 1.0 support: https://github.com/beetbox/audioread/pull/22#issuecomment-106695567

That comment suggests using gst-launch (I think) with a special pipeline to see if GStreamer has any clue about the duration of the file. I seem to have lost track of of the Bugzilla link, but I seem to remember this could be a known bug for them.

sampsyo avatar May 16 '16 21:05 sampsyo

@sampsyo I thought the gstreamer duration issue was about really tiny mp3s

gst-inspect-1.0 doesn't deal with media files, but with gstreamer plugins and elements

ghost avatar May 16 '16 22:05 ghost

@matthysk the command you probably want is gst-discoverer-1.0 <path>. You may need to install an additional package to get it, but I only know the name of the package on RHEL/CentOS/Fedora (gstreamer1-plugins-base-tools)

ghost avatar May 16 '16 22:05 ghost

Thanks, @jrobeson; I was freehanding and mixed up the GStreamer commands. :cry:

Yes, I only saw this for very short files, but the symptom here seems to be the same: no duration available for MP3s. Maybe there's something related happening.

sampsyo avatar May 16 '16 22:05 sampsyo

every gui audio program playing program I've used for the past 10 years has used some version of gstreamer or another, and I've never seen that happen (except the really short ones that I've never had IRL). Of course, there could be some bug related to that, but it's unlikely.

EDIT: I tend to use gst123 on the cli too, so maybe that's something to try after gst-discoverer-1.0

ghost avatar May 17 '16 01:05 ghost

I think that the issue here is that for variable bitrate MP3 files, there's no way to know the duration without reading the whole file. So GstPad.query_duration() returns a duration of 0 if the file has not been read fully yet.

This could be worked around by reading the whole file in the init() method, then seeking back to the beginning.

ssssam avatar Dec 26 '18 20:12 ssssam

Got it! Maybe the right behavior here would just be to produce zero for the duration in this case instead of throwing an exception?

sampsyo avatar Dec 26 '18 21:12 sampsyo