CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Jun 2011
    Posts
    35

    Streaming video to several clients

    Hello folks!

    I am planning on building a site which streams video to clients. Imagine a simple HTML page with a flash video embedded on it. So far so good, appears to be just some flash movie embedded in a plain html page.

    Now, let's assume the video I'd like to stream has a length of 10 minutes.

    The video should be played no watter if anyone is connected or not. The stream should shared by everyone.

    This means that if user1 joins right off the start he'll watch the video from 0:00 to 10:00. A user that joins 5 minutes after the video was streamed he'll only catch the last five minutes.

    Somehow the server should trigger the streaming process and when a user joins he/she'll have missed the parts of the video already streamed.

    It should be like a cinema. The video starts at 9:00 GMT. If you're late, you'll have missed the beginning.




    Now my question is: How would I do this? I've never worked with a multi-tier-streaming(like Youtube). How can clients (which are in no way related) share the same stream?


    The technologies of choice were PHP, *SQL, and flash/html5.


    I'm open to any suggestions or questions.


    Thanks,

    Laurent

  2. #2
    Join Date
    Jun 2011
    Posts
    35

    Re: Streaming video to several clients

    Hey guys -

    I'm really just looking for a hunch here. Don't be afraid to throw me a bone because as of right know I cannot see any way of doing this - even though it has already been done (see http://www.vokle.com/).

    Thanks

    Laurent

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Streaming video to several clients

    What is the design goal you are trying to achieve here? (Or more bluntly: why would your users want that?) Without doing something extremely complicated, you're not going to save on bandwidth by having them 'share' a stream; you'll still be sending the bits - individually - to each connected user. Why not just record the content you want to show as a flash video and get an in-browser player to display it so any user can watch the whole thing? Don't try to make the internet be like TV for no compelling reason.

    If you absolutely must have the video start partway through, why not just set the starting position of the video (probably by a parameter to the player) to <CURRENT_TIME> - <START_TIME>?

    Sure, that won't prevent someone who really wants to view the file in it's entirety from just changing the parameter to play from the beginning, but you're not going to defeat users who want to do that without doing something very complicated. The solution I propose will work for most users, I think.

    Good luck. Unless it turns out you want to use the internet like TV without a compelling reason. In which case, bad luck. :-)
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #4
    Join Date
    Jun 2011
    Posts
    35

    Re: Streaming video to several clients

    Hello,

    The main goal was to have a constant flow of video recorded "live" and streamed to whomever is connected to a given page. From an architectural POV this is most definitely feasible but I cannot see it implemented with the tools I have (PHP, Flash, JS and HTML).

    I came to the conclusion (just as you stated) to give the illusion of a live stream, which is far easier to implement.

    I have one question though - what is so wrong with "making internet like tv" ? There are already sites that offer tv-like service (such as vokle.com). Why do you think it is a bad idea?

    Thanks for participating
    Laurent

  5. #5
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Streaming video to several clients

    Well, I guess it is a general bias that programs should be structured so as to be maximally convenient to humans if it takes no additional effort to implement. With TV, it initially started out that the fact that it needed to be transmitted through the air imposed a technical limitation which prevented on-demand streaming of information. The internet does not have this limitation because - even though many people may receive the same information from one person - there is still an individual transmission open for each individual (unless you do some complicated peer-to-peer stuff, but that's beyond the scope here). Thus there is no technical reason (usually) to require only live feeds to be available so it seems like poor design to only send users part of a file they would like to receive. (You wouldn't, for example, send only part the last half of a text file after some arbitrary point in time; you'd send the entire file to a user who requested it).
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  6. #6
    Join Date
    Jun 2011
    Posts
    35

    Re: Streaming video to several clients

    Yes you're right, TV works the way it works because at the time it was the best they could do. A stream per file was simply not feasible.

    I had another solution in mind which would basically be a service script to which the clients' players would connect returning a binary video stream. This service would then hack a local video file into pieces so that the video file starts at time X, and would then fix and return the file so that the clients' player can interpret the stream. I know that there are ways of doing this with php and I also know that anything beyond re-sizing an image with PHP is just overkill and takes huge amounts of time. Still I guess that this would come closest to what I wanted to do.

    What do you think of that?

    Thanks

    Laurent

  7. #7
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Streaming video to several clients

    I think the solution you proposed might be a bit overkill and too intensive on the server side. What I think you really need is just an embeddable player that you can set to start your target video file at time X with a parameter. I think this is called "pseudostreaming", if you want to Google it some.

    Why not have a look at Flowplayer? It's an open source video player that looks like it will support what you want. In particular, the tutorial on pseudostreaming (link) sounds highly relevant to your target goal.

    There might be better solutions, but I didn't see any in my brief search. You might try reading the HTML of your favorite video-streaming website to see if you can figure out which (open-source, hopefully) player they chose. Whatever they chose might be a good solution for you as well.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  8. #8
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Streaming video to several clients

    JWPlayer also looks solid: http://www.longtailvideo.com/players/jw-flv-player/

    It supports pseudostreaming and starting partway through the video: http://www.longtailvideo.com/support...ration-options

    The website/documentation is a little less intimidating too... (to my eye anyway)
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Streaming video to several clients

    Windows Server 2008 R2 lets you encode data streams in a bunch of different compression levels, allowing those with a good connection to receive HD/Dolby 5.1. Server auto-switches on the fly...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Jun 2011
    Posts
    35

    Re: Streaming video to several clients

    Hiya

    @BioPhysEngr Thanks for the research - I'd already found JWPlayer and actually read that it supported seeking to a timestamp within the video which is actually one of the solutions to the problem. Personally though I don't find this solution very nice, I'd prefer having the server manage the stream but as you said this is definitely overkill with the technologies I have at my disposal.
    I've not tried JWPlayer myself but the documentation suggests that the with the requirements described in my OP are easily implementable with this player.

    @dglienna Thank you for joining the discussion. Unfortunately I don't have Windows Server available in this scenario. It's great to know though that the solution I pointed out here above can be realized using .NET. It's a shame that there is no opensource video management framework for PHP as this would totally rock my world (assuming that performance wise it would not suck the life out of the server). This being said I believe that somewhere in the infinte lengths of the WWW there is a somebody working on exactly this feature. Fingers crossed.

    Thanks guys

    Laurent

  11. #11
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Streaming video to several clients

    Well if you absolutely must have the server control the stream, what you could do is pre-process (once, you doing it - not in PHP on every page load) the file into N chunks each of which contains the contents of the file from partway through the file until the end. Then you can use the client JWPlayer code to fine-tune the exact starting point within the stream. If you absolutely had to (though I have argued against it), you could even make the earlier N-1 files inaccessible after the N'th becomes available.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  12. #12
    Join Date
    Jun 2011
    Posts
    35

    Re: Streaming video to several clients

    Thanks for pointing that out! I also had something similar in mind.
    Instead of loading a big file of say 2hrs to the server load chunks of the movie (of say 1 minute each -> 120 files) to the server, then use php to find the appropriate file to start on (if the "streaming" is ought to have started X-30 minutes ago, start with chunk 30).

    Something I'm not entirely sure about is how the player would harmonize with this kind of strategy. Would it start rebuffering after each minute/chunk? Or will it keep polling the php script and therefore prefetch the binary of the next chunk? Would the php script have to modify the header information of each chunk so as to have a continuous stream (continuous file stream [1 header per stream] or several sequential file streams [one header per chunk/file]).

    The idea of creating chunks instead of having one huge file may make the idea of "live streaming" sound much easier but I'm not sure if this is truly the case. I believe that the JWPlayer will simple buffer the contents of the current chunk N and then play it (and not automatically start buffering the following chunk, i.e. the script will only invoke the php script once).

    Did I understand your suggest correctly?

    Thank you once again for your input,

    Laurent

  13. #13
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Streaming video to several clients

    You might want to look at Microsoft Cloud Solution: Windows Azure. Also, Windows 8...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured