Join now!

Search blog.co.uk

Streaming video in Linux

by cc0028 @ 2008-01-05 - 20:25:07

Or how to watch telly on Linux when the channel thinks everyone uses Windows ...

Up until yesterday, you could have written on the back of a postage stamp everything I knew about streaming video. You might need, perhaps, half a sheet of A4 now: so I still don't know a lot, but I know more than I did. Here's why.

On a visit to the S4C Web site recently, I noticed that they were offering the facility to view some of their programmes on a computer. These were either programmes that had already been broadcast and had been saved to a file, or programmes currently being televised. "Ooh! There's lovely" I thought, as you do if you live in this part of the world, and clicked on a link to a programme shown earlier of a concert by the harpist Catrin Finch. I have this Catrin Finch problem: but let's not go into that.

The only response I got to clicking on the link was an error message saying that, "mms is not a registered protocol". The protocol MMS, it appears is a Microsoft proprietory video streaming format, and so not a lot of help to those of us who do not run Windows computers. Now, I've lived for nearly sixty-one years without needing mms so I'm pretty certain I could carry on without it, but it did appear to me that it was a bit unfair of S4C to provide content for Windows users only. So I wrote to S4C to see what they had to say.

I had an email back from them explaining that they felt that they had to use the most popular video streaming format, and referring me to some Web sites that turned out not to be of much use. It was pretty obvious from the reply that they weren't going to change their policies just for me, although I did point out that Linux users, minority or not, paid just as much for S4C as anyone else and ought therefore to get the same service as everyone else. It also occurred to me that if they applied their argument to language usage, S4C would not exist. It is the highest cost per capita television channel in the UK and serves 1% of the UK population. I didn't say that, though. Instead I just wrote that we'd have to agree to differ.

All this did start me thinking though, which is usually a dangerous thing, but in this case turned out fairly well.

I'm on the mailing list of the South Wales Linux User Group, so I posted there asking if anyone could suggest a way of getting the S4C programmes on Linux. Their combined help was truly amazing.

The first thing that I learnt was that you could obtain MPlayer for Linux. MPlayer is free, and supports the mms format. So I downloaded it and installed it. The result was that I could do this from a command line to watch Catrin Finch:

mplayer "mms://s4c.unique-media.tv/s4c_uk/bsm/hsbc_jazz_
aberhonddu___catrin_finch_ai0000803d21b8.wmv?sami=http:
//www.s4c.co.uk/sami/A290559874.smi"

The bit in quotes is the URI, and I got it by right-clicking on the link on the S4C Web page and selecting "Copy Link Location" from the context menu in Firefox. I then pasted the link text onto the command line I was using.

The results were not impressive, though. In fact the results were unwatchable with the picture stopping and starting all the time and the sound totally out of sync with the video. However, not to be deterred, I learnt next from the SWLUG faithful that you could do this:

mplayer -dumpstream "mms://s4c.unique-media.tv/s4c_uk/
bsm/hsbc_jazz_aberhonddu___catrin_finch_ai0000803d21b8.wmv
?sami=http://www.s4c.co.uk/sami/A290559874.smi"

This downloaded the stream to a file called stream.dump in the same folder as the folder from which the mplayer command was issued. Once the file had been downloaded, you could do this:

mplayer stream.dump

The results of this were better, because the stream was no longer downloading in real time: however the picture quality was still disappointing. By the way, I'm not sure how happy S4C would be to know that you could download the stream to a file like that. Does it make me a pirate?

Once again, the group had a suggestion. Had I tried xine? Well, no, I hadn't. In fact even though it came with my SUSE Linux distribution, I'd never installed it. Ten minutes later I had xine installed and tried:

xine stream.dump

The results were perfect. So I thought I'd try real time:

xine "mms://s4c.unique-media.tv/s4c_uk/bsm/hsbc_jazz_
aberhonddu___catrin_finch_ai0000803d21b8.wmv?sami=http:
//www.s4c.co.uk/sami/A290559874.smi"

No luck. Nothing.

Another post to the group and I discovered that xine didn't want to know about the final bit of the URL above: the bit starting with the question mark and ending ".smi". So I tried with this:

xine "mms://s4c.unique-media.tv/s4c_uk/bsm/hsbc_jazz_
aberhonddu___catrin_finch_ai0000803d21b8.wmv"

Absolutely perfect. Streaming video in real time.

And that would be it, really, you would think. I certainly did. I wrote back to S4C explaining to them how it was done and settled back to do some serious Catrin Finch watching. Just then another email from the SWLUG dropped into my mail box. It said:

While I was playing around with this I found this link, now I can click
on an mms link in firefox and it opens xine.

http://www.cinlug.org/node/316

Here is all you have to do (quoted from the site):

  • Open Firefox, type "about:config" (no quotes) in the address window, and click enter.
  • Right click on the window and choose <New>, then <String> from the pop-up menu that appears.
  • In the first pop-up box, enter: "network.protocol-handler.app.mms" (no quotes, and it might just be easier to cut 'n paste this into the box).
  • In the next pop-up box enter the path to Kaffeine (e.g. "/usr/bin/kaffeine").
  • Now, click in the main window again but choose <New> <Boolean>
  • In the first pop-up box, enter: "network.protocol-handler.external.mms"
  • In the second pop-up select <True>.

This only works, obviously, if you have Kaffeine - which most Linux distributions do. It would probably also work with any player that accepted the entire link location (i.e. including the bit from the question mark until the ".smi"). You would just have to change the "path to Kaffeine" bit, to "path to MPlayer", or whatever.

Now all I have to do is to click on the link in Firefox and the video opens in Kaffeine. Just, wouldn't you agree, as nature intended.

This prompted another email to S4C and the suggestion that they publish an article on their Web site explaining how to do it. Alternatively, I suggested - rather generously, I thought - that they might want to ask me to write an article that they could link to from their Web site. That way they don't have to accept any responsibility for its content.

So what do we learn from all this? A few things, I reckon.

Firstly, I learnt a fair bit about streaming video, and that can't be a bad thing.

Secondly, I learnt that the Linux community have the most incredible knack of working together to pool knowledge and to solve each other's problems. They've never failed me yet.

Lastly, I learnt that whatever it is, in the Open Source world someone will have had a crack at it and will have produced a solution. Not one of the applications that I have mentioned in this article is owned by a private company or individual. They are all the fruit of co-operative code hacking by a community of programmers interested in solving a problem. This is what programming should be like. It is more akin to a research activity than to product development: and it is done best when done openly and in a spirit of co-operation. It's why open source software works and closed source software often doesn't.

Vista, anyone? No? Didn't think so.

Happy new year to one and all - or "Blwyddyn Newydd Dda" as they say on S4C.

:)


 
 

Trackback address for this post:

authimage

Comments, Trackbacks: Hide subcomments

Kathryn [Visitor]
http://theshellgame.wordpress.com/
06/01/08 @ 10:27

Nice job!

I'm looking fondly at mplayer. I've been using it since I started out about 6 months ago. I'm working on a script for mplayer right now. I'm not doing so well with it. But I'm working on it. Maybe I'll throw it up on my blog and get some community feedback.

Leave a comment :

Your email address will not be displayed on this site.
Your URL will be displayed.
Allowed XHTML tags: <!, p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, a, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small, img>
URLs, email, AIM and ICQs will be converted automatically.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)
Validation code:
Please enter the above code here:
For protection from spambots (case-sensitive).

Recent Posts

  1. A matter of style
    by cc0028 on 2008-09-11
  2. The late Helen Mary Bradley
    by cc0028 on 2008-08-10
  3. Install issues - harder than you think
    by cc0028 on 2008-08-10
  4. At your service
    by cc0028 on 2008-07-16
  5. The standard way of working
    by cc0028 on 2008-06-27
  6. Beyond lies the Web
    by cc0028 on 2008-06-25
  7. EPP
    by cc0028 on 2008-06-24
  8. Who dares, wins
    by cc0028 on 2008-01-28
  9. A cat's tale
    by cc0028 on 2007-12-17
  10. A grandad. Again.
    by cc0028 on 2007-04-19

Footer

The content of this website belongs to a private person, blog.co.uk is not responsible for the content of this website.