spacer
spacer search

SwissCenter

Search
spacer
Main Menu
Home
Documentation + FAQ
Screenshots
Downloads
Forums
Bug Tracking
History
Login
Username

Password

Remember me
?
No account yet?

Locations of visitors to this page

 
Home arrow Forums

SwissCenter Forums  


Resume without Simese - 2006/05/15 11:54 What functionality does Resume require which ties it to Simese?

I'm running SwissCenter on a WAMP setup, so I could move over to Simese, but I'll likely move to Linux at some point. So I'd like to make this work under Apache unless there's a good reason not to.
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 12:07 The resume feature is limited to Simese because the webserver needs to record the last point of the file that was sent down to the showcenter. Simese does this, but I have no idea how to get apache to do it

If you can think of a way, then let me know!!!
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 13:27 admin wrote:
The resume feature is limited to Simese because the webserver needs to record the last point of the file that was sent down to the showcenter. Simese does this, but I have no idea how to get apache to do it


How does Simese do this? (Bear in mind I don't have Simese installed and ideally would like to avoid installing it.) If you can point me to the relevant SC code I'd appreciate it (I can see where the bookmark is read but not where/how it's created, and I'm only assuming that bookmarks is what I should be looking at).

If you can think of a way, then let me know!!!

My first thought was to not use the redirect to a "real" file path, as SC currently does, but instead to fopen the file, send the data from the file in "chunks", and record the point at which the HTTP connection gets killed. Having played a bit with that I've failed to get the file to send properly due to buffering issues (it reads the whole file into PHP then sends the whole file no matter what I do with output buffering, flush(), closing sessions, etc). Assuming I can get that to work, though, I should know within PHP exactly how much of the file has been sent.
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 13:59 hollymcr wrote:

Having played a bit with that I've failed to get the file to send properly due to buffering issues (it reads the whole file into PHP then sends the whole file no matter what I do with output buffering, flush(), closing sessions, etc). Assuming I can get that to work, though, I should know within PHP exactly how much of the file has been sent.


I've now got past this problem. For some reason, at the end of stream.php the script is in three levels of output buffing. Not sure why, but replace the following code:
Code:

    require_once( realpath(dirname(__FILE__).'/base/page.php'));



with:
Code:

    echo "Output buffering level is ".ob_get_level()."\r\n";   require_once( realpath(dirname(__FILE__).'/base/page.php'));   echo "Output buffering level is ".ob_get_level()."\r\n";   die;



.. at the top of stream.php to see that this is the case (I haven't debugged this any further).

So, if I remove that debug code and instead replace:
Code:

    header ("HTTP/1.0 307 Temporary redirect");   header ("location: ".$server.$redirect_url);



.. with:
Code:

    header ("Content-Type: audio/mpeg");   while(ob_get_level()) ob_end_flush();   $fh=fopen($location'rb');   while(($fbuf=fgets($fh,2048)) !== FALSE) {     echo $fbuf;     flush();   }   fclose($fh);



.. at the bottom of stream.php, the streamed file now gets sent through the web server instead of using the redirect.
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 14:05 Update:

Assuming you add a "bookmark" (int, allow NULL) field to each media table, the following replacement code updates the database with the number of bytes of the media file sent to the browser when last played:

Code:

    // This line need modifying to send the correct type   header ("Content-Type: audio/mpeg");   // Close as many levels of output buffering as necessary!   while(ob_get_level()) ob_end_flush();   // Don't abort the script if the connection is closed, or for timeout   ignore_user_abort(TRUE);   set_time_limit(0);   // Open the file in binary mode   $fh=fopen($location'rb');   $bookmark 0;   // Loop: While connection open and still got some file to send,    // read 2048 bytes and send it   while( (connection_status()==0) && (($fbuf=fgets($fh,2048)) !== FALSE) ) {     $bookmark += strlen($fbuf);     echo $fbuf;     flush();     db_sqlcommand("update LOW_PRIORITY $table set bookmark = $bookmark where file_id=$file_id");   }   // If we reached end of file, reset bookmark to NULL in database   if (feof($fh)) $bookmark "NULL";   fclose($fh);   // Update Db with bookmark value   db_sqlcommand("update $table set bookmark = $bookmark where file_id=$file_id");



Note that the header line is a bodge and needs customising to the correct type of media. The rest should be pretty much all thats needed.

Edit: Added set_time_out() and DB update inside loop
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 14:21 Useful feature of this method: If I browse SwissCenter with IE of Firefox, and listen to music with WinAmp (ie download the playlist file into WinAmp) it no longer gives up on the redirect, which it used to do before. Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 15:19 Good work... I tried to use fpassthru() to do this kind of thing a while back, but I kept managing to crash the server and showcenter, so gave up on it.

Of course... if you can get it running smoothly within PHP then that would be fantastic

For testing purposes, you need to see if your code can cope with the user pressing the 0-9 buttons to jump to a particular point, and whether or not FF, RW work correctly.

Rob
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/15 16:15 admin wrote:
Good work... I tried to use fpassthru() to do this kind of thing a while back, but I kept managing to crash the server and showcenter, so gave up on it.


I assume this was Simese?

If so I could do with someone testing the hack above and seeing if it crashes Simese. It would be nice to end up with a portable solution! AFAIK ignore_user_abort is not Apache-specific?

Of course... if you can get it running smoothly within PHP then that would be fantastic


Well, so far so good!

It would help to know how things currently work (I'll probably have to give in and install Simese, but even then I'm not sure that'll tell me what is going on).


For testing purposes, you need to see if your code can cope with the user pressing the 0-9 buttons to jump to a particular point, and whether or not FF, RW work correctly.


I think the starting point would be to modify stream.php to support the HTTP "range" request, which ought to be straightforward. I guess that's how the players currently work with FF. Is there a spec somewhere for how the hardware players interact with the webserver? What is the "Resume" request that's used in gen_playlist.php?
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/05/16 17:09 hollymcr wrote:

Well, so far so good!


Right, well it seems to work but is going to need some tidying up as well as some testing on Simese.

Is anyone here reading this prepared to try some experiments? I have basically two changed files which should be drop in replacements for the current beta (and drop-out again if they break anything , plus an extra field needed to store bookmark position in the relevent DB tables (again easily removed after tests).

On my system here I am able to skip forward but buttons 0-9 aren't apparantly mapped to anything (my player is an LVD-2010 and I don't think that's ever worked for me, but if I can get Simese installed on a test PC I'll check).

<LATER...>
It seems that the changes work just fine on Simese, so this appears to work just as well as the old Simese-only code but without the Simese-only limitation. Except that my testing doesn't go very far as I don't have a very capable player, so I need help to take this further!

So I have attached my changed files, plus the necessary SQL changes. This is for people happy with running SQL queries manually and prepared to break their SwissCenter - be warned!

<EVEN LATER...>
I seem to have broken the option to upload a file, so suggestions welcome
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/06/19 10:30 May I join the thread?

This sounds extremely promising. I posted a thread about this topic a few months back and was going to try and tackle the problem myself. But real-life keeps stopping me finding the time.

But now you sound like there's really something to work with, albeit early and possibly imperfect, I'll throw in whatever effort I can too.

I'd love to test and help further with this. Do please let me know the change to code, etc and I'll join in with you.

FYI: am running SwissCenter on a Buffalo Linkstation (so Linux) with Apache/PHP5. At the other end is a Pinnacle Showcenter1000. Since I've not yet switched fully to SwissCenter I've no worries about dodgy code or messing up my database.

Sean
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/06/27 18:11 sgroarke wrote:

I'd love to test and help further with this. Do please let me know the change to code, etc and I'll join in with you.


Sorry I was so slow replying to this.

I haven't really had time to look at it since I last posted here, and lack of good test hardware had reduced my motive to continue with it (unless it was actually worthwhile I couldn't seem much point continuing, and without some help testing I couldn't work out if it were worthwhile). So your interest is certainly welcomed!

I'll try again to attach a file with my mods. If that works, take a look and let me know how you get on; if it doesn't then suggestions welcomed, but I could probably stick them on a website somewhere and post a link.
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/06/27 18:14 Attachement 1: stream.php
File Attachment:
File name: stream.php.txt
File size:5104 bytes
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/06/27 18:15 Attachment 2: gen_playlist.php

Also: you'll need the following SQL mods:
Code:

  ALTER TABLE `mp3sADD `bookmarkBIGINT NULL; ALTER TABLE `moviesADD `bookmarkBIGINT NULL;

File Attachment:
File name: gen_playlist.php.txt
File size:4127 bytes
Player : Lite-On LVD-2010 (wired ethernet)
Server : Apache2/PHP5 on Win2k running on Athlon XP, 1Gb RAM, 1 Tb storage.
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/09/17 02:58 I would be interested in helping testing, Has any of this gone in to the new 1.15 code and are the patches compatable.

Serverr: Linux Centos
Client: BLT
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/09/17 05:18 Hollymcr,

Apologies... somehow I completely lost track of this thread. It must have been while I was trying to organize lots of wedding plans! lol.

I'm very very interested in getting PHP to handle the resume feature as I actually use SwissCenter on an APache installation under SuSE Linux. I'm going to have a play with the files you uploaded and incorporate them asap.

Many many thanks for your efforts so far!

Rob
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/09/17 10:08 Hollymcr,

I've incorporated your code into stream.php against version 1.15.1 and done some testing. I haven't implemented the resume feature yet - I'm just concentrating on the streaming iteself, and I've come up with a couple of problems on linus machines:

1. When I try to stream a file that is > 2Gb, the showcenter reports that the video is an "Encrypted MPEG".. which it's not, and it refuses to play it.

2. When streaming music, the showcenter does not make a request fot the "Now Playing" screen.

Attached is the "stream.php" for use with the 1.15.1 release, could you test against that please?

many thanks

Rob
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/09/17 10:11 Rename to "stream.php":

File Attachment:
File name: stream.1.15.1.txt
File size:10024 bytes
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re:Resume without Simese - 2006/09/18 11:47 Hi

Have you checked out this:
http://pear.php.net/package/HTTP_Download

It may be just what you are looking for. I have already used the pear downloader in a project and am happy with it!

greetings,
Michael
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/04/13 23:08 So any news about this functionality? I'm using the latest 1.20 from main trunk and it's not implemented for Apache. What was the latest update? Can I pickup development of this feature from the point where it was left?

--Vlad
Player: BLT Linktheater DVD
Server: SwissCenter 1.20 on Windows+Apache2+PHP5
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/03 18:34 I have been looking at this, at least to understand the playback side so I can test to see if any changes I make work...

I have installed simese to help me understand.

So simese writes a file ( whos filename depends on the md5 of the original filename ) out to a location which has a 2 digit number which represents the % though the media we are.

On my Buffalo link theater when I try and resume with simese I get a message saying I trying to view an encrypted mpeg file.

When I use simple tools to cut the file I observe the following.

1) When I just cut the head off an avi I get the same message as I do for resume.

2) When I append about 20-30K of the head of the media file the BLT is happy to play the media file from the "correct" place

comment ?
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/06 18:31 Having a quick look at this:

Code:

  /var/www/swiss/gen_playlist.php 192.168.11.92 /gen_playlist.php 530 /var/www/swiss/media/21/Yu-Gi-Oh/5x02 Unwanted Guest (2).avi 192.168.11.92 /media/21/Yu-Gi-Oh/5x02 Unwanted Guest (2).avi X 192523184



I can see that this was viewed 95%, the X shows that it was stopped early.

ls -l "/var/www/swiss/media/21/Yu-Gi-Oh/5x02 - Unwanted Guest (2).avi"

(192523184*100)/201132720=95

Where this will have issues is where rewind or fast forward is used, does Siamese handle this well ?
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/07 08:27 Simese records the percentage as the info is streamed, so if you skip around then the percentage will still accurately record where you were in the file.

On my Buffalo link theater when I try and resume with simese I get a message saying I trying to view an encrypted mpeg file.

It may be that the Buffalo firmware doesn't support resuming.

2) When I append about 20-30K of the head of the media file the BLT is happy to play the media file from the "correct" place

Thats because you've left the video header (with bitrate, etc) intact and simply cut out a lot of actual movie data. Doing this isn't really an option because you'd have to understand the file format for each codec to ensure that the header is left intact.

I can see that this was viewed 95%, the X shows that it was stopped early.
ls -l "/var/www/swiss/media/21/Yu-Gi-Oh/5x02 - Unwanted Guest (2).avi"
(192523184*100)/201132720=95


That's useful - is it just the infor from the apache access log?

Where this will have issues is where rewind or fast forward is used

In theory, if you ff, rw or skip within the movie then you might get multiple accesses logged. You could then just use the latest.

Rob
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/07 12:26 admin wrote:
Simese records the percentage as the info is streamed, so if you skip around then the percentage will still accurately record where you were in the file.

On my Buffalo link theater when I try and resume with simese I get a message saying I trying to view an encrypted mpeg file.

It may be that the Buffalo firmware doesn't support resuming.

2) When I append about 20-30K of the head of the media file the BLT is happy to play the media file from the "correct" place

Thats because you've left the video header (with bitrate, etc) intact and simply cut out a lot of actual movie data. Doing this isn't really an option because you'd have to understand the file format for each codec to ensure that the header is left intact.

I can see that this was viewed 95%, the X shows that it was stopped early.
ls -l "/var/www/swiss/media/21/Yu-Gi-Oh/5x02 - Unwanted Guest (2).avi"
(192523184*100)/201132720=95


That's useful - is it just the infor from the apache access log?

Where this will have issues is where rewind or fast forward is used

In theory, if you ff, rw or skip within the movie then you might get multiple accesses logged. You could then just use the latest.

Rob


What you get in the log is the number of bytes sent. If you record the Range header we get something more useful. Range is where we start and the 3rd argument is the data sent.

/var/www/swiss/media/21/Yu-Gi-Oh/5x02 - Unwanted Guest (2).avi 192.168.11.232 /media/21/Yu-Gi-Oh/5x02 - Unwanted Guest
(2).avi X 188533102 range-bytes=5421078-
/var/www/swiss/media/21/Yu-Gi-Oh/5x02 - Unwanted Guest (2).avi 192.168.11.232 /media/21/Yu-Gi-Oh/5x02 - Unwanted Guest
(2).avi X 188227678 range-bytes=6132006-

/var/www/swiss/media/21/Yu-Gi-Oh/3x05 - Freeze Play (1).avi 192.168.11.92 /media/21/Yu-Gi-Oh/3x05 - Freeze Play (1).av
i - 122007896 range-bytes=0-

( you can see what the children are watching... ).

This is the thing I add to apache. Note you need support for logio to use %O( its in by default under debian )

CustomLog /var/log/apache2/swiss-real.log "%f %h %U %X %O range-%{range}i"

We could use a pipe and output it to a program which could give you exactly the same functionality as simese or would you prefer to parse the log in php ?

Do you want me to write some proof of concept code ? and if so which language would you like it done in ?

Also If my firmware doesn't support resume what do you feel about my hack to get playback working ? ( What percentage of people have firmware that supports resume and how many don't ? ).
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/08 14:13 To be honest, it's probably more effort than it's worth - especially if your player doesn't support resume (I don't know which players do, I only have a Showcenter 200).

One simple trick that I used to use back when I had SwissCenter installed on a headless linux server was simply to press the "right" arrow before turning off a moie to see what percentage was shown on the screen.

I'd simply remember that for when I wanted to watch the rest (eg: for 54%, I'd start the movie and press "5" to jump to 50% and then "right" four times to get to 54%).

The "Hack" you mention doesn't work very well as we'd have to do the streaming via PHP. I've experimented with this in the past and it seams to be very unstable for large files (often crashing the player, and sometimes locking up the server as well).

Feel free to play around in the "Stream.php" file though if you'd like to see if streaming via PHP can be made stable. If it can, then we can simply record the bytes sent to the player without requiring the webserver (apache or simese) to do it.

Rob
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/08 17:40 admin wrote:

I'd simply remember that for when I wanted to watch the rest (eg: for 54%, I'd start the movie and press "5" to jump to 50% and then "right" four times to get to 54%).

The "Hack" you mention doesn't work very well as we'd have to do the streaming via PHP. I've experimented with this in the past and it seams to be very unstable for large files (often crashing the player, and sometimes locking up the server as well).

Feel free to play around in the "Stream.php" file though if you'd like to see if streaming via PHP can be made stable. If it can, then we can simply record the bytes sent to the player without requiring the webserver (apache or simese) to do it.

Rob


The firmware I have doesn't let me jump to 10%, given I have some files which you can't fast forward in this is a right pain.

Looking at the php the think that I suspect is wrong although i am not a php expert is the use of echo instead of fwrite. As fread returns a binary chunk which may have NULLS in it and I would suspect strlen to return the wrong thing tm.

Also "magic quotes" needs to be disabled.
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/09 09:18 I would also think about using

$fbytessofar = ftell ($fh)

instead of

$fbytessofar += strlen($fbuf);

If you can give me a hint about how to make it use stream.php instead of apache then I will play.
--
Server: Debian 4.0, Ram: 3 gig , Disc : 5 TB
Client: Buffalo LinkTheatre, dLAN 200 AV
MySQL 5.0.32-Debian_7etch1-log
  | | The administrator has disabled public write access.
Re: Resume without Simese - 2008/09/09 14:39 OK, some tips on modifying stream.php to stream movies in PHP:

In SwissCenter, all media files are requested via the Stream.php file. It is broken down into the following structure:

Code:

   if ( in_array(strtolower($req_ext),$subtitles) )   {     // The player has requested the subtitles for the movie      // (the type can be determined by examining the $req_ext variable)   }   elseif (!is_readable($location))   {     // If the file is unreadable (wrong permissions) then send a message     // to the log.   }   elseif ($media == 1//music   {     // Streams the mp3 file via the stream_file() function   }   elseif ($media == 2//photos   {     // Loads, scales, rotates and outputs images that are part of a slideshow   }   else   {     // All other types     // Send a "Redirect" response to the player and give the locations      // as the actual file on disk.   }



Simply add a section which tests for "$media == 3" (movies) and stream the file. You'll need to send the appropriate headers before calling stream_file().

Note 1 - most of your changes will probably need to be in stream_file()

Note 2 - You might want to comment out the section which outputs subtitles to being with and concentrate on the streaming the movie. If the subtitles are not sent correctly then the movie does not play... I never did get that working.

You'll need to test all combinations of movies with/without subtitles and the player's subtitles setting on/off.
Player : Pinnacle Showcenter 200 and 1000 (wired ethernet)
Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.

  | | The administrator has disabled public write access.
spacer
 

Screenshots

www.flickr.com
This is a Flickr badge showing public photos from swisscenter. Make your own badge here.


 

Mambo is Free Software released under the GNU/GPL License.
spacer