Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:32:46+00:00 2026-05-28T01:32:46+00:00

This is my first question here :D, first sorry about my english. My question

  • 0

This is my first question here :D, first sorry about my english.

My question is basically how can i save a flash Movie Clip to FLV.

The Movie Clip is generated by users and it has various sounds and animations and i need to save an FLV to send it to Youtbue.

What have I tried:
I found some question here about using an Alchemy Lib that I am using to grab the Movie Clip frame to frame and save it to Bitmap.

The Alchemy Lib converts those frames to FLV like a charm and supports saving chunks of sound using ByteArray.

In this situation my Problem is, how can i grab the sound of Movie Clip to send it to Alchemy Lib?
I´ve tried using:

SoundMixer.computeSpectrum(sndData, false, 2);

Witch returns me a byteArray in sndData variable but is useless since it´s used for render Audio Wave forms on screen.

Thougth aboud using

Sound.extract();

but i believe the sound class is used only for one MP3 sound and I need to grab the mixed sounds generated by Movie Clip.

Is there another way to generate the FLV from a MovieClip?

Below some of my code:

I based my code under the tutorial that I found in this link: http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/

private const OUTPUT_WIDTH:Number = 550;
private const OUTPUT_HEIGHT:Number = 400;
private const FLV_FRAMERATE:int = 24;
private var _baFlvEncoder:ByteArrayFlvEncoder;      
public var anime:MovieClip;


//Starts recording
public function startRecording()
{
    this.addEventListener(Event.ENTER_FRAME, enterFrame);

    //Initialize the Alchemy Lib
    _baFlvEncoder = new ByteArrayFlvEncoder(stage.frameRate);
    _baFlvEncoder.setVideoProperties(OUTPUT_WIDTH, OUTPUT_HEIGHT);
    _baFlvEncoder.setAudioProperties(FlvEncoder.SAMPLERATE_22KHZ);
    _baFlvEncoder.start();      

}
//Stops recording
public function stopRecording()
{
    this.removeEventListener(Event.ENTER_FRAME, enterFrame);
    _baFlvEncoder.updateDurationMetadata();

    // Save FLV file via FileReference
    var fileRef:FileReference = new FileReference();
    fileRef.save(_baFlvEncoder.byteArray, "test.flv");          

    _baFlvEncoder.kill();

}

//The Main Loop  activated by StartRecording
public function enterFrame(evt:Event)
{
    var bmpData:BitmapData = new  BitmapData(OUTPUT_WIDTH, OUTPUT_HEIGHT, false, 0xFFFFFFFF);
    bmpData.draw(anime);

    var sndData:ByteArray = new ByteArray();
    SoundMixer.computeSpectrum(sndData, false, 2);

    _baFlvEncoder.addFrame(bmpData, sndData);
    bmpData.dispose();


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:32:47+00:00Added an answer on May 28, 2026 at 1:32 am

    Done it! ( Well… almost 😀 )

    It was complicated but since my problem was only the audio of MovieClip I’ve created a class that acts like a mixer.

    The mixer is responsible to play all the sounds using a unique SampleDataEvent that mix the bytes of all my sounds. Also it generates a single sound data in ByteArray when i execute the startRecording funcion. Kind Complicated to explain but here is the code for the mixer:

    /**** MySoundMixer initializations omitted ***/
    
    //Generates the sound object to start the stream 
    //for reproduce the mixed sounds. 
    public function startStream()
    {
        fullStreamSound= new Sound();
        fullStreamSoundData = new ByteArray();            
        this.fullStreamSoundChannel = this.fullStreamSound.play();
    }
    
    //Adds a sound in the soundlib 
    //(See: MySound object for more details)
    public function addSound(sound:MySound, key:String)
    {
        sound.initialize();
        sounds.push({sound:sound, key:key});
    }
    
    //Play a sound in the sound lib
    public function play(key)
    {
        var founded:MySound = null;
        for (var i = 0; i < sounds.length; i++)
        {
            if (key == sounds[i].key)
            {
                founded = sounds[i].sound;
                break;
            }
        }
        if (founded != null)
        {
            founded.play();
        }
    }
    
    // The SampleDataEvent function to Play the sound and
    // if recording is activated record the sound to fullStreamSoundData
    public function processSampleData(event:SampleDataEvent)
    {
        var pos = 0;
    
        var normValue:Number = 1 / this.sounds.length;
        while (pos < BUFFER)
        {
    
            var leftChannel:Number = 0;
            var rightChannel:Number = 0;
    
            for (var i = 0; i < this.sounds.length; i++)
            {
                var currentSound:MySound = this.sounds[i].sound;
                var result = currentSound.getSampleData();
                leftChannel += result.leftChannel * normValue;
                rightChannel += result.rightChannel * normValue;
            }
    
            event.data.writeFloat(leftChannel);
            event.data.writeFloat(rightChannel);
    
            if (isRecording)
            {
                fullStreamSoundData.writeFloat(leftChannel);
                fullStreamSoundData.writeFloat(rightChannel);
            }
    
            pos++;
        }
    }
    
    //Starts recording
    public function startRecording()
    {
        this.isRecording = true;
    }
    
    //Stops recording
    public function stopRecording()
    {
        this.isRecording = false;
    }
    

    The SampleDataEvent is used for play and extract the mixed sounds at the same time.

    I also had to create a MySound class that extends the Sound object in order to extract the sampleData of each sound (method getSampleData()) at current buffer used by processSampleData method. The MySound class also starts playing when Mixer starts (sending 0 bytes for both channels) and will stop also when the mixer stops, it will only start to send the byte information of the music when play() function is called.

    The class that i have created is something like this:

    /**** MySound initializations omitted ***/
    public function initialize()
    {
        this.extractInformation(null);
    }
    
    //Override the play function to avoid playing.
    //(The play act will be triggered by SoundMixer class)
    override public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel 
    {
        this.isPlaying = true;
        this.currentPhase = 0;
        return null;
    }
    
    // On each buffer in sampledata i read the chunk of sound bytes
    public function getSampleData()
    {
        var leftChannel:Number = 0;
        var rightChannel:Number = 0;
        if (this.isPlaying) {
            if (currentPhase < totalPhases)
            {
                this.soundData.position = currentPhase * 8;
                leftChannel = this.soundData.readFloat();
                rightChannel = this.soundData.readFloat();
                this.currentPhase ++;
            } else 
            {
                stopPlaying();
            }
        }
        return { leftChannel:leftChannel, rightChannel:rightChannel };
    }
    
    //Extracts information of the sound object in order to 
    //split it in several chunks of sounds.
    public function extractInformation(evt:Event)
    {
        trace("Inicializando o som " + this.id3);
        this.soundData = new ByteArray();
        this.extract(soundData, int(this.length * SAMPLE_44HZ + 10000));
        this.totalPhases = this.soundData.length / 8;
        this.currentPhase = 0;
    }
    
    ///Stop playing means stop extracting bytes
    public function stopPlaying()
    {
        this.isPlaying = false;
    }
    

    With that, i have generated a unique ByteArray object that contains the hole sound information of the mixer.
    all i had to do is start the mixer when the movieclip starts and stop it also when the movieclip stops.
    The ByteArray information with the sound object is passed addFrame(bitmapData, sndData) of Alchemy Lib that records it successfully.

    It is working well in my project but i probably will need to optmize the code.

    Thanks all guys that helped me!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, this's my first time to ask a question here. So, I don't have
this is my first question here so I hope I can articulate it well
first of all this is my third question about web services here and i
this is my first question here so sorry if I do something wrong or
This is my first question here, so sorry in forward if it is not
this is my first question here :) I know that I should not check
Greetings to all! This is my first question here on stackoverflow. I have a
Ok, I need help. This is my first question here. Background: I am working
this is my first question to stackoverflow so here it goes... I use cruise
this is my first question.. so, here we go. i have a site, 100%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.