Can I start or seek to sub-second intervals with NetStream? - actionscript-3

I am working on a Flash Video player and am implementing the ability to start a video at x time within the span of an FLV (served from FMS). I am able to start it x seconds into a stream without any issue using
netStream.play(source, startTime);
but as far as I can tell, it only supports seconds. I am looking to be able to give a start time (or even a seek time if that is supported) in milliseconds, or really anything more precise than whole seconds.
Anyone know of any way to achieve this even by monkey patching the fl classes?
Thanks,
Doug

Well the seek will allow you to seek by a number of frames, but the spec says that it only seeks to the closes I-Frame in the FLV. That will become a problem with any method you use, because the I-Frames are the only ones that actually contain the whole picture frame (here's the gist of that).

Related

Want to Improve the rewind function on HTML5 Video player

This is not some programming question. I am working on a project where I have video files in different formats such as mov, mp4 etc.
My app is built using knockoutjs with html5 and css3.
Our Client requirement is when they play the video and use functionalities like fast forwaard, rewind etc.. there should be no performance issues with the video rendering.
Right now, I am able to render videos properly and fast forward feature works flawlessly with html5, the Issue I am facing is in Rewind, when users hit rewind, videos begin to stutter and lose frames, and to the users here rewind function is very important.
Now I want to make a consistent performance for videos of all formats.
What will be the ideal way of going ahead in order to optimize the video performance on websites.
Any suggestions and help is greatly appreciated.
I'm not sure how you encode your video, but look into optimizing your video keyframes to see if that improves your rewind performance.
Here is a brief overview of how that might help:
http://www.lighterra.com/papers/videoencodingh264/#maximumkeyframeinterval
...we still want enough keyframes that seeking and fast-forwarding
behavior is good, because players can only jump directly to keyframes
"under the hood" during playback, and will usually only display the
keyframes during fast-forwarding and rewinding at higher speeds (at
low speeds such as 2x or 3x they can often play every frame). Jumping
to an arbitrary point in the timeline therefore becomes more sluggish
the fewer keyframes there are, because more intervening delta-frames
need to be decoded just to reconstruct the final target frame, even
though those intervening frames between the previous keyframe and the
target frame won't actually be displayed.

Accessing VideoJS Played TimeRanges

I'm building a web app using ReactJS that will allow employees to view various video training sessions and then answer quiz questions about them. I would like to use HTML5 video elements to maximize compatibility across devices, but users can always just scrub through the video to get to the end and trigger the next operation in the app. It is necessary for them to watch the entire video before moving on.
I need a way to tell if the whole video has been played before allowing the user to move on. I was looking at the Video JS Advanced Examples page, and I found exactly what I was looking for. They have a 'played' data field that updates with what time ranges the user has played through. The problem is that I have no idea of how to implement that feature in my app. I can include and get VideoJS up and running just fine, but I don't know how to access the 'played' property of the video player.
If anyone could give me a direction to go in, I would really appreciate it. If this is a stupid question, I'm really sorry. I'm still fairly new to all of this. Thank you so much.
Cheers,
Jaydon
played comes form the html5 media spec. It returns a TimeRanges object.
Video.js provides most of the functionality of the native video element via methods. So, the played property on the video element (as vidEl.played) becomes a method call on the Video.js's player object (as player.played()).
The API to time ranges is a bit weird. But essentially, it has a three properties: length, start, and end.
This is what they do:
* length: how many ranges are there? In the case of played, how many different sections of the video have been played?
* start(): a method that tells you the start time of a given range
* end(): a method that tells you the end time of a given range
It's likely that you will only have one range, but it's possible you'll have more. So, you'll want to loop over the length of the ranges. To know exactly how much the user as played, you'll basically want to loop over each range and calculate it's duration (end(i) - start(i) and then compare it to the duration of the video (player.duration()). If they are close, that means that the user has watched the entire video.

Boosting Audio Above 1 on SoundChannel

I'm dealing with an audio anomalie. I have audio that is mastered quite loud, yet on some systems, it is too quiet. Boosting the audio file anymore causes clipping.
It would be fine, except for the fact that, in my project, a lot of other sounds are in use as well. Lowering the volume of everything to match this would make some stuff impossible to hear. And again, this doesn't happen on all computers, only some.
To compensate, can I boost audio in code? The SoundChannel I'm using is already at 1.0 volume (full), and I know I can't use that property to boost it further. Is there any way to raise the audio further in code?
(I'm using Flash Professional CS5.5, Adobe AIR 3, and ActionScript 3)
After some time, I've concluded that it is apparently not possible to boost sound volume above 1 (that is, to amplify) using Flash's API. While you can set SoundTransform to a number greater than 1, it will coerce to 1 nevertheless.
If anyone has information to the contrary, you are welcome to post the answer and I'll change which answer I've accepted if you solve the problem.
You are correct. Sounds cannot be played at a volume above 1 (100%). However -- You can play two identical sounds simultaneously on different channels. This would effectively give you an audio boost above 1. But depending on the nature of the sound you may get some distortions from synchronization. If you're talking about a sound-effect without a lot of discernable Attack, you may get away with it. If you're talking about speech or percussive sound, your mileage may vary.

as3 | Flash | understanding better the meaning of importing a video to flash

I am making a project, that includes many videos. In short: let's say I want to put 20 videos that are on the screen (I won't put them all together - they would be 4 together each on 5 pages for example) and the user could hear 15 seconds of them and then decide if he/she wants to play the whole video.
this is the general code I use for import (just to understand how I import):
playlistVideoDisplay[i].movie = new FLVPlayback();
playlistVideoDisplay[i].movie.load("videos/somefile.flv");
To my understanding - It would be easier for flash to load 20 videos of 15 seconds each - and then when a user request a specific video - flash will load the full video of this specific short one.
BUT - I would much rather use the other way - loading full-length (let's say 10/7/5 minutes) and when the user can play the 15 second sample and, if he/she wishes, he will play the full video (without re-loading a new video - and not making a smooth transform between the short one and the long one).
My question is: Am I wrong by assuming that importing bigger movies would make everything hard and slow on flash?
First of: you'd probably do your users a great favor by NOT importing the full length FLV:s. In the case of 20 5-minute videos you'd be importing 100 minutes of moving pictures. That's a lot. For someone surfing with limited bandwidth (say a mobile broadband) that could easily eat a big chunk of the monthly allocated bandwidth.
For that reason alone, I'd say go with the small previews.
Having said that, I'd recommend you have a look at this class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html
Streaming would definitively be a better idea than loading all of those videos. Unless there's a specific reason why you want to load them?

Multiple Flash objects on a single web page?

Is there any significant performance/load time impact if single web page will load, say, 10 identical flash objects? 20? 30?.. any evidential data on sustainability of such kind of setup?
This would be the same flash app, each instance serving its own stream.
There's definitely going to be some overhead in size as there is a certain amount of code that is contained in every swf regardless of it's developer created content.
I'm almost certain there would be speed issues as well, which would see frame rates drop right down the more swfs you add to the page.
To be honest the concept smells a little fishy and i would think there must be a better solution to your problem.
EDIT
Also there is a restriction on having two steams coming over http per domain. Sure you could get around this but it will definitely be an issue.
I found this post which might help. The trick is to use SWFObject to embed your swf files.
I ran into a strange problem today. On the music charts page on Muziboo, I was displaying a list of songs and a playlist on the right. Each song has a small button player done in OpenLaszlo. In firefox everything was fine and in IE (not unusually), the page would freeze for sometime. This would happen once and repeat only if I delete cache and try again. I googled a bit and learnt that it's a good idea to embed give each swf a unique id otherwise the browser misbehaves. I then went ahead and used swfobject to embed the swf files and everything started working great!
Yes, it'll likely nuke the browser if you go too far down that road.
If you want to deal in multiple streams, perhaps combining all your would-be applets into one giant one might work better. It'll certainly offset the serious overhead you'd have with 10-40 of the little blighters.
If this is a music player, you want to have a serious look at doing some JavaScript remoting. It's fairly trivial to control a flash app via JS so you could have standard HTML/CSS controls without having to load up a billion flash instances.
Design-wise this just sounds like a bad idea. You'd be running multiple instances of the Flash player inside a browser, each of which has an individual cost, and the host (in this case the browser) will run all of them on the same thread (with the exception of certain elective asynchronous processes), so you're almost surely going to run into problems of various kinds -- jittery playback, UI blocking, processor burden, memory bloat, consequent instability of the host, etc.
Unless the SWFs are very tiny, and doing very little work, it seems like a design that's just asking for trouble. Indeed you could test such a thing fairly easily; have you run any tests yet? Just curious.
Also curious as to the requirements; we might be able to offer more constructive alternatives if we knew a little more about what you were aiming for. Have you considered simply loading all the SWFs into a single container SWF requiring only a single browser-hosted instance of the Flash player?