Categories
Programming

How to play HLS with JWPlayer

In this post we will show you a simple way how to play HLS into web browser with JW PLayer – the free version.

Even on JW Player website is saying you need the Premium version for HLS, we found it is working also with the free version together with HLSprovider plugin.

We assume the root website is in /var/www/html.

First, you must download jwplayer-6.7 from http://www.jwplayer.com/ and save the archive in /var/www/html, on the web server.
Unpack the archive:

[code language=”bash”]
unzip jwplayer-6.7.zip
cd jwplayer
[/code]

Clone the HLSProvider plugin:

[code language=”bash”]git clone https://github.com/mangui/HLSprovider[/code]

We will create the HTML file where we will display the player:

[code language=”bash”]nano index.html[/code]

and paste the code below (of course you need to adjust it, replacing mydomain.com with your real domain name or IP):

[code language=”bash”]
<html>
<head>
<script type="text/javascript" src="http://mydomain.com/jwplayer/HLSprovider/test/jwplayer6/jwplayer.js"></script>
</head>
<body>
<div id="player">Loading the player…</div>

<script type="text/javascript">
jwplayer("player").setup({
playlist: [{
// file is the url to m3u8 file
file:’http://mydomain.com/hls/bbb.m3u8′,
provider: ‘http://mydomain.com/jwplayer/HLSprovider/test/jwplayer6/HLSProvider6.swf’,
type:’hls’
}],
width: 640,
height: 480,
primary: "flash"
});
</script>

</body>
</html>
[/code]

That’s all. Now point your browser to http://mydomain.com/jwplayer/ and you can play the video.
This example ‘should’ work both on iOS devices and PCs with Flash support.

You can see the example here – if the server is up

You can read also the blog post about HLS Video on Demand streaming

Categories
linux Programming

How to do VoD with nginx

You can read my last post on LeaseWeb Labs – Streaming Video on Demand with nginx and RTMP Module

Categories
Programming

Web server in one line of bash

If you want to quickly save a file through http but you don’t want to install a web server, you can just use netcat.
You can run:
[code language=”bash”]
while true; do { echo -e ‘HTTP/1.1 200 OK\r\n’; cat index.html; } | nc -l 8080; done
[/code]

index.html can be any file you want to serve it.

You can access it after that as: http://host_ip:8080/

Categories
Programming python

Install MySQLdb for Python 2.x

If you want to install MySQLdb for Python 2.x, without using the package manager of your Linux distro (Ubuntu in our case), you can do it through pip like this:

First you must to have installed libmysqlclient-dev (and, of course pip)

[source language=”bash”]
sudo apt-get install libmysqlclient-dev
[/source]

After that execute this two commands:

[source language=”bash”]
sudo easy_install -U distribute
sudo pip install mysql-python
[/source]

Test if is working:
Type in the command line:

[source language=”bash”]
python
[/source]

and in the python console:

[source language=”python”]
>>> import MySQLdb
>>> help(MySQLdb)
[/source]

That’s all. Enjoy!

Categories
Programming symfony2

Load bundle without composer.json in Symfony2.3

This is how I loaded a legacy budle without composer.json in a custom location for my Symfony2.3 project with composer.

In one of my Symfony2.3 projects I needed to use an old external bundle. This legacy bundle (from Symfony2.0) hasn’t a composer.json file and in my case I can not add one.
Anyway, I wanted to use composer and its autoloader also for this bundle in order to keep things simple for me.

Let’s assume I wanted to add TwitterClientBundle and its namespace is: Razvan\TwitterClientBundle

For this I added in my composer.json the following:

[javascript]

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"": "src/",
"Razvan\\TwitterClientBundle": "vendor/razvan/twitter-client-bundle"
}
},
"repositories": [
{
"type": "package",
"package": {
"name": "razvan/twitter-client-bundle/Razvan/TwittereClientBundle",
"version": "4.4.3",
"source": {
"url": "https://github.com/raztud/TwittereClientBundle",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"razvan/twitter-client-bundle/Razvan/TwitterClientBundle": "*"
},


[/javascript]

After that I ran:

[bash]php composer.phar update razvan/twitter-client-bundle[/bash]

and the bundle was added in /path/to/yourproject/vendor/razvan/twitter-client-bundle/

eg:

[bash]
razvan@main2:/var/www/twitter/vendor/razvan/twitter-client-bundle$ tree
.
— Razvan
— TwitterClientBundle
— DependencyInjection
   — RazvanTwitterClientExtension.php
— RazvanTwitterClientBundle.php
— Manager
….
[/bash]

After that I enabled the bundle in AppKernel.php

[php]new Razvan\TwitterClientBundle\RazvanTwitterClientBundle()[/php]

and that was all.

Disclaimer:
– Maybe there are better solution, but I did not find them yet.
– The bundle RazvanTwitterBundle doesn’t exist on Github.

P.S. Somebody else wrote a similar post in the past.

Categories
Programming

Tip: List vs. Set in Python

In Python, if you have a “list” with a lot of members and you need to do many membership checks, it will be better to use a “set” instead, because the checks are linear for lists and constant for sets.