14 Replies Latest reply on Aug 4, 2016 5:57 PM by mint4pcm40991987

    publish externel live source with multicast

    whwi999

      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

        • 1. Re: publish externel live source with multicast
          Michael Thornburgh Adobe Employee

          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.

          • 2. Re: publish externel live source with multicast
            whwi999 Level 1

            thank you for clarify the appendBytes Problem

             

            i read some source code from omf (httpstreamin)

            http://sourceforge.net/adobe/osmf/svn/2081/tree/osmf/tags/1.6.mid-sprint-2/framework/OSMF/ org/osmf/net/httpstreaming/

            it sould be possible with this solution (write FLV headers generate Tags,..) but maybe i think to complex for my Problem

            so i looked in fmle i can use an video device and convert it to h264 and aac and broadcast to the multicast

            on the client i only need netStream.play("stream") and attach the netStream to the videodisplay all works fine

             

            how fmle do this voodoo? fmle does not use FLV for data transfer?

            when i use an video device on the client with attachCamarea the video is read in raw bgr24 and audio pcm format

            intern the video is convert to the Sorensen codec but this not a solution for me

             

            how can i code the client to broadcast an h264 aac stream to the multicast network

            and on the client i can start the stream with play("stream")

            can you give me an hint to the right direction?

             

            best regards

            • 3. Re: publish externel live source with multicast
              Michael Thornburgh Adobe Employee

              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.

              • 4. Re: publish externel live source with multicast
                whwi999 Level 1

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

                 

                yes ok because that i would like to broadcast an external source with the client (best from an URLStrema source) (i encode the video on an other server in h264 acc)

                is this possible? i need this for our company... it's an live video tv streams for pubs,kaffees,...

                ( for the last tests i use the FMS 4 dev server but no sucess)

                • 5. Re: publish externel live source with multicast
                  whwi999 Level 1

                  the problem is we can not use fmle to stream unicast to the fms 4 server

                  because is#t an linux server

                   

                  so we cannot use Cirrus for our company :-/ right?

                  • 6. Re: publish externel live source with multicast
                    Michael Thornburgh Adobe Employee

                    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.

                    • 7. Re: publish externel live source with multicast
                      whwi999 Level 1

                      hello

                       

                      yes works greate i can publish an rtmp stream to fms4 server and fms republish the the stream multicast to the peers

                       

                      the problem is now i need an central fms4 server  to publish ALL streams

                      and the idea is in p2p that every client can be the publisher

                       

                      so any idea how i can publish (broadcast) the external h264 acc flv file with the client?

                       

                      maybe appendbytes or object replication?  any suggestions ?

                       

                      best regards

                      • 8. Re: publish externel live source with multicast
                        Michael Thornburgh Adobe Employee

                        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.

                        • 9. Re: publish externel live source with multicast
                          shooding2011

                          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?

                          • 10. Re: publish externel live source with multicast
                            Michael Thornburgh Adobe Employee

                            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.

                            • 11. Re: publish externel live source with multicast
                              shooding2011 Level 1

                              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}?

                              • 12. Re: publish externel live source with multicast
                                Michael Thornburgh Adobe Employee

                                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().

                                • 13. Re: publish externel live source with multicast
                                  K2xL.com Level 1

                                  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!!   

                                  • 14. Re: publish externel live source with multicast
                                    mint4pcm40991987

                                    is this solved?
                                    we have the same problem

                                     

                                    1. multicast is setup, and console show it.

                                    ams1.png

                                     

                                    2. bandwidth need 50k more for each connections now

                                     

                                    Thanks.