• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

using netstream appendBytes with mp4 file

Guest
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

hi. i am trying to play a mp4 video file with netstream.appendbytes method. but the video down't loading. when i am load a flv video file, the player play the flv video but when i am trying a mp4 video file, don't loading. flv works, but mp4 don't works. why? Please help me!

my code is

import flash.net.URLRequest; import flash.net.URLStream; import flash.events.ProgressEvent; import flash.events.Event; import flash.utils.ByteArray; import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Video; import flash.events.NetStatusEvent; var urr:URLRequest; var urs:URLStream; var nc:NetConnection; var ns:NetStream; var vid:Video; urr=new URLRequest("http://video.ak.fbcdn.net/cfs-ak-snc6/214988/655/115514355195743_26925.mp4?oh=53935006d42b2db7f970d4..."); urs=new URLStream(); urs.addEventListener(flash.events.ProgressEvent.PROGRESS,progresHnd); urs.addEventListener(flash.events.Event.COMPLETE,completeHnd); urs.addEventListener(flash.events.Event.CLOSE,closeHnd); urs.addEventListener(flash.events.Event.OPEN,openHnd); urs.load(urr); function progresHnd(e:Object):void{      trace (e);      var bytes:ByteArray=new ByteArray();      urs.readBytes(bytes,0,urs.bytesAvailable);      ns.appendBytes(bytes);            }       function closeHnd(e:Object):void{      trace (e);      }       function completeHnd(e:Object):void{      trace (e);      }       function openHnd(e:Object):void{      trace (e);      nc=new NetConnection();      nc.connect(null);      ns=new NetStream(nc);      vid=new Video();      vid.attachNetStream(ns);      ns.play(null);           addChild(vid);      }

TOPICS
ActionScript

Views

6.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

You cannot play mp4 container directly. If you look into documentation of appendBytes you will see that this method understands FLV headers only. This means that you need to create an FLV header at runtime and append mp4's payload after that.

In any case, this is a very tedious task and you are better off sticking with OSMF framework that does that (it is open source).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 04, 2011 Nov 04, 2011

Copy link to clipboard

Copied

hi andrei1,

is it possible to refine what you mean by "mp4's payload".

writing a standard flv-header (0x46, 0x4C, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09) is no problem at all, but what to write next?

which mp4-boxes are required? i guess "mdat" in some way, obviously.

any additional information / links?

thx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 04, 2011 Nov 04, 2011

Copy link to clipboard

Copied

LATEST

"is it possible to refine what you mean by "mp4's payload"."

by payload I mean bytes that mp4 codec specific bytes that follow header.

Adobe has documentation (PDF) that describes video file specs. I don't have a link to it ready but you can find it on their site. Again, reverse-engineering OSMF code provides deeper insight in how bytearray may be handled.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

Another thing. You are better posting this question on HTTP Dynamic Forum:

http://forums.adobe.com/community/flash/httpdynamicstreaming?view=discussions

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines