PDA

View Full Version : Launching .FLV's entirely from AS (music video project)


Peran
10-25-2006, 06:58 PM
Hi again guys!

Sorry to bother you with what's probably another easy-peasy question, but I'm a beginner at Flash and AS, and asking stupid questions is what we beginners do... :D

I'm doing a sort of relatively simple music video, with animations and stuff synced to an audio file.

First, I went thru my audio file, placing markers where I have points in time I want to sync stuff up to, I then export that to a text file, so I have exact min:sec:frame data that I can use later.

Next, I've done some animations in Flash and exported them to .AVI's using the brilliant FlashAnts tool (Flash is nowhere near being able to animate those 3D thingies in realtime). Then I've been toying around with using video editing software to put it all together, but it's just so messy compared to if I could do it all inside Flash.

So... I've converted the .AVI's into FLV's. and now I'd like to know a way to handle them sort of like I'd handle a movieclip, moving them around, stopping/resuming, changing blend modes and alpha.

First of all, is that possible?

I mean sure, I can just set up a _root.onEnterFrame = function() and have a framecounter ticking with if statements and all the usual hoopla to let the code know when to do stuff, but can I actually have that sort of control over a .FLV?


Thanks in advance,

Peran.

squadjot
10-25-2006, 07:06 PM
if you load FLV's by using netstream, you usually control your movie with seek(second) ..so..its actually a totally other way than normally movieclip handling..

All the other things ..well you could load your video into a movieclip that you then set all these blend functions on and stuff..

i tried following the help file.. wasnt so hard.

Example taken from help file;

The following example plays a previously recorded file named myVideo.flv that is stored in the same directory as the SWF file.

var my_video:Video; // my_video is a Video object on the Stage
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");

Peran
10-25-2006, 08:02 PM
All the other things ..well you could load your video into a movieclip that you then set all these blend functions on and stuff..

Thanks for the reply!

Now, the above code on it's own doesn't result in anything visible when I just paste it into a blank project (I point the filename to a .FLV in the correct dir). How would I go about to put that video into a movieclip?

Here's how my template .FLA starts out:

var mcMyStage=_root.createEmptyMovieClip("MyStage",1);

I'm not at all sure how to connect the video object as a child to the above movieclip. (I'm guessing that's what I should do to put the video inside the movieclip?)

The code below just throws a syntax error (but hey, at least I tried :) ) :

var mcMyStage=_root.createEmptyMovieClip("MyStage",1);
var mcMyStage.my_video:Video;

Like I said, I'm a beginner, please have patience. :o


Peran.

squadjot
10-25-2006, 08:30 PM
Oops.i'm sorry...the netstream apparently only works for files that are online..

If your application doesent have to be super dynamic in the adpect of adding new videos.. you could more easily control the video if u simply import the flv's to the stage..and create SWF's containing the video.. then load those.

Kraken
10-25-2006, 08:41 PM
the one piece you're missing is having a video object on the stage. First, go do your library and click on the little box in the upper-right corner. Choose New Video... from the dropdown menu. This will add a video object to your library. Now drag that video object to the stage and give it a name. From there, you can use netStream and netConnection like squadjot posted.

Look up the video class in the dictionary.

Peran
10-26-2006, 06:27 AM
Hi again guys!

Thanks for your replies. I'm starting out with the "embed into .SWF" solution.

I created an empty .FLA, embedded the .FLV into it, and whoopee, a .SWF file that plays my video. Now, with a new empty .FLA, I've loaded that .SWF into my library, and given it an identifier, "BlurCircle". Next, I AS as follows:

var mcBlurCircle=_root.attachMovie("BlurCircle","instBlurCircle",1)
mcBlurCircle.gotoAndPlay(1);

...but nothing happens. Went thru a bit of the documentation and a couple of threads here on the forum, I get the impression the above code should work. Tried adding blank frames to the timeline, did nothing, tried creating mcBlurCircle with createEmptyMovieClip before attaching the movie, but neither of those made a difference.

I'm sure there's something really basic I'm missing, please slap my fingers and tell me where I went wrong. :)


Peran.

squadjot
10-26-2006, 07:52 AM
i beleive its just _root.attachMovie("BlurCircle","instBlurCircle",1);

squadjot
10-26-2006, 08:03 AM
the one piece you're missing is having a video object on the stage. First, go do your library and click on the little box in the upper-right corner. Choose New Video... from the dropdown menu. This will add a video object to your library. Now drag that video object to the stage and give it a name. From there, you can use netStream and netConnection like squadjot posted.

Look up the video class in the dictionary.
i'm pretty sure netstream wont work with local files..

Peran
10-26-2006, 08:11 AM
Maybe there's another problem... When I try to preview my .SWF (which contains the .FLV) inside the library, it's just blank. Also, the .FLA file containing the .SWF is a bit smaller (61kb) than the .SWF itself (140kb).

I'm guessing that could be the problem. Question is, what to do about it?

If I double-click the .SWF file from Windows, it plays nicely in the Flash Player.

To get it into the library, I do File -> Import -> Import to Library, then set the Identifier to "BlurCircle", leave Class blank.

So... Should a .SWF preview animated in the library, and is the filesize problem as bad as I suspect (i e Flash simply screws up horribly when I import the .SWF)?

I've attached my .FLA and the .SWF containing the .FLV (totals 149kb).


Peran.

Peran
10-26-2006, 12:00 PM
Hi again!

Been doing some more testing here...

If I replace the .SWF containing a .FLV with a .SWF with just a simple tween done in the timeline, all's well with the code below:

var mcBlurCircle=_root.attachMovie("BlurCircle","instBlurCircle",1)
mcBlurCircle.gotoAndPlay(1);

...that .SWF also previews just fine from within the Library.

So, for some reason Flash screws up (an expletive beginning with "f" would be more suitable, but who knows, kids might read this too) when I import a .SWF made from a .FLV to the Library. I can't preview the .SWF in the Library, and the above code doesn't play it.

Can anyone else confirm this behavior? To me, it's looking like a raging bug.


Peran.

squadjot
10-26-2006, 01:47 PM
you misunderstood me..

make a new fla

import the FLV into that one.. (you will se video symbol in library,.. thats the raw flv)

now IN the fla.. u can manually put the FLV into a movieclip.. read MOVIECLIP (not new swf).. ..so create a movieclip on stage.. and inster the video from the libriary.. so now you should have a movieClip containing a lot of frames with video..

what you should NOT do is.. import a FLV into a FLA..then export that as a SWF and then try to import that one.. thats wrong.. hence the empty frames.

Peran
10-26-2006, 02:17 PM
you misunderstood me..

make a new fla

import the FLV into that one.. (you will se video symbol in library,.. thats the raw flv)

now IN the fla.. u can manually put the FLV into a movieclip.. read MOVIECLIP (not new swf).. ..so create a movieclip on stage.. and inster the video from the libriary.. so now you should have a movieClip containing a lot of frames with video..

Ok, gotcha. Still doesn't play tho... I'm sure it's because of something I'm doing wrong, I'd love to know what tho. I'd really appreciate it if you would take the time to take a look at the attached .FLA and tell me what the problem is...

what you should NOT do is.. import a FLV into a FLA..then export that as a SWF and then try to import that one.. thats wrong.. hence the empty frames.

Why is it wrong tho? I have two working .SWF's, one made with timeline animations, one containing video. Both work if run in the Flash Player, but only one of them can be imported, isn't that a bit strange? Or is it just a fact of life that I'll have to live with? :)


Peran.

Kraken
10-26-2006, 03:10 PM
for the record, NetStream will work with local .flv files.

Is there a reason you're not using the FLVPlayback component to show your video? You can move it, resize it and change things while it's playing. It's pretty robust and you can autohide the controls to make the interface minimal...


------------------------------------------------
To continue the discussion, however, here's a sample file you can learn from:
http://www.richpaul.com/flash/flv_pause_test.zip

It's got a simple video object pulling from a .flv that's in the same folder. I also added some simple pause functionality and a little seek bar. It's just a simple example, but that's how you do it.

squadjot
10-26-2006, 03:58 PM
peran >

in that movieclip u have..theres only one frame..

easy way is.. have a clean time line.. (no video object yet).. then drag the video object into the first frame.. and if the movie does not have frames enough to display all frames in video..it will ask you to add frametime.. in this case 152 ...try it.

Kraken..youre absolutely right.. i dont know why my little project here at home didnt succed with local file.. but i can see that youre right from your example.. i only had one go with FLV, but that was online.. ..anyways....so Peran both ways are now available.. i dont think the outcome will differ much..but the approach will be somewhat different.

Peran
10-26-2006, 04:10 PM
for the record, NetStream will work with local .flv files.

Is there a reason you're not using the FLVPlayback component to show your video? You can move it, resize it and change things while it's playing. It's pretty robust and you can autohide the controls to make the interface minimal...

No reason at all. I'm just a total newbie, oblivious to what tools are at my disposal. :D

Thanks for the file. One problem tho; I need to be able to convert the resulting .SWF to an uncompressed .AVI (I use FlashAnts' great converter), and when trying it on your file, no video shows up... So it seems the netstream thingie won't help... But thanks anyway!


Peran.

Peran
10-26-2006, 04:14 PM
in that movieclip u have..theres only one frame..

easy way is.. have a clean time line.. (no video object yet).. then drag the video object into the first frame.. and if the movie does not have frames enough to display all frames in video..it will ask you to add frametime.. in this case 152 ...try it.

Well, thing is, I don't want the video file to just play from frame 1 until it's done, I want to be able to control it from a single frame, all in AS, with a steady _root.onEnterFrame = function(), from which I'll be turning videoclips on and off and doing some other stuff.

If I could just find a way to put an .FLV inside a movieclip and be able to play, stop and pause that from a single AS frame, I'm a happy panda. ...assuming I can find a way that also works with the FlashAnts AVI converter thingie... :)


Peran.

squadjot
10-26-2006, 04:33 PM
but you CAN.. you just need to know your very basic flash actionscript.

you can use attach movie.. you rightclcik on the symbol in the libriary>properties> and gives it a linkage name.

then u can use attach movie.



right after you have attach it .. you stop the movie..

try have a look at http://www.jotbot.dk/videotest005.zip

Kraken
10-26-2006, 04:42 PM
"I need to be able to convert the resulting .SWF to an uncompressed .AVI"

Just curious as to why?

Peran
10-26-2006, 04:50 PM
but you CAN.. you just need to know your very basic flash actionscript.

you can use attach movie.. you rightclcik on the symbol in the libriary>properties> and gives it a linkage name.

then u can use attach movie.

right after you have attach it .. you stop the movie..

try have a look at http://www.jotbot.dk/videotest005.zip

*Yay* Ok, this certainly solves it for me! Thanks a bunch, I really appreciate it!


Peran. :D :D :D :D

squadjot
10-26-2006, 04:50 PM
"I need to be able to convert the resulting .SWF to an uncompressed .AVI"

Just curious as to why?

if he's making AV stuff? .. music video?..

theres a lot of poepl programming effects in flash and outputting them to video.

Peran
10-26-2006, 04:54 PM
"I need to be able to convert the resulting .SWF to an uncompressed .AVI"

Just curious as to why?

The final product is going to be a video clip, and I want to be able to do things in sections using Flash, then stitch it all together and add extra effects using Premiere, or possibly even After Effects.

So the thinking is:

1) Small effects (like the spinning ball attached above) programmed in Flash, then exported to AVI (so I can do heavy crap that Flash doesn't stand a chance at running in a decent frame rate).

2) Using Flash to script the resulting AVI files and add some extra minor stuff, like blend modes or filters.

3) Using video editing software to stitch it all together and fine-tune sync, possibly adding real footage aswell.


Peran.

Edit: Damn, squadjot beat me to it. :)

squadjot
10-26-2006, 04:59 PM
3) Using video editing software to stitch it all together and fine-tune sync, possibly adding real footage aswell.
Peran.

I would still argue against that tho.. then again..all depending on what u have to do.. if its straight up Math.. movements by calculating the tempo of the beat..and creating animations to it..THAT would be a project for flash..

If youre looking for perfection in image quality....and you want to do stuff with glow/color/blur/stretch/transform you'll be much better of with a "real" videoediting.. + it gives you 100 more features.. but sure.. you'll probably find out pretty quick whats best for you..

please look at the way ive buildt the function for you.. and how its used.. it will be a blessing when u get it under control.

you can use a similar function for adding/placing movieclip..

if youre planning on doing animations..you should check up on mx easing class. it can do cool stuff too..

again all relative..depending on what u have to do..