actionscript-3 - 在 as3/AIR mobile 中从相机录制视频、叠加位图、添加音频、保存到设备

标签 actionscript-3 video audio mobile air

我的任务是从移动设备上的摄像头录制实时视频流,然后叠加随时间变化的位图,并将音频 mp3 轨道添加到视频文件,然后将其保存到设备上的某个位置,例如相机胶卷。

我看到了一些有用的帖子,主要是这个:AS3 Flash/AIR recording video with webcam and save it

但显然,有些人在桌面上遇到过应用程序卡住的情况。我只能想象在移动设备上情况会更糟......

此外,如何将视频信息与单独的音频 mp3 一起添加到一个文件中?

有没有人完成过这样的事情?

最佳答案

更新,我让视频工作了。有点。有时我仍然会收到此错误。即使是短视频。

Error #2030: End of file was encountered.

有时它工作正常。但至少我能够从组件中录制 FLV。我还没有添加音频。

要运行此代码,您需要在此处找到 FLVRecorder:http://www.joristimmerman.be/wordpress/2008/12/18/flvrecorder-record-to-flv-using-air/

<?xml version="1.0" encoding="utf-8"?>

        import mx.core.UIComponent;
        import mx.events.FlexEvent;
        private var file:File;
        private var recorder:FLVRecorder=FLVRecorder.getInstance()
        private var fps:uint = 10;
        private var timer:Timer;
        protected function viewnavigator1_creationCompleteHandler(event:FlexEvent):void
        {

            //              2. Define the target FLV-file’s properties, the file instance to your flv-file, width & height, framerate and the systemManager instance, that’s a Flash internal declared variable and the optional duration in seconds:
            file=File.desktopDirectory.resolvePath("recording.flv");
            recorder.setTarget(file,320,320,fps,systemManager)

            var camera : Camera = Camera.getCamera();

            if (camera)
            {
                var ui      : UIComponent   = new UIComponent();
                var video   : Video     = new Video(320, 320);

                camera.setMode(320, 320, 24.);

                video.attachCamera(camera);
                ui.addChild(video);
                cameraGroup.addElement(ui);
            }

            timer = new Timer(1000/fps);
            timer.addEventListener(TimerEvent.TIMER, captureScreen);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, stopRecording);


        }

        protected function stopRecording(event:Event):void
        {
            timer.stop();
            //when saving is done
            recorder.addEventListener(FLVRecorderEvent.FLV_CREATED, fileMade)
            //when saving starts
            recorder.addEventListener(FLVRecorderEvent.FLV_START_CREATION, startCreatingFLV)

            // TODO Auto-generated method stub
            recorder.stopRecording()

        }

        private function startCreatingFLV(e:FLVRecorderEvent):void{
            recorder.addEventListener(FLVRecorderEvent.PROGRESS,onFLVCreationProgress)
        }

        private function onFLVCreationProgress(e:FLVRecorderEvent):void{
            //e.progress: percent complete (0 to 1)
            //pbSaving: ProgressBar component in Flex
            trace("saving progress ", e.progress,1);
        }

        protected function captureScreen(event:TimerEvent):void
        {
            trace("captured screen");
            recorder.captureComponent(movieGroup)     //DisplayObject, takes a screenshot from that component

        }

        protected function startRecording(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            timer.start();
        }

        protected function fileMade(event:Event):void
        {
            trace("file made");
        }

    ]]>
</fx:Script>
<s:VGroup>
    <s:HGroup>
        <s:Button label="start" click="startRecording(event)"/>
        <s:Button label="stop" click="stopRecording(event)"/>
        <s:Label id="progress" text="waiting..."/>
    </s:HGroup>
    <s:Group id="movieGroup" width="50%" height="50%">
        <s:Group id="cameraGroup" width="100%" height="100%"/>
        <s:Image source="image.png" width="25%" height="25%"/>
    </s:Group>
</s:VGroup>

关于actionscript-3 - 在 as3/AIR mobile 中从相机录制视频、叠加位图、添加音频、保存到设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7098420/

相关文章:

javascript - 继续在 Typescript 和 ActionScript 3 之间打字

c# - 将声音文件加载到 monogame 中

java - 使用JAVA的音频文件持续时间

image - 如何在 MATLAB 中从视频中选择特定帧?

android - Android编码器和语音邮件的文件格式

javascript - 如何创建和递增 2 位或 3 位十六进制数?

flash - 如何使用loadPCMFromByteArray?

actionscript-3 - 变量的AS3对象表示法

python - 如何使用OpenCV从mp4从mp4创建帧数组

javascript - 如何从 youtube url 获取视频的直接 url?