Jump to content
GreenSock

Doc

VideoLoader Seek to ms

Recommended Posts

Hi !

 

Happy new year everyone :)

First, thanks for the awsome job, you definitely changed the way people used as3 :)

 

I have a question.

I have several Videos.

Each of them in a videoLoader.

When I click on button, I need my video B to seek exactly at the same time that my video A is.

 

I do it this way (in a function but just copied the interesting part) :

	trace("current mainVideo Time : " + main_video.videoTime)
	timeToSeek = main_video.videoTime
	trace("Time to seek " + timeToSeek)
	
	
	if(e.currentTarget.name == "selector_front"){
		video_container.holder_front.visible = true;
		//video_front.playVideo();
		video_front.gotoVideoTime(timeToSeek, true, true);
	}

Unfortunately, so when I use videoTime, I get the videotime as this : 

3.599 or 2.02 etc...

But the gotoVideoTime() method only accept a Second.

 

Is there any workaround so I can seek to a milliseconds ? 

 

Hope there is or i'll have to restart my project my project from the begining, at least on the video part :/

 

Anyway, thanks again for the awsome job you did for the community and sorry for my bad english :)

 

Fred.

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The videoTime and gotoVideoTime() use seconds. (see docs)

 

We don't use milliseconds anywhere (as far as I can recall).

 

If you need a value in milliseconds you can just multiply seconds x 1000.

 

1 second = 1000 milliseconds.

 

Am I missing something? Let us know, would love to help you get it sorted.

Link to comment
Share on other sites

Hi Carl !

 

Thx for the qui answear :)

 

I ll try to be more precise : 

 

I Need to seek at an exact time in a video.

When I use the videoTime method, it gives a very precise time, like 1.235.

I need to seek at this exact moment.

 

Is it possible ? 

 

Or maybe with the original netstream seek function ? 

 

Still thx for the support Carl, and thx for what you did on snorkl.tv back in the days ;)

 

Have a nice day,

 

Fred.

Link to comment
Share on other sites

So are you saying that gotoVideoTime(3.599) won't seek to that time at all and is rounding to exactly 3 or 4 seconds? What do you see with this:

video_front.gotoVideoTime(3.599, true, true);
trace(video_front.videoTime); // expecting 3.599

 
The time parameter takes a Number, not an int (and it's never converted to an int internally), so it should work fine with fractions of a second.
 

Attempts to jump to a certain time in the video. If the video hasn't downloaded enough to get to the new time or if there is no keyframe at that time value, it will get as close as possible.


Is it possible your video just has sparse keyframes and is having difficulty showing the specific time you jump to visually?

  • Like 1
Link to comment
Share on other sites

Ah, ok I think I understand better. And Jamie just touched on exactly what I was going to elaborate on.

 

Its actually very difficult if not impossible to have accuracy down to the millisecond when seeking a video. You can only technically seek to the keyframe nearest the time you are trying to seek to.

 

Here's a nice summary from wikipedia

 

Because video compression only stores incremental changes between frames (except for keyframes), it is not possible to fast forward or rewind to any arbitrary spot in the video stream. That is because the data for a given frame only represents how that frame was different from the preceding frame.

 

 

http://en.wikipedia.org/wiki/Key_frame#Video_compression (video compression section)

 

As Jamie suggested in order to get better timing accuracy you may need to re-encode your video with a higher keyframe density.

Link to comment
Share on other sites

Hi thanks for the very precious and accurate answear.

You totally understood what i meant.

 

I tryed to re-encode the video with a higher key-frame, 1 every 4 frame, and I still have the same trouble.

I'm now re-encoding with 1 keyframe every frame but I doubt it will change anything :/

 

I also tried to trace the seeked time the way you said, and it gives me exactly the time I seeked : 

trace("current mainVideo Time : " + main_video.videoTime)
timeToSeek = main_video.videoTime
trace("Time to seek " + timeToSeek)
	
	
if(e.currentTarget.name == "selector_front"){
	video_container.holder_front.visible = true;
	video_front.gotoVideoTime(timeToSeek, true, true);
	video_front.playVideo();
	trace("Seeked " + video_front.videoTime)
}

//current mainVideo Time : 3.641
//Time to seek 3.641
//Seeked 3.641

You can try to take a look at the project here : 

www.advoc8.fr/wweg/index.html

 

The main video is the one top, and i need to synchronize the others when i select the angle to be at the exact same time.

 

No to the milliseconds, but a tenth of a second would be good.

 

I'm starting to got a little bit of stress :/

 

Thank you for the help, and i cross my fingers to make it work !

 

Fred.

Link to comment
Share on other sites

Hi again :)

 

I Tried encoding with a keyframe every frame.

It doesn't seem to be much better :/

 

It's pretty strange because all the videos have exatly the same length.

 

You can check at the same url than before : 

www.advoc8.fr/wweg/index.html

 

Do you think maybe if publish with hardware acceleration it might be better ? 

If so, shoud I use CPU or GPU ? 

 

I also found this : http://nikohelle.net/2011/11/25/as3-perfect-video-sync-with-embedded-frame-numbers/

 

But i'm not sure it would be the right solution, plus it's far beyond my skills :/

 

Thanks again for the help,

 

Fred.

Link to comment
Share on other sites

Hi

 

I'm not really a video expert by any means but I'm not so sure that syncing streams with total precision is even really possible. Lots of variables involved from buffering to decoding to rendering the final image.

 

I'd suggest to test this without VideoLoader to see if you get more accurate results with just the native netstream. If there are inherent problems in flash player and native APIs it could be very difficult(if not impossible) to work around them in VideoLoader.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×