我想知道如何使用我的网络摄像头在MATLAB中录制视频.
我正在尝试实现如下功能
最终录制的视频 =" 从前置摄像头捕获视频 + 从视频录制音频(我通过视频播放器播放)".
有关更多信息,请参阅附加屏幕截图.
使用下面给出的我的代码块:最后我得到的是一个视频,但没有音频.
但我想要实现的是" 最终录制的视频必须是以下内容的组合:' 从我的前置摄像头捕获的视频 + 仅录制我正在播放的视频文件中的音频.'"
我怎样才能实现上述功能?
这是我的代码.
" 录制 "按钮单击方法如下:
-(void) startRecording
{
[self initCaptureSession];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"video"
ofType:@"mp4"]];
[self playMovieAtURL:url];
[self startVideoRecording];
}
Run Code Online (Sandbox Code Playgroud)
" initCaptureSession ":使用此方法我使用前置摄像头使用"AVCaptureSession"录制视频
-(void) initCaptureSession
{
NSLog(@"Setting up capture session");
captureSession = [[AVCaptureSession alloc] init];
NSLog(@"Adding video input");
AVCaptureDevice *VideoDevice = [self frontFacingCameraIfAvailable];
if (VideoDevice)
{
NSError *error;
videoInputDevice = [AVCaptureDeviceInput deviceInputWithDevice:VideoDevice error:&error];
if (!error)
{ …
Run Code Online (Sandbox Code Playgroud) 我已经看过OpenCV的Python示例,介绍如何使用VideoCapture
和VideoWriter
捕获并写出视频文件.但我一直在:
OpenCV Error: Assertion failed (dst.data == dst0.data) in cvCvtColor, file
/tmp/opencv-n8PM/opencv-2.4.7.1/modules/imgproc/src/color.cpp, line 4422
Traceback (most recent call last):
File "examples/observer/observer.py", line 17, in <module>
video_writer.write(frame)
cv2.error: /tmp/opencv-n8PM/opencv-2.4.7.1/modules/imgproc/src/color.cpp:4422: error:
(-215) dst.data == dst0.data in function cvCvtColor
Run Code Online (Sandbox Code Playgroud)
清理相机.
这是代码:
#!/usr/bin/env python import cv2
if __name__ == "__main__":
# find the webcam
capture = cv2.VideoCapture(0)
# video recorder
fourcc = cv2.cv.CV_FOURCC(*'XVID') # cv2.VideoWriter_fourcc() does not exist
video_writer = cv2.VideoWriter("output.avi", fourcc, 20, (680, 480))
# record video …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AVFoundation录制视频.当我只将视频输入添加到会话时,一切正常,但是当我向其添加音频输入时,它会停止录制视频.(录制开始后立即调用Delegate方法).这是我的代码:
-(void) recordVideo
{
self.session = [[AVCaptureSession alloc] init];
if([session canSetSessionPreset:AVCaptureSessionPresetMedium])
session.sessionPreset = AVCaptureSessionPresetMedium;
CALayer *viewLayer = [self.cameraView layer];
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = viewLayer.bounds;
[viewLayer addSublayer:captureVideoPreviewLayer];
self.videoInput = [AVCaptureDeviceInput deviceInputWithDevice:[self frontFacingCameraIfAvailable] error:nil];
self.audioInput = [AVCaptureDeviceInput deviceInputWithDevice:[self audioDevice] error:nil];
if(!videoInput)
NSLog(@"Couldn't create input!");
else
{
self.output= [[AVCaptureMovieFileOutput alloc] init];
NSString *pathString = [[self outputPath]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *fileURL = [NSURL fileURLWithPath:pathString];
[session beginConfiguration];
[session removeInput:[self videoInput]];
if([session canAddInput:videoInput])
[session addInput:videoInput];
[videoInput release];
[session removeInput:[self audioInput]];
if([session canAddInput:audioInput])
[session addInput:audioInput]; …
Run Code Online (Sandbox Code Playgroud) 我必须创建一个Android应用程序,我正在尝试使用表面视图录制视频和捕获图像.到目前为止,我能够捕获视频,但在录制视频中遇到问题.我的视频录制代码是 -
onCreate(){
..
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
startRecording();
.
.
}
protected void startRecording() throws IOException
{
if(mCamera==null)
mCamera = Camera.open();
String filename;
String path;
path= Environment.getExternalStorageDirectory().getAbsolutePath().toString();
Date date=new Date();
filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4";
File file=new File(path,filename);
mrec = new MediaRecorder();
mCamera.lock();
mCamera.unlock();
mrec.setCamera(mCamera);
mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mrec.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setOutputFile(path+filename);
mrec.setMaxDuration(10000);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(width, height);
try {
mCamera.setPreviewDisplay(surfaceHolder);
} catch (IOException e) { …
Run Code Online (Sandbox Code Playgroud) 我有自动脚本每晚运行(大约50个脚本或测试用例).我想录制每个测试用例的视频(Selenium Java API + Cucumber).是否有任何工具或方法可用于分别控制每个测试用例的视频录制?我希望在测试用例设置开始录制和拆解停止录制期间,并在本地保存具有指定名称和日期的视频.所以每个测试用例应该有50个视频(更好的是只保存测试用例失败的视频)
有没有办法在我用于我的设置和拆卸的代码中集成此功能?
我想使用任何格式的ffmpeg在mac OS上录制现场网络摄像头视频.我尝试了很多,但无法找到重新录制视频的命令.所以请任何人都可以告诉我ffmpeg命令捕获视频使用web cam for mac os.
Thanx提前.
我想用网络摄像头录制用户视频并使用Ruby On Rails将录制的视频保存到服务器,这应该适用于所有浏览器.我尝试了以下方法,但这并没有解决我的问题.
请让我知道,如果有任何机构有一个标准的解决方案(适用于所有/大多数浏览器,最好是开源).
任何帮助将不胜感激.提前致谢!
我需要旋转视频来调整我的一些需求.我将在下面的列表中解释详细信息.
我正在创建一个像应用程序一样的Vine.我必须录制视频片段,然后将所有部分合并为一个文件.我正在使用mp4解析器库和最新版本1.0-RC-26使用其网站上提供的示例在Android应用程序上执行此操作:此处
如果所有视频具有相同的方向,附加视频示例工作正常但我发现从前置摄像头录制视频的一些问题,因此快速解决方案是将视频方向记录设置为270.此解决方案的不好部分是该段此方向在合并视频上显示错误的方向.
我可能的解决方案是旋转视频以应用我在不同情况下所需的内容,但我没有使用我的代码的工作示例.在互联网上搜索我在这里找到了这样的解决方案.此代码的问题是与上一版本不兼容(它给出了编译错误).我也试图理解库的逻辑,但我没有结果.例如,我尝试使用setMatrix
Movie对象上的指令,但它根本不起作用.
public static void mergeVideo(int SegmentNumber) throws Exception {
Log.d("PM", "Merge process started");
Movie[] inMovies = new Movie[SegmentNumber] ;
//long[] Matrix = new long[SegmentNumber];
for (int i = 1 ; i <= SegmentNumber; i++){
File file = new File(getCompleteFilePath(i));
if (file.exists()){
FileInputStream fis = new FileInputStream(getCompleteFilePath(i));
//Set rotation I tried to experiment with this instruction but is not working
inMovies [i-1].setMatrix(Matrix.ROTATE_90);
inMovies [i-1] = MovieCreator.build(fis.getChannel());
Log.d("PM", "Video " + i + " …
Run Code Online (Sandbox Code Playgroud) 昨天,当我正在制作我的游戏时,我决定要包含一些视频,显示主题和教程的潜行峰值等等.然后我决定检查如何录制我的场景或节点.环顾四周后,我总结说没有简单的方法可以做到这一点所以我决定制作自己的实用程序,我希望与大家分享.
请知道我或多或少是一个初学者,而且我没有长时间编码.我知道它可能没有做好,而且可以用更好的方式完成.无论如何它在这里.
/*
* JavaFX SceneCaptureUtility 2016/07/02
*
* The author of this software "Eudy Contreras" grants you ("Licensee")
* a non-exclusive, royalty free, license to use,modify and redistribute this
* software in source and binary code form.
*
* Please be aware that this software is simply part of a personal test
* and may in fact be unstable. The software in its current state is not
* considered a finished product and has plenty of room for improvement …
Run Code Online (Sandbox Code Playgroud)