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

Getting a FLV to loop back toward a specific frame using Netstream (as3)

New Here ,
Aug 30, 2012 Aug 30, 2012

Copy link to clipboard

Copied

To preface this my knowledge of AS3 is quite novice. As the thread titled reads, I'm trying to get an FLV to play through it's entireity and then loop back towards a specific frame and keep replaying from the point endlessly. After a lot of digging I found a video tutorial using AS3 that worked! Here's my situation now though, I cannot find the right code to insert to make the video loop back to the frame that I want. The FLV just stops and doesnt rewind at the end of the video. Here is my code so far:

var video:Video = new Video(1980, 1020);

addChild(video);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

var meta:Object = new Object ();

meta.onMetaData = function (meta: Object)

{

          trace(meta.duration);

}

ns.client = meta;

video.attachNetStream(ns);

ns.play("All.flv");

Ultimately, the video needs to play all the way through only on the first load and then loop back to frame 319 and play toward the end and loop back again to frame 319 infinitely. I think I'm almost there, I just need some assistance with getting my code working appropriately. I done this before using "gotoAndPlay()" but the loop isnt seamless thus it yields a one second pause before looping back. I'm hoping using a Netstream function that this will be resolved. I would appreciate any help!

Views

84.9K

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

correct answers 1 Correct answer

Community Expert , Sep 02, 2012 Sep 02, 2012

then you can use:

var video:Video=new Video(1980,1020);

addChild(video);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream=new NetStream(nc);

ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusF);

ns.client = this;

video.attachNetStream(ns);

ns.play("All.flv");

function onMetaData(obj:Object):void{

    trace(obj.duration);

}

function netStatusF(e:NetStatusEvent):void {

        switch (e.info.code) {

              case "NetStream.Play.Stop":

              ns.seek(2);

           

...

Votes

Translate

Translate
New Here ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Okay, so I re-encoded my video with bit rate of 400, (with keyframes at every frame). Same issue is happening, the .swf plays fine in the Flash stand-alone-player, but when the .swf is loaded into a web-browser it hangs on the last frame a while before looping. I tested in both Google Chrome and Safari. The FLV video clearly is the new one (400 bitrate), due to the lower visual quality. As a detail, the new .flv is at 15mb, the older one was at 46mb, though this hasn't made a difference in the video hanging at the end before the loop action.

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
Community Expert ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

upload your new flv for testing.

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
New Here ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Okay here it is:

http://mitchpatrick.com/art/Int_Medium.html

*loads at original size, zoom out to see the entire video.

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
Community Expert ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

this still has a glitch especially the first time through the video but thereafter it's not bad:  http://www.kglad.com/Files/forums/main.html

you can remove the first time glitch by preloading your flv or using the lower bitrate video.

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
Mentor ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Is there some very special reason that the video needs to display at such large dimensions? As a consumer (who happens to have a fair amount of Flash and video production experience) I just don't get the message of the video, the purpose behind it. And making me wait and wait watching a jerky video, only confuses me further.

A smaller dimension and lower bitrate video that works correctly and effectively focuses on the message behind the video, may very well be a much better choice than continually attempting to "fix" a video that from the outset has a very shakey foundation.

Contrast your video with the link I posted earlier.... which loops back to a set point in the video using NetStream:

http://www.cidigitalmedia.com/tutorials/loop_vid/loop_vid.html

What exactly is happening in the frame that you are attempting to loop back to? Is that really needed? Can it be done some other way? Can you use a smaller, lower bitrate video and do a better job in getting your message across?

Just trying to help here so I hope you take this suggestion in the spirit with which it is intended.

Best wishes,

Adninjastrator

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
New Here ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Yes, everything is needed, it's a peice of video art that I'm putting together for a show. The tailoring of the video itself is fine. The frame it loop backs to is the beginning of a palindrome loop, after the start of the video it will sustain the seamless loop that happens towards the end. It's very simple. I just need to either put a preloader on it (personally I think it would take away from the work), or reduce the bit-rate and make the video itself smaller. The "non"/original web version will be sized at 1920 x 1080p, the web version looks as if it will have to be much smaller in screensize and bitrate.

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
Mentor ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

So the "Show" version is a kiosk or non-Web version?

A pre-loader (which doesn't actually pre-load anything... it just hopefully distracts the viewer long enough for them to download the full 15MB of data) is only needed when viewing via Internet (not kiosk based). And if the viewer has to wait too long... forget it!

If you've not done much work with video bitrate vs display dimensions, here is an old post that may help with background information. The really important part is the correlation between display size and required video bit rate. Doubling the display size does NOT double the required video bit rate... so a jump from 320 x 240 to 640 x 480 for example requires 4 TIMES THE BITRATE to achieve equal quality. And once this bitrate exceeds the download speed of your visitors... you are in trouble... as per your first video encoding.

Anyway, for your review:

Video bit rate

Video bitrate is the minimum amount of data that must continually flow into the video player in order for the player to display that particular video uninterrupted. If that supply of data is not high enough, the video player will stop…. Wait for more data to download, then resume. The video bitrate is set as a parameter when the video is encoded.

One of the principle of goal setting is to "Begin with the end in mind". In this case it'll be very hard to give good recommendations because the end is not defined. So I'll just make a few assumptions and you can correct me as needed.

First, I'll assume that since you are converting to Flash, you want to deliver this video over the Internet. If that's true, then we'll have to make some assumptions on the Internet connection download speeds of your potential viewers. Let's just say that most have at least a 1.5Mb connection or faster.

OK, that would mean that a video bitrate of half that should usually provide a video download that is not interupped by buffering (most of the time anyway). So assuming a video bitrate of 750kbps, what would the optimum display dimensions be?

Before we decide, here's a little info about bitrate. For highest quality playback, the video bitrate is tied directly to the display dimensions. That is, the larger the display, the more incoming data is required to properly display the video. Think of bitrate in terms of a can of paint. If you have 1 quart of paint, you might be able to do a very nice job on a 32 X 24 foot area. But if you try to stretch that same amount of paint out over a 64 X 48 foot area, the coverage will not be nearly as good and you get poor results.

In the same way, a video displayed at 640 X 480 pixels will require 4 times the bitrate as a video displayed at 320 X 240 pixels to produce the same quality. So for example a video with a bitrate of 100kbps, displayed at 160 X 120 will produce the same quality results as a video with a bitrate of 1600kbps if displayed at 640 X 480.

So to boil it all down, video bitrates of 750kbps, even up to 1000kbps can usually get delivered of the Internet on most high speed connections. Higher bit rates may work for really fast connections but will cause problems for viewers with slower connections. Video display size has a direct bearing on the final quality. In the 750 to 1000kbps range, display size should be kept around 450 or 500 width max (and whatever height the aspect ratio calls for). Yes it can be displayed larger, but the quality will suffer.

Sound like your audio settings are fine, especially for Internet delivery.

As for framerate, maintain the original raw video framerate for best results. So if the video was shot at 24fps, leave it.

As for video converters, do you have the Flash 8 Video Converter? It works just fine for video to be delivered over the Internet. Remember, you are taking a Cadillac version of video (h.264 HD) and stuffing it into a Chevy body to get it to work over the Internet.

Best wishes,

Adninjastrator

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
Community Expert ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

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
New Here ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

I re-encoded the video, it is now at 768 x 432 pixels with a bitrate of around 500, and still - freezing occurs on the last frame when played in a web browser

*Please also note that when I open the file in a web-browser such as Chrome or Safari - it's a file thats on my computer (right click-open with) , it doesn't need to download/stream anything from a server, and it still freezes - why is that?

*Also when I encoded the video it says the file output size will be something 835kb but the file ends up being 18megs? Why is that?

*The display dimensions are looking good now at-least (not as BIG) maybe the file size should be much lower? - This is strange because I have other flash videos on my website that are around the same size and they load without a hitch.

http://mitchpatrick.com/art/L2.html

::Pulling hair out::

PS: Also I notice when the video eventually loops, that the time in-between the loops change each time - sometimes 5 seconds, sometimes 1 second, sometimes ten, one minute, etc, etc, whatever.

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
New Here ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

I saw what you posted on your domain, still a little sluggish and size is too big. See my reasponse to Adninjastrator - updates have been made, size is now at a good spot, just need to get the thing to loop smoothly when played in a browser.

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
Mentor ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

From what I'm seeing in both kglad's and your post of the video, the video really seems to be having problems. That is, it's very jerky and slow to load.

Also, when I view the file in my cache it shows up as an html file, not an .flv file.

Is this the correct address to direct download the video? We should be able to direct download the .flv if in fact it is a .flv file.

http://mitchpatrick.com/art/All_w.flv

The reason I ask is that I'd like to see the plain .flv, without adding in the looping problem. I think there is something wrong with the video and viewing it straight, whithout any looping may give some indication of what the problem is.

I'd suggest that you first get a smooth running version of the video (no looping). Do not play the video from your cache, upload to your server and delete your cache and see if you can get the jerkiness out of the video.

Also, the link you posted above is NOT displaying at 768 x 432, it's much smaller than that.... yet anoter problem with the video.

While you may be able to see the looping point, there is so much jerkiness in the rest of the video that from a new viewers point of view, it's not an issues... it's the rest of the video that has the problems.

So can you post a non-looping, just play from start to finish version to verify that the video is OK.

Best wishes,

Adninjastrator

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
New Here ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

Ok, here is a link where you can download the .FLV I'm using in the web version:

http://www.mediafire.com/?mayf8h56i4qwesz

The video is at 768 x 432p, but for some reason the html page loads it at a smaller size, so you have to manually zoom in.

Some details about the .flv:

- Before encoding I put a Flash cue point on the exact time where the video should loop back to when it ends, the cue point is at 10.18 seconds (which is where the palindrome loop starts).  (maybe this cuepoint is causing an issue?)

- In my encoding settings I set my keyframe distance at 1 instead of the default 30, so my loop will hit more accurately. (maybe this is causing the issue?) though when I wasn't using this setting my loop wasnt working correctly, when I set my keyframe distance to 1 it loops perfectly (when played in the stand-alone flash player)

Hope these details give you some insight to the problem. Thank you for all the valuable feedback thus far.

-mitch

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
Community Expert ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

that one is going to be slow to load because his bitrate is 10,000.  but once it loads it's ok and like i mentioned, it can be preloaded if the 400bitrate video is unacceptable.

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
Mentor ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

I was attempting to direct download the .flv from the URL used for the .flv in this link:

http://mitchpatrick.com/art/L2.html

my cache shows the file here:

http://mitchpatrick.com/art/All_w.flv

but that does not download a working .flv file. Wonder why that is!!

We should be able to access the .flv file just like the .swf player file does... same URL as used in the player, but in this case there seems to be some error.

I'm not a great fan of pre-loading .flv files, though that is sometimes a work-around when bit-rate is too high or there are some other issues with the .flv file. I'd rather see the file correctly sized for the application.

Best wishes,

Adninjastrator

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
New Here ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

I've uploaded the .FLV im using to mediafire:

http://www.mediafire.com/?mayf8h56i4qwesz

see post 62 above.

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
Mentor ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

Thanks for the link, but what I was really hoping to test was the URL used in your .swf to load the video... not a zipped file fo the video. This direct URL download as used in the .swf is just one of the basic trouble shooting steps for .flv video.

Anyway, I did download the video file from the link you listed and now have a better feel for what you are attempting to accomplish. One thing to note, to make a seemless jump from the last frame of a video to some earlier point in the video means that the last frame must match EXACTLY the frame you are looping back to.

In the case of your video, you have a moving hand holding a camera phone. Matching exactly the very last and the loop to frame is a VERY difficult job because of the movement, camera angle, lighting, etc.

Using the suggested 10.18 loop to point, you'll notice that the over the shoulder camera has not yet gained correct focus on the hands. Second, the hands are not in EXACTLY the same position as they are in the last frame. So the jump from last frame to 10.18 makes the hands jump (positions don't match exactly) and the hands are a little blurry (the camera has not yet quite grabbed correct focus).

I played around with a couple other loop to points, and while none match exactly, I think 11.426 matches the last frame a little better. See samples and compare here:

http://www.exploreolympics.com/stal/seek_to_and_loop.html

I don't see any hestitation or problems with looping in these samples

As for your code, if you are using ns.seek, there is no need to use a cue point, The "seek" method is sometimes referred to as a pseudo cue point, that is, it can trigger events just like a cue point. So yes, the cue point may be throwing things off. Start by eliminating that.

Second, I would still suggest that you post on a Web page a none looping version of your video to ensure that the loading and playing the video via NetStream is correctly done. Only after you have a working, none looping version displaying correctly from a Web server (NOT on your local machine) would you move to adding in the looping... Not trying to tell you how to run your project, just pointing out some basic trouble shooting steps. Eliminate ALL other possible problems before moving to the looping phase.

And I say this because as you can see from my examples, you should be able to loop using NetStream very easily.

Best wishes,

Adninjastrator

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
New Here ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

Okay, so I re-encoded the video this time without the Flash cue point inserted in the timeline. I loaded my Flash project and re-published (both the .swf and an html file). I believe the issue at hand is not how this is playing on the web. What is concerning me is why the .swf is not playing correctly in a web browser when I just simply open the html or .swf on my local machine into something like Google Chrome or Safari. If it's not looping correctly when loaded directly from my machine, then I think it's safe to say that it wont loop when I put it on my server. Again, it plays fine in the stand-alone Flash Player.

****WHOA*** So, I just decided to start a new project and copy/paste the as3 code I'm using in the previous project, NOW - all of sudden it's working in my webbrowser now when loaded off my machine. I think my project file was corrupted? Wow. Let me try putting it on my server now.

Message was edited by: mitwyatt85

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
New Here ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

LATEST

UDATE: Now we're getting somewhere. For some unknown reason(s) this thing wasn't looping right when my project file fps was set 29.97, though when set at 24fps it loops fine in webrowsers now, that was just a detail I noticed when I was combing through all the pre-publishing options. Anyway, I'm sure there were other possible reasons why it just wasnt working right. Please give this a try:

http://mitchpatrick.com/work2012.html

(click on INT_MEDIUM) should pop up a window at the correct frame-size, on first load it lags sightly but its looping fine now. Maybe all that's needing adjustment is my bitrate settings to get it near perfect, but it may be in a good place as it is.

Thanks.

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
Community Expert ,
Sep 03, 2012 Sep 03, 2012

Copy link to clipboard

Copied

don't use 16.2.  that may not be reached.  use 16, for example.

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