NetStream.publish() to AMS ends up with 1kb file - actionscript-3

I'm using Adobe Media Server 4.5 and the FLEX 4.6.0 sdk.
I have an .swf application that connects to Adobe Media Server over RMTP, takes audio and video input from the user's webcam and mic, and does a NetStream.publish() to stream the file to the server. The file grows in size as the user records the video. On occasion, the resulting file will end up with a size of 1kb.
What's causing this and how can I prevent it, or otherwise end the session and inform the user that something went wrong?
Edit:
Some additional questions/comments/opinions that might help identify the problem:
This only happens 1% of the time, and I'm not sure what I can use to troubleshoot this. I've never been able to catch when this happens before the log files generated by AMS expire.
My theory is that it happens when the client loses connection somewhere.
As long as the NetStream is publishing correctly, the file will grow in size.
If the file doesn't grow, it should mean that the NetStream lost connection. Seeing as the file is 1kb, the stream must have lost connection immediately after starting to publish.
I also opened the file in Notepad++ and got this:
FLV [SOH][NUL][NUL][NUL][NUL] [NUL][NUL][NUL][NUL]
Another theory is that something has a chance to overwrite my file, but this is unlikely

Have the same problem, but 0.001% of the cases.
The most common problem occurs because of a microphone.
Need to check the microphone before publishing a stream.
Another possible problem:
Client interrupts the flow - NetStream.Record.Stop
Exits the application - onDisconnect
Сlient disables the microphone / camera
"The FLV segment cache is full"
Can warn if called onUnpublish event on the server.
I also use the timer after the publish () method on the client side, if after 3-5 seconds NetStream.Record.Start event is not called, then the client has a problem and it should be prevented.

Related

WebRTC video works locally but not remotely

There's quite a bit of code involved, so I threw what I had into a temporary github repo:
https://github.com/stevendesu/webrtc-failure
I'm learning WebRTC and long-term want to do some fancy stuff, but for now I'm starting simple: send a video from one computer to another. Unfortunately this failed. Here's what I've set up so far...
On a development server I own I installed coturn to act as a STUN/TURN server
I created two pages: broadcast.html and watch.html. The former creates a media stream and (using Socket.IO) sends the connection details to a signaling server. The latter gets the connection details from the signaling server and attempts to watch the stream
After running npm install you can npm start to run the server and access it at localhost:2017.
So here's what works:
After opening broadcast.html you are prompted for a broadcast ID. You can type anything here, but I usually just do an incrementing number - so I start with "1"
After entering a broadcast ID, and a short delay, you see your webcam feed on the screen. Looking at the console you can see several messages have been exchanged with the Socket.IO server
If you open watch.html in a new tab, you are prompted for a broadcast ID. Enter the same ID as before
After entering the ID, and a short delay, you will see your webcam feed on the new tab. Looking at the console you can see that the earlier ICE candidates and offer details were sent by the Socket.IO server and the watcher responded with an answer
Returning to the broadcast tab, you can verify that the answer was received and processed. A connection has now been established
For bonus points, the pc variable is in the global scope (PeerConnection) so in the console you can establish an RTCDataChannel and send messages between the tabs directly (bypassing the Socket.IO server)
Here's what doesn't work:
For now (and I know why this is, so it's not a concern) only the FIRST person to enter an ID into the watch.html page can actually see the broadcast. It's not "broadcast", it's just peer-to-peer, and once one connection has been established then future connections fail
My issue: if I open watch.html from a different computer or device (either on the same network or a different network) then the video never plays
In the latter case if you look at the console you'll see the offer and ice candidates are delivered to the watcher, the watcher generates an answer, the answer is sent back to the broadcaster, and the watcher sees a media stream added to the PeerConnection. This media stream is converted to a blob URL and assigned as the source of the video element.
I'm at a point where I don't know how to progress. I don't know why the video isn't showing up.
your watch.js does not emit ice candidates. That is one possible cause. If that doesn't help you can use chrome://webrtc-internals to figure out what is going on -- see here for a description of how to interpret what is going on.
You might also want to look into modernizing your code. https://webrtc.github.io/samples/src/content/peerconnection/pc1/ is a fairly simple example of modern WebRTC code using promises and other things like using srcObject instead of the deprecated URL.createObjectURL.

Flex Security Sandbox Violation just started happening

I have an http handler built and running on my website server. Code in flex generates a http request then navigates to the handler, which generates and streams back file information for the user to download.
Basically the request sends image data and the return result is a pptx stream with the image data in a powerpoint slide.
This worked fantastically this morning until about an hour ago. I have no idea what changed, but every swf I am building which attempts to access this handler is now giving me:
* Security Sandbox Violation *
Connection to https://g1.localhost/Turm/BounceBack.aspx halted - not permitted from https://g1.localhost/Turm/FlashApps/ImageAndExporting.swf?debug=true
I even fully qualified the BounceBack.aspx name (it was a relative url until just now) in case something was confusing the flash player, but as you can see, the url request and the swf are loaded from exactly the same domain (even the same virtual app in the web domain).
I have even added the physical filepath as a 'trusted folder' in my flash player security settings.
What gives? Anyone have any suggestions?
Using the Apache 4.9.1 SDK and latest version of flashplayer.
As mentioned, this worked all day yesterday and this morning. I cannot figure out what has changed, but am having no luck resolving the issue, source code has not changed.
Finally figured out what changed. I move the navigation to my ASPX handler into a seperate method that delays invoation till after a UI update. Becuase I use the same ui components for printing as well as exporting, I tested the updates with the print feature and that worked without error. About an our later, I noticed the handlers were failing. Since the url request is not handled inside a UI interaction event (Like MouseEvent.CLICK) the flash player was preventing the call. Once I moved the navigation back into the event handler, the sandbox violation went away.
If you ask me, not a very good error message due to the actual problem encountered, but ... you learn something every day.

In flash as3 webcam recorder how to reconnect or republish after connection loss

I have a flash as3 based webcam video recorder that publishes the webcam video stream of a user to a Flash Media Server (FMS). The trouble I have is that when the connection of the user drops due to erratic internet connection, the recording stops abruptly in between and the video file is more often than not, corrupted. I can use the NetConnection.Connect.Closed and NetConnection.Connect.NetworkChange events of the NetConnection class to detect a connection drop and reconnect to the server without any problems. But on attaching the newly reconnected NetConnection object to the NetStream object, the recording is reset and starts all over.
In the case of playback using an FMS, the re-attaching of a new NetConnection to the NetStream, there are ways to resume the playback from the last position as shown in the documentation here: http://help.adobe.com/en_US/flashmediaserver/devguide/WSae44d1d92c7021ff-1f5381712889cd7b56-8000.html. But while publishing / recording, I can't resume the recording once i have re-connected. Is there a way to work around this? Ping me in the comments if the question is not clear. Thanks.
Note, I've never done this, so I don't know how it would work w/files that are corrupted, but there is an option to append to an existing stream (or append with a gap), when publishing a NetStream. The second parameter of the publish() method specifies how to publish the stream:
ns.publish('myStreamName', 'append');

Database content not retrieved in the exported SWF and published HTML

I have this problem that when i am running my project in Flash cs6 using ctrl+enter, the project is ok, the flash player is retrieving the files from mysql database. but when i run the independent swf file outside, there is no retrieval happening. the text box that suppose to be showing the retrieved data is empty. how can i fix this?
Make sure you are running the published html from an actual page in the browser and not from the local file system.
Just make sure that the URL doesn't start with file:///
You must be having a security sandbox error, but you probably don't have the Debugger version of the Flash Player, so it's not telling you anything.
Just go to http://www.adobe.com/support/flashplayer/downloads.html and choose the proper one for your operating system and browser.
If you STILL want to run the files from your local file system, you can have a look at Flash Player's Global Configuration, to give access to the files/directories you want. Just right click on your swf file in the browser, and when the Menu opens, select Global Configuration.
The reason it is working when running inside Flash CS6 is that the player has less security restrictions in there.
Let me know if you were able to solve your problem.

Record Video from Browser using Webcam and Microfone inputs

I need to record a video through user browser using input from camera and microphone and send to my server. Since html5 still doesn't make that magic happen, I'm looking for flash solutions.
Do I really need some flash media server to do that, or can I do a POST request?
I want to get both inputs(webcam and microphone), put them in a .flv and send to my server.
I've seen some implementations using bytearrays to record and send, audio and video separated. The problem is that it generates a series of synchronization problems when you try to compose them in a single file.
If you're still looking for a solution check out:
http://framebase.io
They have an embed-able recording widget that can transcode the videos automatically. I'd check out the docs, but on success, you can run an API call to check the status of transcoding and download it to your server or you can just use your own S3 bucket.