-----------------------------------------
smthplayer 0.12 (rel: 10/12/2012)
Powered by Matteo Seclì <secli.matteo@gmail.com>
Released under GPLv2 licence or higher.
Using smth.php class and MkVid264.php (by mitm and k0wal5ky)
smthplayer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
By using this program, you accept that I HAVE NO RESPONSIBILITY
for any use you make of it. Therefore, make sure you can play with a standalone player
the stream you'd like to watch.
Although this program is an evolution of old raibot.php 0.0.2a <http://acab.servebeer.com/php/src/>
by mitm, it has no more relationship with rai.tv. Its aim is to be a universal cross-platform smooth
streaming player, not a bot for rai.tv site. Here is what is changed:
v0.12 (rel: 10/12/2012)
- No need of faad anymore to decode aac!
v0.8 (rel: 18/08/2012)
- Important fix of CustomAttributes issue in the request url.
v0.7 (rel: 07/07/2012)
- New (still rough) MPlayer control function via pipes for both Windows and Linux (no more crashes!);
- Some small fixes on the parser side.
v0.6 (rel: 02/06/2012)
- Play 2 or more streams at the same time;
- Added a "safe mode" that downloads chunks even if extracted timestamps are corrupted;
- New downloader engine for all types of timestamps attributes;
- For non-live streams, added the possibility to start the playback from a precise point;
- Wave header building from both WaveFormatEx and wave attributes;
- Included MkVid264.php in the smth.php class (this makes smthplayer faster);
- Better managing of Live manifests;
- Fixed timestamps parsing;
- Fixed CustomAttributes parsing;
- Fixes in the video request url;
- Fixed shift format;
- Smarter layout;
- Other minor fixes.
v0.4 (rel: 01/04/2012)
- New options parser for simpler and more customizable commands;
- Fixed some bugs on the parser side;
- Fixed a bug in the AAC decoding function (now AAC-LC and AAC-HE are fully supported);
- Added a new function that gives more stability to the player;
- Added the shebang line - after a cleaning of carriage return chars: *nix users can use "./smthplayer.php".
v0.3 (rel: 20/03/2012)
- Adaptive streaming support;
- Fixes in the audio request url;
- Sorting of indexes that are not in the correct order;
- Added a "scale" option to mplayer.
v0.2 (rel: 16/02/2012)
- New manifest parser for both ism/isml and csm manifests;
- H.264 and AAC support, that is entirely by k0wal5ky. I have just "translated" his bash script to php;
- WmaPro support (thanks again to k0wal5ky for his tip about WaveFormatEx);
- Prompt for index bitrate if not given;
- Prompt for clip index if not given;
- Timestamp calculation from chunk "d" attributes;
- No timestamps sync during buffer time, for faster buffering;
- Initial delay option, for safe streaming beginning on some servers;
- Automatic start of the player if set;
- Playfile building (for manual start of the player).
I want also to say clearly that this program is a player, not a downloader! And it will NEVER be
a downloader. In fact, audio and video temporary files are always kept separated and never joined in a
audio/video cointainer. This is for legal reasons, so please DO NOT ask me to make a recording function.
-----------------------------------------
--------------------------
REQUIREMENTS
--------------------------
In order to launch smthplayer.php, you have to have installed on you computer PHP5.
See: <http://php.net/downloads.php>
You need also FAAD2 for aac decoding.
See: <http://www.audiocoding.com/>
The latest thing you need is mplayer.
See: <http://www.mplayerhq.hu/>
---------------------------
CONFIGURATION
---------------------------
Configuration options depend on you operating system.
You have to configure some variables in smthplayer.php. The examples below are using default Linux configuration:
$mplayer = "mplayer";
This parameter sets the mplayer path.
$vc1_codec = "ffvc1";
This parameter sets the video codec for WMV/VC-1 elementary streams.
$vc1_adaptive_codec = "wmvvc1dmo";
This parameter sets the video codec for WMV/VC-1 elementary streams if you are playing an adaptive streaming. Currently,
this is the only codec that can play VC-1 adaptive streams. Note that you have to install 32-bits codecs in order to use it.
32-bit Ubuntu users can easily install them by installing the "w32codecs" package from Medibuntu repo.
For 64-bit Ubuntu users I provide a deb package cointaining a 32-bit mplayer with 32-bit codecs included.
Visit <https://sourceforge.net/projects/smthplayer/files/extras/mplayer32/> to download it.
$h264_codec = "ffh264";
This parameter sets the video codec for H.264 elementary streams.
$wmav2_codec = "ffwmav2";
This parameter sets the audio codec for WMAv2 streams.
$wmapro_codec = "ffwmapro";
This parameter sets the audio codec for WMAPRO streams. I suggest to try firstly ffwmapro codec, but you have
to install a very recent mplayer version to get a working version of this codec. If you are an Ubuntu user,you could
try to install it from <https://launchpad.net/~motumedia/+archive/mplayer-daily>.
If ffwmapro doesn't work properly, use "wma9dmo" codec. If you are on a 64-bit system, you need to follow this guide
in order to use wma9dmo codec: <http://www.cyberbyte.ch/Linux/mplayer32biton64bit_win32codecs.htm>.
Obviously, you need to set $mplayer to "mplayer32" after installing mplayer32 package.
$aac_codec = "faad";
This parameter sets the audio codec for AAC streams.
$playfile = "PlayMe.sh";
This parameter sets the file cointaining the command for playing your stream. I suggest to use a .sh file on Linux
and a .bat file on Windows, as you can play your stream by simply double-clicking on the file.
The file must be used within the first two minutes (approx.) of stream, because then it becomes unusable and you
must restart smthplayer.
Note that when you use PlayMe.sh for the first time, you need to give it execution attributes. Then, you can
simply not delete the file to avoid giving it permissions every time.
$automatic_play = "yes";
If this parameter is set to "yes", you can avoid to use "playfile" to play your stream, because smthplayer will play it
automatically. If you have troubles, simply delete "yes" and write anything else.
If you are on Windows, you have to use bgrun.exe from <http://www.jukkis.net/bgrun/> to allow background start
of mplayer.exe and prevent smthplayer.php waiting for mplayer.exe execution.
For this reason, you have also to set $mplayer to "bgrun.exe mplayer.exe".
$buffer_time = "10";
This parameter sets the buffer time after which playfile will be created. It depends on your system, but I don't recommend
to use a value lower than "10". It must be an even number.
$init_delay = "5";
This parameter sets Nth timestamps to use as a starting timestamp. Because some servers don't make a "chunk cache",
it could be possible that the time the program takes to start the chunk downloading makes the first parsed timestamp unaviable.
To avoid that, the program also downloads again the manifest before starting download if you gave "ask" option.
$mplayer_options = "-idle -mc 0 -autosync 30";
This parameter sets mplayer extra options.
------------------------
HOW TO USE IT
------------------------
In order to use the program, you have to launch it from the directory in which is stored.
Therefore, you have to open a terminal, navigate to the folder of the program, and launch it with:
"php smthplayer.php" followed by program options.
Note that *nix users can use
"./smthplayer.php"
without calling php.
For a options help, simply launch
php smthplayer.php
or follow the help below.
-----------------------------------------
HOW TO USE IT - OPTIONS
-----------------------------------------
Usage for ism - isml manifests:
php smthplayer.php --ism <ISM> --vidx <INDEX_NUMBER|'ask'|'adaptive'> --manifest <Manifest forced url>
'--ism' and '--vidx' arguments are necessary, while the '--manifest' one is optional.
'--ism' argument is the url of the video with the '/' at the end, while '--vidx' argument is a number (from 0 that indicates
highest quality to a maximum number depending on the manifest), or the word 'ask', that makes the program asking you
for index number after showing you the available indexes, or the word 'adaptive' that makes the program trying to play
an adaptive streaming (still experimental!!!). Use 'ask' option if you are unsure about index number.
Options can be given in any order in one of these forms:
--option="value" --option "value" --option value
Examples:
php smthplayer.php --ism http://mediadl.microsoft.com/mediadl/iisnet/smoothmedia/Experience/BigBuckBunny_720p.ism/ --vidx ask
php smthplayer.php --vidx 2 --ism http://mediadl.microsoft.com/mediadl/iisnet/smoothmedia/Experience/BigBuckBunny_720p.ism/
'--manifest' option forces the manifest url. If the program cannot obtain manifest url simply adding 'Manifest' to the url
you gave as first argument, you can specify it manually. Example:
php smthplayer.php --ism http://smooth.server.com/smoothmedia/Funny_Video.ism/ --vidx ask --manifest http://manifest.smooth.com/smoothmanifests/Funny_Video.ism/My_strange_manifest
Usage for csm manifests:
php smthplayer.php --csm <CSM> --vidx <INDEX_NUMBER|'ask'|'adaptive'> --clip <CLIP_NUMBER|'ask'>
This syntax is similar to that used for ism manifests. The '--csm' option replaces the '--ism' one, and the argument for this option
is the url of the manifest with the '.csm' at the end. You have also to specify the index of the clip by using the '--clip' option.
The argument for this option must be a number (from 0 that indicates the first clip to a maximum number depending on the manifest),
or the word 'ask', that makes the program asking you for clip number after showing you the available clips. Examples:
php smthplayer.php --csm http://localhost/mycustommanifest.csm --vidx ask --clip ask (Ask for clip and bitrate)
php smthplayer.php --csm http://localhost/mycustommanifest.csm --vidx 2 --clip ask (Ask for clip and use index 2 bitrate)
php smthplayer.php --csm http://localhost/mycustommanifest.csm --clip 2 --vidx 0 (Play 3rd clip and use index 0 bitrate)
php smthplayer.php --csm http://localhost/mycustommanifest.csm --clip ask --vidx 0 (Ask for clip and use index 0 bitrate)
You can also pass extra options to the program:
--buffer <BUFFER> Starts SMTHPlayer with the value you give as $buffer_time
--delay <DELAY> Starts SMTHPlayer with the value you give as $init_delay
For non-live streams, this starts the video from a time (in seconds) equal to 2*<DELAY>
--fs Starts MPlayer in fullscreen mode if not set by default
--nosync Doesn't sync timestamps with the server. Useful for csm manifests
--vc <V_CODEC> Forces MPlayer video codec with that you give
--ac <A_CODEC> Forces MPlayer audio codec with that you give
-------------------------
KNOWN ISSUES
-------------------------
- If on Windows while I'm playing a stream I start another stream at the same time, the playback of the 2nd stream doesn't start.
> Windows is a problematic OS. Simply use the playfile to start the 2nd stream playback until I solve this problem.
- After a few seconds mplayer crashes or I cannot anymore heard anything.
> Mplayer currently doesn't support growing files. Simply restart the player using the playfile.
If you are interested to test a patch for this, go to <http://patches.libav.org/patch/14430/>
- If I go fullscreen when I play a H.264 adaptive streaming, Mplayer returns in windowed mode when video quality changes.
> Sorry, it's a known bug of Mplayer. If you want a fullscreen video playback add "-fs" to mplayer options to start it in fullscreen mode.
Note that then, if you switch from fullscreen to windowed mode, Mplayer will return fullscreen on the next change of quality.
On linux, there is another solution. Simply create a shortcut to go fullscreen and use it to go fullscreen on Mplayer.
Ubuntu users can follow this simple guide: <http://grok.lsu.edu/Article.aspx?articleid=12663> (note that you can create the same shortcut
in compiz, too).
In the example above, the shortcut is "Alt+F", so use "Alt+F" to go fullscreen in Mplayer instead of "f".
This is the best solution in my opinion.
- If I play an adaptive stream, sometimes there is an A/V desync.
> Sorry, there is no solution for this. Use "-" and "+" keys to correct sync.
- The video doesn't start and I get an error about fps on command line, or video starts but it's too fast.
> Mplayer can't get a fps value. You have to force fps by passing an extra option to mplayer: "-fps 24".
You can change the value of the fps as you want, for example to 25 or 23,97.
-----------
NOTES
-----------
From v0.6, SMTHPlayer has a built-in function that remove temporary files if CTRL+C is pressed.
I've had to disable this function on Windows because it's not supported properly by the OS (see commented lines in the code).