GNOME Bugzilla – Bug 566661
[typefind] Fall back to file extension using uri query
Last modified: 2009-12-17 06:01:42 UTC
Please describe the problem: Using Ubuntu Intrepid (8.10). When trying to play an audio .gsm file, Totem displays the following error dialog: "An error occurred. Could not determine type of stream." Running totem from command line, the following output is shown: magicfab@magicfab-laptop:~$ totem Desktop/msg0001.gsm ** (totem:10268): DEBUG: Init of Python module ** (totem:10268): DEBUG: Registering Python plugin instance: YouTube+TotemPythonPlugin ** (totem:10268): DEBUG: Creating object of type YouTube+TotemPythonPlugin ** (totem:10268): DEBUG: Creating Python plugin instance ** (totem:10268): DEBUG: Init of Python module ** (totem:10268): DEBUG: Registering Python plugin instance: BBCViewer+TotemPythonPlugin ** (totem:10268): DEBUG: Creating object of type BBCViewer+TotemPythonPlugin ** (totem:10268): DEBUG: Creating Python plugin instance ** Message: Error: Could not determine type of stream. gsttypefindelement.c(806): gst_type_find_element_activate (): /GstPlayBin:play/GstDecodeBin:decodebin0/GstTypeFindElement:typefind Steps to reproduce: 1. Double click on .gsm file on the Desktop Actual results: Totem displays the following error dialog: "An error occurred. Could not determine type of stream." Expected results: Totem should play the .gsm audio file. Does this happen every time? Yes. Other information: This has also been files as an Ubuntu bug at: https://bugs.edge.launchpad.net/ubuntu/+bug/290527
Created attachment 125799 [details] Example .gsm audio file I've attached an example .gsm file. This is commonly used in Asterisk servers to send voice mail as GSM attachments via email.
Added the file detection to shared-mime-info (without any magic): * freedesktop.org.xml.in: * tests/list: * tests/msg0001.gsm: Add audio/x-gsm for GSM 06.10 encoded audio files Added it to Totem as well: 2009-01-06 Bastien Nocera <hadess@hadess.net> * data/mime-type-list.txt: Add audio/x-gsm GStreamer should be able to play the file, it has a gsm decoder, and ffmpeg contains a demuxer for the format. Didn't work in my tests though. Sox played it fine.
This file contains raw GSM data, there is not enough information to typefind this. It would work better if the GSM data was inside a container like AVI or so. I don't think we can automatically play this file without the user specifying the type of the file.
Or inside a wav file, which is all spec'ed up.
The file comes from voice mail sent by an Asterisk system. Is it malformed ? aplay (from sox) deals fine with it, I suppose it doesn't block playback on knowing what type of audio it is. Fixing this for Totem seemed like a good way to have support for GSM in other applications too. I am interested in playing such files in Totem (or else) because aplay doesn't provide any visual indication of playback nor can it stop/pause/forward/rewind playback.
It's not malformed, it can be played with GStreamer if you make a custom pipeline. It's just that the type of those files cannot be determined reliably. We could assume the gsm format based on the extension when the typefinder cannot find anything but it's unclear how that should work. what are you using to play the file back, none of the tools I have can automatically play this file.
Sox plays it fine, it needs to be compiled with gsm support though. The one in Fedora is plays it out-of-the-box though.
what if you rename the file to a different extension? does it still play it as a gsm file?
In Ubuntu I need to install the following packages: sox libsox-fmt-gsm Then I can assign "aplay" to play .gsm attachment in Thunderbird (or else). aplay however is only command line and although the file plays well I can't control anything about it. In fact I often stop its playback using the System Monitor or kill.
sorry, I don't get it: wim@wtay:~$ dpkg-query -S /usr/bin/aplay alsa-utils: /usr/bin/aplay wim@wtay:~$ my aplay is from alsa-utils, what does that have to do with sox? Also: wim@wtay:~$ aplay /home/wim/data/msg0001.gsm Playing raw data '/home/wim/data/msg0001.gsm' : Unsigned 8 bit, Rate 8000 Hz, Mono wim@wtay:~$ which results in noisy output. sox however comes with play, which does: wim@wtay:~$ play /home/wim/data/msg0001.gsm Input File : '/home/wim/data/msg0001.gsm' Sample Size : 8-bit (1 byte) Sample Encoding: GSM Channels : 1 Sample Rate : 8000 Time: 00:07.44 [00:00.00] of 00:00.00 (0.00%) Samples out: 357k Clips: 0 Done. Nicely sounding GSM decoded and all. Then when I rename the file, removing the .gsm extension: wim@wtay:~$ play /home/wim/data/msg0001 play soxio: Can't open input file `/home/wim/data/msg0001': unknown file type wim@wtay:~$ As expected because you can't guess the type of a raw GSM file. So it seems that is is simply using the .gsm extension to determine the codec.
Apologies, of course I wanted to write "play" and instead my keyboard decided otherwise. I can confirm everything in Wim's comment. I also renamed to .wav and this confirms it uses extensions: magicfab@bachue:~$ play Desktop/msg0001.wav play soxio: Failed reading `Desktop/msg0001.wav': WAVE: RIFF header not found
Ok, cool. What we should do then is let the typefinder fall back to the file extension if the type could not be determined by looking at the data. It also happens that GST_QUERY_URI from Bug #562949 was commited recently which allows us to to get the uri and file extension in typefind. Changing subject to reflect this.
Created attachment 126127 [details] [review] first patch to core First part of a patch. * Add gst_type_find_helper_for_extension() to the typefind helper * Allow registering typefind factories that only register extension/caps without a real typefind function. * patch the typefindelement to search for extensions<->caps mappings when we can determine the type algorithmically.
Created attachment 126128 [details] [review] Patch to register a gsm typefinder * Add a GSM extension to caps typefindfactory * allow for making the extension strings static
commit cc8b9ae5e8d11d16f313cde3a74bd871052a9dec Author: Wim Taymans <wim.taymans@collabora.co.uk> Date: Fri Jan 23 11:40:26 2009 +0100 Add typefind function for gsm Because core now supports typefindfactories without a typefind function we can register a factory fo GSM that will --if all else fails-- assume the file is a GSM file based on the registered extension. Fixes #566661.
Comment from the launchpad bug: >>> I'm running 9.10. Totem says Pause | 0:00 (Streaming) and when I hit play, the "visual effects" play for what I would approximate as the time of the recording, however the time does not change and no audio is heard. <<< gstreamer in Ubuntu 9.10 has the following components: gstreamer0.10 | 0.10.25-2 | karmic | source gstreamer0.10-plugins-bad | 0.10.14-4ubuntu1 | karmic/universe | amd64, i386 gstreamer0.10-plugins-ugly | 0.10.12-1 | karmic/universe | amd64, i386 gstreamer0.10-plugins-good | 0.10.16-1ubuntu3 | karmic | amd64, i386 gstreamer0.10-plugins-base | 0.10.25-2ubuntu1 | karmic | amd64, i386