[英]Recording Flash Webcam FMS 4.5 to Mp4 results in terrible quality
I have successfully setup recording webcam to FLV using FMS 4.5 developer edition, so I wanted to attempt recording to an Mp4 next. 我已经使用FMS 4.5开发人员版成功设置了将摄像头录制到FLV的功能,因此我想接下来尝试将其录制到Mp4。 I am doing a silent save of the video file because the goal here is to be able to have these videos playable outside of Flash/FMS. 我正在对视频文件进行静默保存,因为此处的目标是能够在Flash / FMS之外播放这些视频。 I set the program up to save the Mp4 file generated by FMS, but the quality is terrible. 我设置程序来保存FMS生成的Mp4文件,但是质量太差了。 I am seeing green distortion when movement is captured, and heavy pixelation. 捕获运动时我看到绿色失真,并且像素沉重。 Here is my test application code that saves the video file after 5 seconds of recording. 这是我的测试应用程序代码,可以在录制5秒后保存视频文件。 Can anyone please point out where I am going wrong? 有人可以指出我要去哪里了吗? Any help is greatly 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, so I am answering my own question. 好的,我在回答我自己的问题。 I found the answer here along with the link to the tool to process: adobe help site 我在这里找到了答案以及要处理的工具的链接: adobe帮助站点
You must convert the files after recording them using a post-processing tool so they can be viewed in other video players. 使用后处理工具录制文件后,必须转换文件,以便可以在其他视频播放器中查看它们。
Edit: VLC can actually play the unprocessed file, so I thought it was a quality issue at first! 编辑:VLC实际上可以播放未处理的文件,所以我一开始认为这是质量问题!
You could try to change the quality of the video stream VideoStreamSettings.setQuality(bandwidth:int, quality:int)
( link ). 您可以尝试更改视频流VideoStreamSettings.setQuality(bandwidth:int, quality:int)
( link )的VideoStreamSettings.setQuality(bandwidth:int, quality:int)
。
You only set one of the bandwidth
or quality
values and leave the other to 0. I would try to set bandwidth (measured in bytes per second) to 750000 (6 Mbps), which should be plenty for anything less than full HD. 您仅将bandwidth
或quality
值之一设置为零,而将另一个设置为0。我将尝试将带宽(以每秒字节数为单位)设置为750000(6 Mbps),这对于除全高清之外的任何东西都应该足够。
So, in your case, you could try: 因此,就您而言,您可以尝试:
h264Settings.setQuality(750000, 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.