Wednesday 15 June 2011

actionscript 3 - Recording Flash Webcam FMS 4.5 to Mp4 results in terrible quality -



actionscript 3 - Recording Flash Webcam FMS 4.5 to Mp4 results in terrible quality -

i have setup recording webcam flv using fms 4.5 developer edition, wanted effort recording mp4 next. doing silent save of video file because goal here able have these videos playable outside of flash/fms. set programme save mp4 file generated fms, quality terrible. seeing greenish distortion when motion captured, , heavy pixelation. here test application code saves video file after 5 seconds of recording. can please point out going wrong? help appreciated.

package com { import flash.display.*; import flash.net.*; import flash.utils.timer; import flash.events.*; import flash.filesystem.file; import flash.media.*; public class main extends movieclip { private var nc:netconnection; private var ns:netstream; private var nsplayer:netstream; private var vid:video; private var vidplayer:video; private var cam:camera; private var mic:microphone; private static const local_video:string = "mycamera"; private static const video_fps:uint = 30; private static const save_folder_name:string = "saved_videos"; private static const path_to_fms:string = "c:/program files/adobe/flash media server 4.5"; private var timer:timer = new timer(5000, 1); public function main() { addeventlistener(event.added_to_stage, init); } private function init(evt:event):void { removeeventlistener(event.added_to_stage, init); nc = new netconnection(); nc.addeventlistener(netstatusevent.net_status, onnetstatus); nc.connect("rtmp://localhost/publishlive/mycamera"); } function onnetstatus(evt:netstatusevent):void { if(evt.info.code == "netconnection.connect.success") { publishcamera(); displaypublishingvideo(); timer.addeventlistener(timerevent.timer_complete, timercompleted); timer.start(); } } private function timercompleted(evt:timerevent) { trace("timer completed"); timer.stop(); ns.close(); ns = null; var savefile:file = new file(path_to_fms + "/applications/publishlive/streams/" + local_video + "/" + local_video + ".mp4"); var filename:string = "video" + ".mp4"; var dir:file = file.documentsdirectory.resolvepath(save_folder_name); dir.createdirectory(); var filetosave = dir.resolvepath(filename); if(filetosave.exists) { filetosave.deletefile(); } savefile.copyto(filetosave, true); } private function publishcamera() { var h264settings:h264videostreamsettings = new h264videostreamsettings(); h264settings.setprofilelevel(h264profile.baseline, h264level.level_3_1); cam = camera.getcamera(); cam.setmode(stage.stagewidth, stage.stageheight, video_fps, true); cam.setquality(0, 90); cam.setkeyframeinterval(15); cam.setmotionlevel(100); mic = microphone.getmicrophone(); mic.setsilencelevel(0); mic.rate = 11; ns = new netstream(nc); ns.videostreamsettings = h264settings; ns.attachcamera(cam); ns.attachaudio(mic); ns.publish("mp4:mycamera.mp4", "record"); } private function displaypublishingvideo():void { vid = new video(); vid.width = stage.stagewidth; vid.height = stage.stageheight; vid.attachcamera(cam); addchild(vid); } }

}

ok, answering own question. found reply here along link tool process: adobe help site

you must convert files after recording them using post-processing tool can viewed in other video players.

edit: vlc can play unprocessed file, thought quality issue @ first!

actionscript-3 flash h.264 flash-media-server webcam-capture

No comments:

Post a Comment