jamesward / jsamf Goto Github PK
View Code? Open in Web Editor NEWAn AMF library in JavaScript
Home Page: http://www.jamesward.com/2010/07/07/amf-js-a-pure-javascript-amf-implementation/
An AMF library in JavaScript
Home Page: http://www.jamesward.com/2010/07/07/amf-js-a-pure-javascript-amf-implementation/
I'm working on an HTML5 port of a Flash-based drawing replayer, and I'm stuck with parsing the actual AMF
var test = new XMLHttpRequest();
test.onload = function ()
{
console.log(decodeAMF(this.response));
}
test.open("GET", "23828-24312.amf", true);
test.overrideMimeType("text/plain; charset=x-user-defined");
test.send();
and an error occurs with the following trace
readUInt30BE file:///E:/Projects/AMFFail/amf.js:449:9
readAMF0Object file:///E:/Projects/AMFFail/amf.js:816:9
readObject file:///E:/Projects/AMFFail/amf.js:784:14
decodeAMF file:///E:/Projects/AMFFail/amf.js:62:23
test.onload file:///E:/Projects/AMFFail/index.html:18:16
Converting the response to an array buffer with test.responseType = "arraybuffer";
and decoding that resulted in an object with a version of 0 and the header and messages were empty. Converting the array buffer to an Uint8Array resulted in the same error
Here is the AMF in question.
Both functions readFloat64BE and readFloat64LE are buggy at the following line:
(((b5 & 0x7F) << 24) | (b6 << 16) | (b7 << 8) | b8).toString(2)
If you do, for example:
var b5 = 0, b6 = 0, b7 = 0, b8 = 0;
The expected value should be "0000000000000000000000000000000" (31 zeros), but instead it returns "0"
I solved it by using:
("000000000000000000000000000000" + (((b5 & 0x7F) << 24) | (b6 << 16) | (b7 << 8) | b8).toString(2)).substr(-31)
But this solution isn't cross-browser.
Tested on Firefox 12.0
Thank you for your great work.
Hi James.
I hope you are well.
I'm wondering if you can help. I need a way of extracting AMF data from an RTMP video stream, and your JSAMF library may be able to help with that.
I am streaming video using nanocosmos encoder and it uses a method, onCuePoint to send cue points along with the stream.
In their test player (which is flash) these can easily be seen: (this vid may or may not be available when you get to view it)
https://www.nanocosmos.de/nanostream/player.html?id=rtmp://wowza.rgsit.com/podia2016rgsitcom2200/podiapull
My player is JWPlayer 7, and the viewers will not haver flash installed, hence my need to decode the AMF data so that I can do whatever I need to with it.
JWplayer has its on('meta') but when trying to set var a = BinaryToArray(event.metadata).toArray();
, for example, nothing happens.
I have most likely got something wrong, or perhaps the method in the encoder needs to match the JW method. I really don't know.
If you have any ideas at all, it would be great to hear from you. I realise that it is a while since you built this, but it looks like it could be a really useful mechanism for retrieving such data from video streams in a world where flash is very rapidly become persona non grata, especially on corporate networks.
Many thanks in advance,
Neil.
RemoteObject uses AMFChannel which extends NetConnectionChannel which uses a NetConnection
How to work with this using JSAMF?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.