我想使用libavcodec将HBitmap转换为视频流.我使用以下方法获取HBitmap:
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY);
Run Code Online (Sandbox Code Playgroud)
我想将它转换为YUV(这是我正在使用的编解码器所要求的).为此,我使用:
SwsContext *fooContext = sws_getContext(c->width,c->height,PIX_FMT_BGR32, c->width,c->height,PIX_FMT_YUV420P,SWS_FAST_BILINEAR,NULL,NULL,NULL);
uint8_t *movie_dib_bits = reinterpret_cast<uint8_t *>(bm.bmBits) + bm.bmWidthBytes * (bm.bmHeight - 1);
int dibrowbytes = -bm.bmWidthBytes;
uint8_t* data_out[1];
int stride_out[1];
data_out[0] = movie_dib_bits;
stride_out[0] = dibrowbytes;
sws_scale(fooContext,data_out,stride_out,0,c->height,picture->data,picture->linesize);
Run Code Online (Sandbox Code Playgroud)
但这根本不起作用......任何想法为什么?或者我怎么能这样做呢?
谢谢 !
我正在制作一个视频共享网站,我想从像youtube这样的另一个网站上的flv视频文件中截取屏幕截图.我使用PHP,但我不知道如何做到这一点.任何指导表示赞赏.
在Nexus One上(例如),相机应用程序能够以720x480("高"质量设置)捕获H.264视频.但是,使用MediaRecorder API时,它似乎总是以320x240的固定帧大小捕获.
我希望setVideoSize()方法控制帧大小(如下面的准备片段),但似乎没有效果(使用Froyo 2.2 Android SDK).
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setOutputFile(PATH_TO_FILE);
recorder.setVideoSize(720,480);
recorder.setPreviewDisplay(holder.getSurface());
recorder.prepare();
Run Code Online (Sandbox Code Playgroud)
关于Android开发人员列表的讨论似乎表明这是一个长期存在的问题.任何人都可以建议如何控制帧大小,或者是否可以使用当前的API进行控制?
我需要快速开发一些使用相机作为AV输入的软件.
假设驱动程序是为任何提供输入的设备安装的,我需要能够捕获图像并在winforms窗口中流式传输相机.
我找不到可以使用的组件,可能是因为我不知道它的正确名称.
Touchless是我无法使用的许可证.如果有人知道一个好的组件/代码我可以使用,即使它是收费的,我会很感激.
这是一个奇怪的问题.我没有更改任何涉及此项目的代码,但我的视频录制已经随机停止工作.当我尝试将电影保存到文件时,我收到以下错误:
错误域= NSOSStatusErrorDomain代码= -12780"操作无法完成.(OSStatus错误-12780.)"
我使用以下代码开始捕获:
- (void)initVideoCapture {
self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [self frontFacingCameraIfAvailable];
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:nil];
[self.captureSession addInput:videoInput];
aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
[self.captureSession addOutput:aMovieFileOutput];
[self detectVideoOrientation:aMovieFileOutput];
[self.captureSession setSessionPreset:AVCaptureSessionPresetMedium];
[self.captureSession startRunning];
Run Code Online (Sandbox Code Playgroud)
}
然后我从viewController调用此方法开始录制:
- (void) startRecord {
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"yyyyMMddHHmmss"];
NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];
[outputFormatter release];
NSString * fileString = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",newDateString]];
recordFileURL = [[NSURL alloc] initFileURLWithPath:fileString];
[aMovieFileOutput startRecordingToOutputFileURL:recordFileURL recordingDelegate:self];
Run Code Online (Sandbox Code Playgroud)
}
这时我在这个函数中得到了错误.
- (void)captureOutput:(AVCaptureFileOutput*)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL*)outputFileURL …
我试图imwrite
成功地在Windows窗体上显示图像,但它损坏了磁盘,所以我需要一个更好的方法来做到这一点.
下面是我当前的代码,它将图像临时写入硬盘:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
namedWindow("video",0);
VideoCapture cap(0);
flag = true;
while(flag){
Mat frame;
cap >> frame; // get a new frame from camera
**imwrite("vdo.jpg",frame);**
this->panel1->BackgroundImage = System::Drawing::Image::FromFile("vdo.jpg");
waitKey(5);
delete panel1->BackgroundImage;
this->panel1->BackgroundImage = nullptr;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用Mat
内存中的OpenCV时,我无法让它工作.以下代码片段是我到目前为止所尝试的:
this->panel1->BackgroundImage = System::Drawing::Bitmap(frame);
Run Code Online (Sandbox Code Playgroud)
要么
this->panel1->BackgroundImage = gcnew System::Drawing::Bitmap( frame.widht,frame.height,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) frame.imageData);
Run Code Online (Sandbox Code Playgroud)
我希望frame
在不使用的情况下显示在此代码中imwrite
.我该如何做到这一点?
我已经设法为Windows Phone 8应用程序设置代码,该应用程序初始化并可以使用AudioVideoCaptureDevice开始/停止录制视频.(将其保存到IRandomAccessStream)
//Initialize Camera Recording
Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480);
captureDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, resolution);
captureDevice.VideoEncodingFormat = CameraCaptureVideoFormat.H264;
captureDevice.AudioEncodingFormat = CameraCaptureAudioFormat.Aac;
captureDevice.RecordingFailed += captureDevice_RecordingFailed;
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何将此录制连接到VideoBrush以向用户显示录制内容.我希望用户能够看到他们正在录制的视频正在发生...
我知道有一个教程显示如何使用Windows Phone 7的旧API(CaptureSource,VideoDevice等)执行此操作,但我特别需要使用AudioVideoCaptureDevice进行记录.有谁知道如何在屏幕上显示这个视频?
从Apple文档中,在OSX 10.9中不推荐使用Quicktime框架,而是支持AVFoundations和AVKit.由于我不确定的原因,大多数文档忽略了一些名为VideoToolbox的框架涵盖了一些Quicktime框架替换功能.该替换功能包括解码和解压缩等.
我想解码和解压缩h.264编码的视频数据包(NAL包,TS包,等...),将它们放在像素缓冲区中,然后使用Core Video和OpenGL显示视频.
我通过usb从和编码盒获取视频数据包.我运行时此框不会显示[AVCaptureDevice devices]
.所以我不能使用大多数AVFoundation(据我所知)直接与盒子接口.但是,盒子附带了一个api,可以访问视频数据包文件.我可以将它们写入磁盘并创建一个可以通过quicktime播放的视频.但是进行实时播放是个问题.因此解码,解压缩和创建像素缓冲区的问题让我可以使用Core Video和OpenGL.
我想如果我可以创建一个像素缓冲区,我可以使用AVAssetWriterInputPixelBufferAdaptor
并找出一些方法来获得它AVCaptureSession
.如果我能做到这一点,我应该可以放弃使用OpenGL并使用AVFoundations和AVKit提供给我的工具.
另外,从我对AVFoundations文档的阅读中,每次他们谈论视频/音频数据流时,他们都在谈论两件事之一; 来自AVCaptureDevice的流或来自HTTP Live Stream的流处理.就像我之前说的那样,产生视频数据包的盒子不会显示为AVCaptureDevice
.并且,如果我不需要,我宁愿不构建/实现HTTP Live Streaming服务器.(希望我不需要,虽然我在网上看到有人做过.)
任何帮助将不胜感激.
谢谢!
compression video-capture decoding avfoundation osx-mavericks
我在WPF应用程序中使用web cam.我正在使用Expression Encoder进行视频捕获.对于视频捕获我创建了Job及其正常工作.虽然我想获得与视频分辨率相同的图片.为此,我使用ffmpeg从视频中提取第一帧.但是图像质量很低.优先考虑的是图像质量应该是最好的附加网络摄像头,分辨率应该与视频一样多.
要么我们在Expression Encode中有更好的选择来拍照,要么帮助我任何选择.
我正在开发一个OpenCV 3.0.0 32位分段项目,并从OpenCV 复制+粘贴一些示例代码.不幸的是,当我构建它时,包含所有依赖项和库,它会给我以下错误:
1>Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::VideoCapture::VideoCapture(void)" (??0VideoCapture@cv@@QAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::VideoCapture::~VideoCapture(void)" (??1VideoCapture@cv@@UAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall cv::VideoCapture::open(class cv::String const &)" (?open@VideoCapture@cv@@UAE_NABVString@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall cv::VideoCapture::isOpened(void)const " (?isOpened@VideoCapture@cv@@UBE_NXZ) referenced in function _main
Run Code Online (Sandbox Code Playgroud) video-capture ×10
video ×4
c++ ×3
avfoundation ×2
c# ×2
opencv ×2
.net ×1
android ×1
c#-4.0 ×1
compression ×1
decoding ×1
directshow ×1
ffmpeg ×1
flv ×1
ios4 ×1
php ×1
webcam ×1
wpf ×1