zaterdag 13 juni 2009

Sla mediastreams op, op je eigen pc!

Are you not Dutch? But English is no problem? Click here to go to the English version.



Een tijd geleden ben ik ongeveer een dag bezig geweest voor de website www.gb2000.nl. Er was namelijk op de regionale omroep, Omrop Fryslan, een uitzending van het nieuws geweest (programma heet Hjoed). In die uitzending kwam een item over de gemeente ter sprake. Omdat dit over iemand van GB2000 ging, wilden we dat fragment op de eigen site zetten. De complete nieuwsuitzending staat op de website van Omrop Fryslan (www.omropfryslan.nl).

Met een aantal programma's heb ik het bestand proberen binnen te halen. Dat
gaat niet altijd goed (is het beeld goed, zit er geen geluid bij!).

Kijken of het makkelijker kan.
Dus ik naar de website en uitvogelen wat de URL van het videobestand
was. De pagina op Omrop Fryslan is de volgende URL:
http://www1.omropfryslan.nl/Player.aspx?t=v&fn=1900_HJOED20MEI09.wmv
We zien hier dat de website van omropfryslan een ASP.NET website is, en dat het bestand een wmv bestand is.
Als we de pagina openen en vervolgens in de code van die pagina kijken,
staat er onder andere dit in:
<param name="FileName" value="http://www5.omropfryslan.nl/video.asp?F=1900_HJOED20MEI09.wmv"/>
Dit bestand wordt via een asp bestand binnen gehaald.
We openen die pagina in een browser; automatisch wordt Windows MediaPlayer gestart waarin de uitzending wordt getoond. We kijken nu in de Eigenschappen in Windows MediaPlayer. Hey... dezelfde URL. Ik meende dat toen ik er voor GB2000 mee bezig was, dit ding via mms e.d. ging.

Dit maakt het een tikje makkelijker (denk ik nu nog...).
Ik open Microsoft Visual C# 2008 (Express Edition) en maak een nieuw Windows Forms project aan met de naam 'onlineFileSaver'.
We voegen een tekstvak toe waar we de URL in kunnen plakken/typen, een knop om het bestand lokaal op te slaan en een saveFileDialog. We voegen bij de using statements een 'using System.Net;' toe.

Ik download het bestand en krijg een bestand van 1 kB binnen. Hey, dat is te weinig.
Kijken wat erin staat:


<asx version = "3.0">
<entry>
<ref href = "mms://mms.omropfryslan.nl/video/1900_HJOED20MEI09.wmv"/>
<Title></Title>
<Author>Omrop Fryslân</Author>
<Copyright>Copyright (c)2009, Omrop Fryslân</Copyright>
<Banner HREF = "http://www5.omropfryslan.nl/of.gif" />
</entry>
<Title></Title>
<Author>Omrop Fryslân</Author>
<Copyright>Copyright (c)2009, Omrop Fryslân</Copyright>
<Banner HREF = "http://www5.omropfryslan.nl/of.gif" />
<LogURL href = ""/>
</asx>

Ja, dus toch een MMS stream.
Na wat onderzoek blijkt dat ik dit toch niet even 1-2-3 met een webclient o.i.d.
binnen kan halen.

MMS staat voor de Microsoft Media Services.
Wiki pagina:
http://en.wikipedia.org/wiki/Microsoft_Media_Services

MMS is meestal via poort 1755 bereikbaar. Dit lukt me nog wel als ik een Socket aanmaak en connect:

lSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
lSocket.Connect("mms.omropfryslan.nl", 1755);

Alleen, de vervolgstappen, dat lukt me niet (krijg continu een -1 als resultaat terug).

Maar... op de WIKI pagina, daar vind ik een link naar het SDP media project.
Dat is een closed source freeware programma waarmee je kunt doen wat ik eigenlijk
wil. URL is: http://sdp.ppona.com/

Programma gedownload, geinstalleerd en getest met deze URL.
Resultaat is prima! Als ik nog eens tijd heb ga ik er misschien zelf mee puzzelen, maar op deze manier kan ik, als ik nog eens wat snel moet downloaden, het sneller fixen dan het eerste filmpje van Omrop Fryslan!

Update; al een hele tijd geleden kwam ik de site www.zapperz.nl tegen.
Daar stonden coole filmpjes op (onder andere Sensation White in 2006 als ik me niet vergis). Is de site niet bereikbaar.. daar kom ik dan nog op terug.


ENGLISH VERSION



A while ago I had to download a movie to my pc for the website www.gb2000.nl.
The regional broadcast company, Omrop Fryslan, had made a broadcast of the news of that day, which contained an item about someone from GB2000. The complete wmv file stood on the website (www.omropfryslan.nl).

I tried a couple of programs to save the file locally so I could edit it. That did not always work out the way I wanted it (e.g. the image was perfect but the movie did not contain the sound!).

So now I wanted to see if I can make it more easy for myself (and others). I opened the website in my browser, this is the URL:
http://www1.omropfryslan.nl/Player.aspx?t=v&fn=1900_HJOED20MEI09.wmv
We see here that the website is an ASP.NET website, the file is of the WMV-type.
When we look at the source of the page, we see that it contains this statement:
<param name="FileName" value="http://www5.omropfryslan.nl/video.asp?F=1900_HJOED20MEI09.wmv"/>
The file is opened by ASP. When I call this URL from Internet Explorer, Windows MediaPlayer starts and shows the broadcast. So first we try this URL with an System.Net.WebClient.

I start Microsoft Visual C# 2008 (Express Edition) en create a new Windows Forms project named 'onlineFileSaver'. I add a textbox where we can place the URL, a button and a saveFileDialog (which is triggered by the button).
We also add the using System.Net; on top of the code.

I download the file: it is 1 kB! Much too small, when I open it in Notepad I see that
it contains this text:

<asx version = "3.0">
<entry>
<ref href = "mms://mms.omropfryslan.nl/video/1900_HJOED20MEI09.wmv"/>
<Title></Title>
<Author>Omrop Fryslân</Author>
<Copyright>Copyright (c)2009, Omrop Fryslân</Copyright>
<Banner HREF = "http://www5.omropfryslan.nl/of.gif" />
</entry>
<Title></Title>
<Author>Omrop Fryslân</Author>
<Copyright>Copyright (c)2009, Omrop Fryslân</Copyright>
<Banner HREF = "http://www5.omropfryslan.nl/of.gif" />
<LogURL href = ""/>
</asx>

Ok, so the broadcast is provided by a MMS stream.
I try some different possibilities and finally I see that I cannot do it
very quick/easy. So I start to look on the World Wide Web.

MMS means Microsoft Media Services.
Wiki pagina:
http://en.wikipedia.org/wiki/Microsoft_Media_Services

The MMS contents can mostly be received by calling port 1755. That works when
I create a Socket and connect:

lSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
lSocket.Connect("mms.omropfryslan.nl", 1755);

But then... what to do?
Fortunately on the WIKI page is a link to the SDP project, a closed source
freeware program which does what I want (save the file of a MMS stream on my local disk).
The URL is: http://sdp.ppona.com/

I downloaded it, installed it and tried the above MMS url.
The result is perfect!

A long while ago I found the site www.zapperz.nl, which broadcasted the sets of
Sensation White 2006 (3 years ago... time really flies :( ).
So I want to try it here, turns out the website is offline? Pity... I will try it again later.