Skip navigation
Currently Being Moderated

publish externel live source with multicast

Apr 14, 2011 8:07 AM

hello

 

first i can not use fmle to broadcast the stream i need to publish from an externel source (like on an linux server)

 

first i have an working app with attachAudio and attachCamara this works greate BUT

i need other sources (Video file with h264 codes in flv container like fmle do it)

 

so i make some tests first i load a flv file with URLStream from an http push server like vlc do it

 

in the PROGRESS event

i do

 

private function urlStreamProgress(event:ProgressEvent):void

{

if (event.target.bytesAvailable >= 60000) {

    var encr:ByteArray = new ByteArray();

        event.target.readBytes(encr);

 

        netStream.send("onStreamData", encr,i);

        ns.appendBytes(encr);

        i++;

    }   

}

 

the netStream is the outgoing stream an will published with

netStream.publish("stream");

 

the ns stream is the video player netstream in play(null) status and attached the video

the video plays fine on the broadcaster

 

so on clients

i have an netstream with netstream.play("stream");

and a second ns for the video play (ns.play(null) mode)

 

on the send onStreamData event i do

 

var clientObj:Object = new Object();

clientObj.onStreamData = function(file:ByteArray,i:int):void{

                                                StatusMessage("Received "+file.bytesAvailable+ " " + i + "\n");

                                                StatusMessage("ns bytesTotal "+ns.bytesTotal+  "\n");

                                                StatusMessage("ns bytesLoaded "+ns.bytesLoaded+ "\n");

                                                ns.appendBytes(file);

 

 

     

}

on the client i see i get lot of packages in NetStream all works fine
Download speed: 1.17 Mbit/s ( 142.67 KB/s )
Upload speed: 0 ( 0 )
Total Bytes Pushed From/To Peers: 436.89 KB / 0
Total Bytes Requested From Peers: 1.03 MB
but my ns netStream i empty and no video is shown :-/
ns bytesTotal 0
ns bytesLoaded 0
Received 62264 4872
ns bytesTotal 0
ns bytesLoaded 0
any idea whats wrong ?
the other question is  when i use send is the network multicast send send to all clients i think?
what is the best practice to broadcast an live stream from an external source?
best regards
whwi

 
Replies
  • Currently Being Moderated
    Apr 14, 2011 4:29 PM   in reply to whwi999

    the problem is a P2P multicast isn't 100% reliable (you can occasionally miss pieces), and late joiners won't necessarily get the beginning of a stream.  this is a problem because NetStream.appendBytes() requires a *perfect* FLV to be input.

     

    if you miss the very first message of the multicast, you'll miss (among other things) the FLV header.  if you miss *any* message of the multicast, you'll at least be out-of-sync.

     

    also, in an FLV with H.264 video and AAC audio, you'll only have the H.264 AVCC and AAC AudioSpecificConfig messages once at the very beginning of the FLV.  so if you miss those messages, the H.264 and AAC won't be decodable even if you somehow otherwise stayed in sync adding FLV tags into appendBytes.

     

    this means you can't simply get data directly out of a multicast and send it into appendBytes.  you're guaranteed to go out-of-sync, and the appendBytes FLV parser won't be able to work anymore.

     

    you'll need to do more work if you want to use appendBytes like this, in particular by being able to recover whole FLV tags, and by resending AVCC and AudioSpecificConfig messages from time to time for the late joiners.  and you'll need to make sure that when you're putting bytes into appendBytes that you don't get out of FLV tag sync.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 15, 2011 10:40 AM   in reply to whwi999

    at this time Flash Player does not have H.264 or AAC *encoders*, so Flash Player can't publish a multicast using those codecs.

     

    FMLE doesn't directly publish a multicast either; it publishes a unicast stream to an FMS 4 Enterprise server, which then republishes the stream as a multicast (P2P, IP multicast, or combined "multicast fusion").  there is no "voodoo"; that is a selling feature of FMS.

     

    FMS 4 Developer Edition is free for development use and will allow you to publish a P2P multicast in the manner i've described.  IP multicast (and therefore multicast fusion) is limited to 10 minutes.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2011 10:20 AM   in reply to whwi999

    while i don't know of any specifically, i'm sure there are tools that run on Linux that can publish a stream over RTMP to FMS, even taking that stream from a file.  you might try the FMS forum for pointers on something like that.

     

    also i'm not an expert on FMS server-side programming; it might be possible to get FMS to pull the stream in and publish it as a multicast.  again, i'd ask for help in the FMS forum.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2011 11:11 AM   in reply to whwi999

    we already covered this earlier in the thread.

     

    if you want to publish the contents of an external file as a live stream from a client, then you will need to do a lot of extra work, as that's not a directly supported mode.

     

    you can publish a P2P multicast stream from any client, read and parse the FLV file, and using timers and NetStream.send(), push FLV tags one at a time into the multicast stream at the right time.  you will need to repeat H.264 AVCC frames and AAC AudioSpecificConfig frames periodically for the late joiners.  subscribers can subscribe to the multicast stream, receive the NetStream.send() data, recover the FLV tags, and send them into an appendBytes-mode NetStream for display.

     

    alternatively you could use object replication to distribute the data, and appendBytes to display it.  object replication blocks can come in out-of-order so you'll have to do some work to make sure you wait for enough in-order data to arrive to have an uninterrupted playback.  this is how you'd want to do it if you wanted the experience to be more "video on demand"-y, where people could start watching at any time instead of everyone watching the same live stream at the same point.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2011 12:44 AM   in reply to Michael Thornburgh

    Hi,

     

    Do i still need to send out FLV tags and AVCC constantly if the source is from HttpStream (via FMS livepkgr) ?

    I use the code in OSMF to load a .f4m and hijack ByteArrays from HttpNetStream.

    However, nothing shows up when i appendBytes to a netstream in data generation mode.

     

    Perhaps i need to mock a FLV header and append it first?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2011 10:30 AM   in reply to shooding2011

    you must start out an appendBytes NetStream with an FLV header.

     

    while you don't say, i'm assuming from context that you're capturing FLV data from HTTPNetStream and putting it into a P2P multicast with NetStream.send().

     

    note that HTTPNetStream, when it finally gets to doing appendBytes, might or might not be appending complete FLV tags or starting/stopping on tag boundaries. just taking that data and sending it somewhere else will be very sensitive to any pieces missing. also, HTTPNetStream will, when it's humming along, be sending very large chunks of data (potentially several seconds worth) into appendBytes. if you want to send this through NetStream.send(), you should be breaking the data up into individual FLV tags and metering them into the multicast stream according to tag timestamp (potentially allowing for video and audio tags not being smoothly interleaved) to avoid major bursts in the P2P mesh.

     

    HTTPNetStream won't be resending AVCC/AudioSpecConfig messages into appendBytes, so you would still need to re-send those from time to time into the P2P multicast so late joiners can recover them. any one client just needs them once (assuming the AVC or AAC parameters don't change), but you don't know when clients will join.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 1:53 AM   in reply to Michael Thornburgh

    Like you said. But before sending data out, i tried to playout at the first peer to make sure this is working (without considering sensitive to packet loss)

    While tracing HTTPNetStream.as and f4v file format, inside the code,

     

    bytes = fileHandler.processFileSegment(input);

     

    i got several times 0 bytes before 'mdat'

    HTTPStreamingState.PLAY: processFileSegment, content=

    HTTPStreamingState.PLAY: processFileSegment, content=

    HTTPStreamingState.PLAY: processFileSegment, content=

    HTTPStreamingState.PLAY: processFileSegment, content=

    HTTPStreamingState.PLAY: processFileSegment, content=09000043aa0aba630000001700000000014d001503010...

     

    Compare to livestream1Seg1.f4f, F4F has ftyp='f4v'

    but HTTPNetStream is appending an FLVHeader = 464c5601050000000900000000

    I wonder if appending this FLVHeader followed by mdat bytes is even playable by flash.media.Video??

    Should i append F4V header first, then Fragments{afra abst moof mdat}?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 9:07 AM   in reply to shooding2011

    NetStream.appendBytes() *only* understands FLV. appendBytes() doesn't understand any other formats at this time. OSMF converts F4V to FLV in ActionScript and sends those bytes into appendBytes().

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 30, 2011 1:37 PM   in reply to Michael Thornburgh

    Hi,

    I know this post is sort of old. But can someone answer this question for me? If I just want to get the client to publish a local flv file to Flash Media Server...

     

    Since .appendBytes throws me errors if I try to do it on Flash Media Server, should I have it do .send() to the FMS? And then on FMS would I do appendBytes? Basically I am just trying to find out how to         stream a local FLV file to Flash Media Server!!   

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points