Skip to main content
Petro_O__Bochan
Inspiring
February 16, 2013
Question

AMS Standard livepkgr FMLE vs Flash Player

  • February 16, 2013
  • 1 reply
  • 1898 views

Hello all, I'm facing a rather odd behaviour when trying to publish a video stream to livepkgr via Flash Player. Here is the code I'm using:

import flash.media.H264Level;
import flash.media.H264Profile;
import flash.media.H264VideoStreamSettings;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.media.Camera;

var cl:Object = new Object();
var hd:H264VideoStreamSettings = new H264VideoStreamSettings();
var cam:Camera = Camera.getCamera();
var nc:NetConnection = new NetConnection();
var ns:NetStream;

function onNc(event:NetStatusEvent):void {
if(event.info.code === 'NetConnection.Connect.Success') {
  nc.call('FCPublish', null, 'livestream');
}
}

cl.onFCPublish = function(event:Object):void {
if(event.code === 'NetStream.Publish.Start') {
  ns = new NetStream(nc);
  ns.attachCamera(cam);
  ns.videoStreamSettings = hd;
  ns.publish('livestream?adbe-live-event=liveevent');
}
}

hd.setProfileLevel(H264Profile.MAIN, H264Level.LEVEL_3_1);
hd.setMode(320, 240, 15);
hd.setQuality(65536, 85);
hd.setKeyFrameInterval(4);

cam.setMode(320, 240, 15);
cam.setQuality(65536, 85);

nc.client = cl;
nc.addEventListener(NetStatusEvent.NET_STATUS, onNc);
nc.connect('rtmp://www.domain.com/livepkgr');

Code for Event.xml:

<Event>

  <EventID>liveevent</EventID>

  <Recording>

    <FragmentDuration>4000</FragmentDuration>

    <SegmentDuration></SegmentDuration>

    <DiskManagementDuration></DiskManagementDuration>

  </Recording>

</Event>

HTTP address for SMP - http://www.domain.com/hds-live/livepkgr/_definst_/liveevent/livestream.f4m

When starting afresh, SMP in debug mode shows fine buffering and FPS. HTTP tracker shows status 200 (which is OK). If I quit FP, 4 seconds later SMP runs out of buffer; the picture freezes, then SMP would periodically issue a 304 status (Not Modified which means that no new data is coming along the track). Problems arise when I re-launch the FP app – in the tracker I still get 304 from SMP although the publish process is in progress. Unless I refresh the SMP window, it still issues that 304 code and the live feed never updates.

On the other hand, FMLE never faces this malfunction. I guess FMLE invokes some supplementary commands (or whatever else it does) to avoid such situation. Moreover, regardless if I quit or stop publishing using FMLE, SMP shows a nice buffering caption, while mere quit of FP doesn’t.

How would I approach such a problem?

This topic has been closed for replies.

1 reply

February 16, 2013

Hi,

With the current code, the publishing will never start from flash as you have put ns.publish() function under onFCPublish function which is called by the livepkgr app when already a stream is being published from the same name which you are trying to publish and you will receive NetStream.Publish.BadName code. NetStream.Publish.Start status code is received on NetStream event listener when you do NetStream.publish() and publish is successfully started. Also, you must be seeing some playback because you did publish from FMLE and the fragments were still there.

So, before trying, first delete the streams folder under the applications/livepkgr folder and .stream file under applications/livepkgr/events/_definst_/liveevent folder.

Also, modify your publishing code and put the ns.publish() code under onNc function under NetConnection.Connect.Success status like mentioned below:

function onNc(event:NetStatusEvent):void {

  if(event.info.code === 'NetConnection.Connect.Success') {

    ns = new NetStream(nc);

    ns.attachCamera(cam);

    ns.videoStreamSettings = hd;

    ns.publish('livestream?adbe-live-event=liveevent');

  }

}

Petro_O__Bochan
Inspiring
February 17, 2013

Hello Chandan, I tried this code before and it’s still giving me same output (code 304). What’s more, when I quit FP, SMP in debug mode show status as playing, while if I quit FMLE, its status changes to buffering and a caption appears as well. I still think FMLE send some more data or commands than FP does. How would I address this?

February 18, 2013

Hi Petro,

For 304 error, you should clear your browser cache and then try as I have mentioned earlier. Also, I have tried above code at my end and it's working.