Gosh it has been a long time since my last post, life sucks sometimes. Lets get back into it with three golden oldies.
Downloading a real player file
Saving a real player stream takes two steps. Firstly you download the metadata file, this is a text file, normally ending with .ram.
wget http://link-to-realplayer-metadata-file.ram
Opening this file in a text editor, or by using the cat command will show a link such as:
rtsp
/blah-blah-blah/blah/blah.ra
Using the following command line arguments, you can now download the stream with mplayer:
mplayer -noframedrop -dumpfile localfile.rm -dumpstream rtsp
/blah-blah-blah/blah/blah.ra
Checking your HTTP headers
After fiddling with the configuration of your http server (e.g. Apache), you should check that it is supplying the correct headers. A quick and easy way is to use telnet.
To open the connection, you use:
telnet commandline.org.uk 80
Then lets check the http header for a basic HTML page, copy and paste both lines:
HEAD // HTTP/1.1
Host: commandline.org.uk
Now lets look at an image.
HEAD /images/posts/chess/matchreport/20081025/17.png HTTP/1.1
Host: commandline.org.uk
You can also get the whole page:
GET / HTTP/1.1
Host: commandline.org.uk
You can have hours of fun with telnet!
Giving Java some more juice
Regular readers will know I love using programming languages beginning with P, but I do regularly use little Java programmes written by my friends, which I run in the following way:
java -jar programname.jar
However, I find myself in the situation where the program will die due to lack of memory.
If it runs out of memory, then let it have more:
java -Xms128m -Xmx750m -jar programname.jar
The -Xms argument sets the initial heap size to 128 MB, the -Xmx sets the maximum heap size to 750 MB.
Now all your bloated, poorly-written Java programs can use up as much memory as they need.
<p>BTW, you can combine the "Downloading a real player file" hint into a single command that only depends on the .ram file.</p>
<p>mplayer -noframedrop -dumpfile localfile.rm -dumpstream $(curl --silent <a class="reference external" href="http://link-to-realplayer-metadata-file.ram">http://link-to-realplayer-metadata-file.ram</a>)</p>
<p>People still use Real Player?</p>
<p>As well as telnet, I also use "curl -I" for inspecting headers. Although it has a ridiculously long man page, it's slightly easier for poking about with certain client options:</p>
<p>curl -I <a class="reference external" href="http://www.amberfrog.com/logo/">http://www.amberfrog.com/logo/</a></p>
<p>(look ma, real XHTML)</p>
<p>Thanks for the comments guys. Great to see the all the gang are still here!</p>
<p>Thanks for the <a class="reference external" href="rtsp://">rtsp://</a> post - that's something that has been bugging me for a while!</p>
<p>Stumbled in here at lunch. This is the best find of the week. Thanks.</p>
<p>Very occasionally, you will run into a Java program that uses a lot of memory just to hold all the classes used. It turns out that the JVM uses a different memory segment to store class definitions (as opposed to the data actually used by the program), and you can run out of that even if you've allocated enough memory for the program operation using the command line switches above.</p>
<p>So, if you're still having memory problems running a particular Java program, try adding this option with the others: -XX:MaxPermSize. (You normally won't need more than 64MB...that's a LOT of class file definitions in memory.)</p>
<p>Like so...</p>
<p>java -Xms128m -Xmx750m -XX:MaxPermSize=64m -jar programname.jar</p>