timscaffidi / ofxvideorecorder Goto Github PK
View Code? Open in Web Editor NEWA fast multi-threaded video recording extension using ffmpeg
License: Other
A fast multi-threaded video recording extension using ffmpeg
License: Other
Can I record my OFwindow with this?
I love the addon it is great!
I do not have unistd.h. . .
Hi,
Thanks for this addon. I've been trying to use this to record video from an USB camera. In a first run, I can generate a .mp4 file successfully, but when I try to record a second time, I get an error similar to this:
".\pipe\videoPipe776: Invalid argument"
The second .mp4 file never wraps up. I suspect the recording pipe is not being closed properly, but I'm not sure why. Any hints on this?
I'm using OF 0.9.3, and Windows 10. Camera is Logitech C920. My .cpp follows below:
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup() {
Globals::config("config.xml");
//Basic configuration:
ofSetWindowPosition(Globals::window.x, Globals::window.y);
ofSetWindowShape(Globals::window.width, Globals::window.height);
ofSetFullscreen(Globals::windowFullscreen);
ofSetFrameRate(30);
vidGrabber.setVerbose(false);
if (Globals::verbose) {
ofSetLogLevel(OF_LOG_VERBOSE);
vidGrabber.setVerbose(true);
}
micSetDeviceError = true;
cameraSetDeviceError = true;
//Setting up camera device and video recording settings:
#ifdef TARGET_WIN32
vidRecorder.setFfmpegLocation(Globals::FFMPEGLocation); // custom FFMPEG location
#endif
fileName = "video";
fileExt = ".mp4"; // ffmpeg uses the extension to determine the container type. run 'ffmpeg -formats' to see supported formats
vidRecorder.setVideoCodec("mpeg4");
vidRecorder.setVideoBitrate("4000k");
//vidRecorder.setMovFileExtension("mov");
//vidRecorder.setAudioCodec("mp3");
//vidRecorder.setAudioBitrate("192k");
vector <ofVideoDevice> videoDevices = vidGrabber.listDevices();
for (int i = 0; i < videoDevices.size(); i++) {
//cout << " ----> [videoDevice at " << i << "]: " << videoDevices.at(i).deviceName << " -- " << Globals::cameraDeviceName << endl;
if (videoDevices.at(i).deviceName == Globals::cameraDeviceName) {
if (Globals::verbose) {
cout << " ----> OK! Setting up video device at [" << i << "]: " << videoDevices.at(i).deviceName << endl;
}
vidGrabber.setDeviceID(i);
vidGrabber.setDesiredFrameRate(30);
vidGrabber.initGrabber(Globals::video.width, Globals::video.height);
cameraSetDeviceError = false;
}
}
//Setting up microphone device and sound recording settings:
sampleRate = 44100;
channels = 2;
for (int i = 0; i < soundStream.getDeviceList().size(); i++) {
//cout << " ----> [Sound device at " << i << "]: " << soundStream.getDeviceList().at(i).name << " -- " << Globals::micDeviceName << endl;
if (soundStream.getDeviceList().at(i).name == Globals::micDeviceName) {
if (Globals::verbose) {
cout << " ----> OK! Setting up sound device at [" << i << "]: " << soundStream.getDeviceList().at(i).name << endl;
}
soundStream.setDeviceID(i);
soundStream.setup(this, 0, channels, sampleRate, 256, 4);
micSetDeviceError = false;
}
}
isRecording = false;
showRecordingText = false;
canMoveVideoFile = false;
buttonLock = Globals::buttonLock;
ofBackground(0);
ofTrueTypeFont::setGlobalDpi(72);
msgFont.load("Fonts/verdana.ttf", 30, true, true);
msgFont.setLineHeight(20.0f);
msgFont.setLetterSpacing(1.035);
camNotFoundMsg = "Camera nao encontrada.";
audioDevNotFoundMsg = "Dispositivo de gravacao de audio nao encontrado.";
}
void ofApp::exit() {
vidRecorder.close();
}
//--------------------------------------------------------------
void ofApp::update(){
if (!cameraSetDeviceError) {
vidGrabber.update();
if (vidGrabber.isFrameNew() && isRecording) {
bool success = vidRecorder.addFrame(vidGrabber.getPixelsRef());
if (!success) {
ofLogWarning("This frame was not added!");
}
}
}
if (canMoveVideoFile && !vidRecorder.isRecording()) {
moveVideoFile();
canMoveVideoFile = false;
}
}
//--------------------------------------------------------------
void ofApp::draw(){
if (!cameraSetDeviceError && !micSetDeviceError) {
ofSetColor(255, 255, 255);
vidGrabber.draw(0, 0);
if (isRecording) {
ofSetColor(255, 0, 0);
ofCircle(50, Globals::window.height - 50, 20);
if (ofGetFrameNum() % 29 == 0) {
showRecordingText = !showRecordingText;
}
if (showRecordingText) {
ofSetColor(255, 127);
msgFont.drawString("Gravando", 75, Globals::window.height - 40);
}
}
}
else {
ofSetColor(255, 255, 255);
if (cameraSetDeviceError) {
msgFont.drawString(camNotFoundMsg,
Globals::window.width/2 - msgFont.getStringBoundingBox(camNotFoundMsg, 0, 0).width/2,
Globals::window.height / 2 - 100);
}
if (micSetDeviceError){
msgFont.drawString(audioDevNotFoundMsg,
Globals::window.width / 2 - msgFont.getStringBoundingBox(audioDevNotFoundMsg, 0, 0).width / 2,
Globals::window.height / 2 + 100);
}
}
}
//--------------------------------------------------------------
void ofApp::audioIn(float *input, int bufferSize, int nChannels){
if(isRecording)
vidRecorder.addAudioSamples(input, bufferSize, nChannels);
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
if (!cameraSetDeviceError) {
if (key == 'r') {
isRecording = !isRecording;
if (isRecording && !vidRecorder.isInitialized()) {
videoFileName = fileName + ofGetTimestampString();
vidRecorder.setup(videoFileName, Globals::video.width, Globals::video.height, 30, sampleRate, channels);
// Start recording
vidRecorder.start();
}
else if (!isRecording && vidRecorder.isInitialized()) {
vidRecorder.setPaused(true);
}
else if (isRecording && vidRecorder.isInitialized()) {
vidRecorder.setPaused(false);
}
}
if (key == 'c') {
isRecording = false;
vidRecorder.close();
//canMoveVideoFile = true;
}
}
}
//--------------------------------------------------------------
void ofApp::moveVideoFile() {
ofFilePath p;
string o = p.getAbsolutePath(videoFileName + fileExt);
string n = Globals::networkMediaFolderPath + videoFileName + fileExt;
MoveFileA(o.c_str(), n.c_str());
}
Thanks!
Hi I'm attempting to use this to record some openframework output.
I have it producing a video file, but it looks like one of those scrolling sidewalk adverts, the frames scroll upwards instead of proceeding like a normal video. Any idea why?
[warning] ofThread: - name: Thread 4 - Calling startThread with verbose is deprecated.
[warning] ofThread: - name: Thread 2 - Calling startThread with verbose is deprecated.
ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers
built with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --disable-doc --arch=x86_64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, rawvideo, from '/Users/benjgorman/Code/OF_ROOT/addons/ofxTimeline/duplicate_lips/bin/data/ofxvrpipe0':
Duration: N/A, start: 0.000000, bitrate: 566231 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1024x768, 566231 kb/s, 30 tbr, 30 tbn, 30 tbc
Please use -b:a or -b:v, -b is ambiguous
Output #0, mov, to '/Users/benjgorman/Code/OF_ROOT/addons/ofxTimeline/duplicate_lips/bin/data/testMovie2015-04-16-03-06-40-055.mov':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1024x768, q=2-31, 800 kb/s, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc56.26.100 mpeg4
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
frame= 11 fps=0.0 q=2.5 size= 95kB time=00:00:00.36 bitrate=2112.2kbits/s
frame= 27 fps= 24 q=6.3 size= 208kB time=00:00:00.90 bitrate=1897.6kbits/s
frame= 42 fps= 25 q=10.4 size= 286kB time=00:00:01.40 bitrate=1671.6kbits/s
frame= 58 fps= 26 q=14.1 size= 356kB time=00:00:01.93 bitrate=1508.2kbits/s
frame= 71 fps= 26 q=13.0 size= 399kB time=00:00:02.36 bitrate=1379.8kbits/s
frame= 86 fps= 27 q=12.4 size= 465kB time=00:00:02.86 bitrate=1329.8kbits/s
frame= 98 fps= 26 q=16.5 size= 515kB time=00:00:03.26 bitrate=1291.1kbits/s
frame= 111 fps= 26 q=23.5 size= 560kB time=00:00:03.70 bitrate=1240.6kbits/s
frame= 121 fps= 25 q=20.6 size= 583kB time=00:00:04.03 bitrate=1184.7kbits/s
frame= 136 fps= 26 q=22.8 size= 642kB time=00:00:04.53 bitrate=1160.2kbits/s
frame= 152 fps= 26 q=22.3 size= 690kB time=00:00:05.06 bitrate=1115.6kbits/s
frame= 166 fps= 26 q=22.8 size= 731kB time=00:00:05.53 bitrate=1082.9kbits/s
frame= 181 fps= 26 q=22.2 size= 773kB time=00:00:06.03 bitrate=1050.0kbits/s
frame= 196 fps= 26 q=25.8 size= 831kB time=00:00:06.53 bitrate=1041.5kbits/s
frame= 212 fps= 27 q=25.5 size= 876kB time=00:00:07.06 bitrate=1015.4kbits/s
frame= 227 fps= 27 q=25.2 size= 918kB time=00:00:07.56 bitrate= 993.6kbits/s
frame= 242 fps= 27 q=20.0 size= 971kB time=00:00:08.06 bitrate= 985.7kbits/s
frame= 258 fps= 27 q=22.8 size= 1018kB time=00:00:08.60 bitrate= 970.0kbits/s
frame= 273 fps= 27 q=26.7 size= 1062kB time=00:00:09.10 bitrate= 956.2kbits/s
frame= 289 fps= 27 q=22.9 size= 1111kB time=00:00:09.63 bitrate= 944.9kbits/s
frame= 304 fps= 27 q=24.2 size= 1164kB time=00:00:10.13 bitrate= 941.2kbits/s
frame= 320 fps= 28 q=23.9 size= 1211kB time=00:00:10.66 bitrate= 930.3kbits/s
frame= 335 fps= 28 q=26.3 size= 1260kB time=00:00:11.16 bitrate= 924.1kbits/s
frame= 350 fps= 28 q=19.5 size= 1315kB time=00:00:11.66 bitrate= 923.3kbits/s
frame= 364 fps= 28 q=26.4 size= 1359kB time=00:00:12.13 bitrate= 917.2kbits/s
frame= 380 fps= 28 q=23.8 size= 1405kB time=00:00:12.66 bitrate= 908.9kbits/s
frame= 396 fps= 28 q=23.0 size= 1449kB time=00:00:13.20 bitrate= 899.2kbits/s
frame= 411 fps= 28 q=25.1 size= 1508kB time=00:00:13.70 bitrate= 901.6kbits/s
frame= 426 fps= 28 q=21.6 size= 1551kB time=00:00:14.20 bitrate= 894.9kbits/s
frame= 441 fps= 28 q=24.6 size= 1597kB time=00:00:14.70 bitrate= 890.0kbits/s
frame= 457 fps= 28 q=25.3 size= 1649kB time=00:00:15.23 bitrate= 887.0kbits/s
frame= 472 fps= 28 q=27.0 size= 1709kB time=00:00:15.73 bitrate= 889.8kbits/s
frame= 488 fps= 28 q=31.0 size= 1786kB time=00:00:16.26 bitrate= 899.4kbits/s
frame= 503 fps= 28 q=31.0 size= 1859kB time=00:00:16.76 bitrate= 908.3kbits/s
frame= 519 fps= 28 q=31.0 size= 1946kB time=00:00:17.30 bitrate= 921.3kbits/s
frame= 534 fps= 28 q=31.0 size= 2024kB time=00:00:17.80 bitrate= 931.7kbits/s
frame= 549 fps= 28 q=31.0 size= 2096kB time=00:00:18.30 bitrate= 938.2kbits/s
frame= 565 fps= 28 q=31.0 size= 2173kB time=00:00:18.83 bitrate= 945.4kbits/s
frame= 577 fps= 28 q=31.0 size= 2236kB time=00:00:19.23 bitrate= 952.4kbits/s
frame= 590 fps= 28 q=24.8 size= 2309kB time=00:00:19.66 bitrate= 961.8kbits/s
frame= 605 fps= 28 q=31.0 size= 2384kB time=00:00:20.16 bitrate= 968.4kbits/s
frame= 619 fps= 28 q=31.0 size= 2455kB time=00:00:20.63 bitrate= 974.6kbits/s
frame= 634 fps= 28 q=31.0 size= 2531kB time=00:00:21.13 bitrate= 981.0kbits/s
frame= 643 fps= 28 q=31.0 size= 2579kB time=00:00:21.43 bitrate= 985.6kbits/s
frame= 659 fps= 28 q=31.0 size= 2659kB time=00:00:21.96 bitrate= 991.6kbits/s
frame= 674 fps= 28 q=24.8 size= 2742kB time=00:00:22.46 bitrate= 999.8kbits/s
frame= 690 fps= 28 q=31.0 size= 2826kB time=00:00:23.00 bitrate=1006.6kbits/s
frame= 704 fps= 28 q=31.0 size= 2901kB time=00:00:23.46 bitrate=1012.7kbits/s
frame= 719 fps= 28 q=31.0 size= 2976kB time=00:00:23.96 bitrate=1017.3kbits/s
frame= 734 fps= 28 q=24.8 size= 3059kB time=00:00:24.46 bitrate=1024.3kbits/s
frame= 750 fps= 28 q=31.0 size= 3145kB time=00:00:25.00 bitrate=1030.6kbits/s
frame= 765 fps= 28 q=31.0 size= 3223kB time=00:00:25.50 bitrate=1035.6kbits/s
frame= 780 fps= 28 q=31.0 size= 3303kB time=00:00:26.00 bitrate=1040.7kbits/s
frame= 796 fps= 28 q=31.0 size= 3394kB time=00:00:26.53 bitrate=1047.9kbits/s
frame= 812 fps= 28 q=31.0 size= 3476kB time=00:00:27.06 bitrate=1052.2kbits/s
frame= 826 fps= 28 q=31.0 size= 3549kB time=00:00:27.53 bitrate=1056.0kbits/s
frame= 842 fps= 28 q=24.8 size= 3637kB time=00:00:28.06 bitrate=1061.4kbits/s
frame= 854 fps= 28 q=24.8 size= 3699kB time=00:00:28.46 bitrate=1064.5kbits/s
frame= 870 fps= 28 q=31.0 size= 3785kB time=00:00:29.00 bitrate=1069.1kbits/s
[rawvideo @ 0x103024800] Invalid buffer size, packet size 2045952 < expected frame_size 2359296
Error while decoding stream #0:0: Invalid argument
frame= 879 fps= 27 q=31.0 size= 3833kB time=00:00:29.30 bitrate=1071.6kbits/s
frame= 879 fps= 27 q=31.0 Lsize= 3837kB time=00:00:29.30 bitrate=1072.8kbits/s
video:3833kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.119554%
When I call setup I get this message spit back out. I thought maybe it was because I was using 10.6.8, but I upgraded to 10.9 and still no luck. It seems to be one computer of mine in particular that is having this issue, and I've gotten it to work on 10.8 with 0.71 and 0.74. I've also tried with different versions of ffmpeg, neither working. This is what the console returns when I call setup:
mkfifo: /Users/aferriss/Desktop/adam: File exists
mkfifo: photos/ofx/of_v0.7.4_osx_release/apps/myApps/lkOpticalFlow/bin/data/ofxvrpipe0: No such file or directory
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 21 2014 12:30:59 with llvm-gcc 4.2.1 (LLVM build 2335.15.00)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=llvm-gcc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
great addon, thanks for making it.
even when i setup the recorder to no use audio like so vidRecorder.setup(_name+fileExt,_w,_h, 24);
the code still print this error:
[warning] The video recorder failed to write some audio samples!:
which means vidRecorder.hasAudioError()
is true for some reason
Hello,
Is there support planned for OpenFrameworks 0.10.0? Getting the error of "Poco/Condition.h' file not found" in the example but do not get in OF 9.8
Thank you,
Tegan
Hey Tim,
Thanks for putting together this addon. It's just what I need. I'm getting an error I can't find my way around. I've disabled all audio, which got rid of some of the errors except the Bad File Descriptor error. This is the output I get:
[warning] ofQTKitGrabber: setDesiredFrameRate(): cannot set framerate for QTKitGrabber
[verbose] ofQTKitGrabber: attached video device: FaceTime HD Camera (Built-in)
[verbose] ofQTKitGrabber: starting video session
bash: VC/ofx_v0.9.1/examples/video/ofxVideoRecorderExample/bin/data/ofxvrpipe0: No such file or directory
[verbose] Recording.
[ error ] ofxVideoDataWriterThread: 12:12:32:542 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to write some frames!:
bash: VC/ofx_v0.9.1/examples/video/ofxVideoRecorderExample/bin/data/ofxvrpipe0: No such file or directory
bash: VC/ofx_v0.9.1/examples/video/ofxVideoRecorderExample/bin/data/testMovie2016-03-14-12-12-32-527.mov: No such file or directory
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[warning] The video recorder failed to write some frames!:
[warning] The video recorder failed to write some frames!:
[ error ] ofxVideoDataWriterThread: 12:12:32:628 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to write some frames!:
[warning] The video recorder failed to write [s erroor me] ofxfVirdaemoeDsa!ta:W r
iterThread: 12:12:32:695 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to wr[i errort e] osfoxmVei deforDaamteasW!ri:t er
Thread: 12:12:32:729 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to write some frames!:
[warning] The video recorder failed to wr[ite esrormoer fr] aofxmVeisd!eo:D at
aWriterThread: 12:12:32:794 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to write some frames!:
The disordered text is pasted as is. I'm guessing both the main and secondary threads are printing to console at once.
Secondary question: I need to simultaneously record many separate videos at once. Do you foresee any problems with having 10-14 simultaneous instances of the ofxVideoRecorder running at once?
Thanks!
Testing this out with the RPI and 0.8.0 release. I'm getting this from the command line.
I have an image sequence to record with an audio mp3 file as the sound source.
So far I can record the image sequence with the mp3 playing in the background of the app and by using WavTap to hijack the audio stream on Mac OS X 10.10.
But this solution isn't elegant that I need to install WavTap to capture the audio given I do have a standalone mp3 file already.
// setting up ofxVideoRecorder
void ofApp::setupVideoRecording() {
fileName = imageFolder;
fileExt = ".mov";
// override the default codecs if you like
// run 'ffmpeg -codecs' to find out what your implementation supports (or -formats on some older versions)
vidRecorder.setVideoCodec("mpeg4");
vidRecorder.setVideoBitrate("4000k");
vidRecorder.setAudioCodec("mp3");
vidRecorder.setAudioBitrate("192k");
// set wavTap as the sound input source
for (auto i : soundStream.getDeviceList()) {
if (i.name == "WavTap: WavTap") {
soundStream.setDeviceID(i.deviceID);
break;
}
}
sampleRate = 44100;
channels = 2;
soundStream.setup(this, 0, channels, sampleRate, 256, 4);
vidRecorder.setup(fileName+"-"+ofGetTimestampString()+fileExt, 1920, 1080, appFPS, sampleRate, channels);
}
// recording the audio
void ofApp::audioIn(float *input, int bufferSize, int nChannels){
if(bRecording)
vidRecorder.addAudioSamples(input, bufferSize, nChannels);
}
There are some container formats supporting demuxing.
Thank you!
And thanks again for making this add-on!:thumbsup:
I have created a branch for OF 0.9.0: https://github.com/smallfly/ofxVideoRecorder/tree/0.9.0
Maybe you could create a 0.9.0 branch on your GitHub repo and I could create a PR for these small updates, or do you prefer to push these to the Master right away?
Cheers,
One can disable the audio encoding with -an
option.
if(audioCodec != "")
outputSettings << " -acodec " << audioCodec
<< " -ab " << audioBitrate;
else
outputSettings << " -an";
hey, I added Poco with Project Generator and
#include "ofxXmlPoco.h"
Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "unistd.h" ofxVideoRecorderExample openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 10
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "ioctl" is undefined ofxVideoRecorderExample openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 28
Error (active) E0020 identifier "FIOBIO" is undefined ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 28
Error (active) E0282 the global scope has no "open" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 80
Error (active) E0282 the global scope has no "write" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 96
Error (active) E0282 the global scope has no "close" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 133
Error (active) E0282 the global scope has no "open" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 165
Error (active) E0282 the global scope has no "write" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 177
Error (active) E0282 the global scope has no "close" ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 209
Error (active) E0020 identifier "usleep" is undefined ofxVideoRecorderExample \openframeworks\addons\ofxVideoRecorder\src\ofxVideoRecorder.cpp 341
1.Where was the file saved ? There are no mov. in the "bin" folder.
2.I would like to save the movie drawn by my project in the file. Is it possible with your ofxVideoRecorder?
Where should I rewrite? Now the FaceTime HD camera has been attached.
Sorry for elementary question. Any help would be appreciated. Thank you.
I can grab audio I'm synthesizing from audioOut function, but it doesnt record ofSoundPlayer playback. Is there any way of doing that? Thanks
i have been using your addon for a while now. and it works very well.
i have 4 separate OF apps running at the same time, all using the recorder.
things work well but once in a while i get
[notice ] ofxVideoRecorder: setupCustomOutput
[notice ] videoRecorder: start
[ error ] ofxVideoDataWriterThread: 12:02:37:528 - write to PIPE failed with error -> 32 - Broken pipe.
[ error ] ofxVideoDataWriterThread: 12:02:37:572 - write to PIPE failed with error -> 32 - Broken pipe.
[ error ] ofxVideoDataWriterThread: 12:02:37:636 - write to PIPE failed with error -> 32 - Broken pipe.
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
would you know why?
here is what the print out usually looks like when the recording works correctly:
https://gist.github.com/stephanschulz/471cdec81855ea5f122278b9e03b23df
and here when xcode crashes:
https://gist.github.com/stephanschulz/b26a04dd892de55f6f8c124d0b6dd30e
here is the bash script that your addon generates:
cmd bash --login -c '/Applications/of_v0.9.3_osx_release/apps/zoom-pavilion/zoom_pavilion_faceTracker/bin/data/ffmpeg -y -an -r 24 -s 160x88 -f rawvideo -pix_fmt rgb24 -i /Applications/of_v0.9.3_osx_release/apps/zoom-pavilion/zoom_pavilion_faceTracker/bin/data/ofxvrpipe0 -r 24 -vcodec mpeg4 -b 800k -acodec pcm_s16le -ab 128k /Users/stephan/Desktop/recordings/2016-05-11-13-34-06-171_0.mov' &
hello
i am on OS X 10.10 with of 0.9.3.
i am trying to record a video with alpha and set pixelFormat = "rgba" but the resulting .mov file still has a black background.
i am creating a FBO with GL_RGBA, which draws fine with it's transparencies.
i pass the FBO pixels in to the addon and also check that the pixels still have 4 channels.
bool ofxVideoRecorder::addFrame(const ofPixels &pixels)
{
ofLog()<<"pixels channels "<<pixels.getNumChannels();
...
}
here is the console print out:
[notice ] videoRecorder: start
[notice ] pixels channels 4
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[warning] ofxVideoDataWriterThread: got file descriptor 17
Input #0, rawvideo, from '/Applications/of_v0.9.3_osx_release/apps/tres_caras-faceSplit/splitting_04_rec/bin/data/ofxvrpipe0':
Duration: N/A, start: 0.000000, bitrate: 566231 kb/s
Stream #0:0: Video: rawvideo (RGBA / 0x41424752), rgba, 576x1024, 566231 kb/s, 30 tbr, 30 tbn, 30 tbc
Output #0, mov, to '/Users/stephan/Desktop/recordings/2016-08-08-16-28-12-663.mov':
Metadata:
encoder : Lavf57.25.100
Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 576x1024, q=2-31, 800 kb/s, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.24.102 mpeg4
Side data:
unknown side data type 10 (24 bytes)
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
[notice ] pixels channels 4
I noticed a couple of issues -- it's all a little hazy but some notes if helpful
a) open(...) used to get the file handle for the pipes, seems unhappy when the path has spaces
b) the commands for ffmpeg seem unhappy when there is spaces in the path to ffmpeg
about (a) I am not 100% certain but I think it's an issue.
the solution for me for (a) was to use a relative path without spaces -- since I'm doing something kind of funky and having ffmpeg inside the app bundle and for (b) the solution was to modify how the command is put together and wrap the path to ffmpeg in some quotes.
I'll investigate this some more before a PR but in case it's helpful, just writing some notes here.
Not working in version OF 0.9.8 running osx 10.12.6
Files being saved are giving me this.
ffmpeg output
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
OF output not data written...
any thoughts?
Hi, I've installed the addon, I have ffmpeg installed (the one from Ubuntu packages, Ubuntu 12.04 64 bits) since a while.
I can run ffmpeg commands from console and record the streaming from a webcam in this way:
ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out2.avi
However when running the example I got these errors, so any file is built:
"The video recorder failed to write some frames!"
"The video recorder failed to write some audio samples!"
I don't know if something related with codec issues or maybe a different version of ffmpeg as well, since Ubuntu version is a fork. I appreciate any hint to solve this.
Thanks
Ro
I have ffmpeg installed on my Mac. When I try to close the video, I will get a spinning beachball. Seems the program is stuck in this loop
while(frames.size() > 0 && audioFrames.size() > 0) {
// if there are frames in the queue or the thread is writing, signal them until the work is done.
videoThread.signal();
audioThread.signal();
}
One other thing, the ffmpeg is installed in /usr/local/Cellar/ffmpeg/2.2.2. So should I set the location to /usr/local/Cellar/ffmpeg/2.2.2/bin/ffmpeg?
Thanks!
Please rename setPixelFormat to setPixelInputFormat. This makes things a lot clearer imo.
Also please add an h264 .mp4 example...it's a very common target. Thanks!
e.g.
fileExt = ".mp4";
vidRecorder.setVideoCodec("libx264");
vidRecord.setPixelOutputFormat("yuv420p");
When I compile ofxVideoRecorder with the current OF git version, I get this error:
ofxVideoRecorder/src/ofxVideoRecorder.h:65: error: 'Condition' in namespace 'Poco' does not name a type
Poco::Condition condition;
^
Can you help? I really like this addon!
I keep getting the error ‘ofxVideoRecorder’ does not name a type
. I have updated the project, placed the addon in the correct directory. Should I be including the header file in ofApp.h
and if yes then how would it find the file during make?
[warning] ofQTKitGrabber: setDesiredFrameRate(): cannot set framerate for QTKitGrabber
[verbose] ofQTKitGrabber: attached video device: FaceTime HD Camera
[verbose] ofQTKitGrabber: starting video session
mkfifo: /Users/xxxxxx/Desktop/OF/Mac/of_v0.9.1_osx_release: File exists
mkfifo: 2/apps/myApps/1_recorder/bin/data/ofxvrpipe0: No such file or directory
mkfifo: /Users/xxxxxx/Desktop/OF/Mac/of_v0.9.1_osx_release: File exists
mkfifo: 2/apps/myApps/1_recorder/bin/data/ofxarpipe0: No such file or directory
[verbose] Recording.
[ error ] ofxAudioDataWriterThread: 14:31:17:801 - write to PIPE failed with error -> 9 - Bad file descriptor.
[ error ] ofxAudioDataWriterThread: 14:31:17:807 - write to PIPE failed with error -> 9 - Bad file descriptor.
[ error ] ofxAudioDataWriterThread: 14:31:17:813 - write to PIPE failed with error -> 9 - Bad file descriptor.
bash: /Users/xxxxxx/Desktop/OF/Mac/of_v0.9.1_osx_release: Permission denied
Hello,
I'm having problems to save my file in a specific folder, any suggestion?
Here's the code:
if(key=='r'){
bRecording = !bRecording;
if(bRecording && !vidRecorder.isInitialized()) {
vidRecorder.setupCustomOutput(vidGrabber.getWidth(), vidGrabber.getWidth(), 30,"/Users/usuario/Google Drive/test.mov");
vidRecorder.start();
}
Hope you can help me.
Thanks.
Not sure if this is a issue related to ofxVideoRecorder or to ffmpeg itself.
I'm using ofxVideoRecorder in a project and I'm having some strange issues. When I start running the application everything is fine and all videos are recorded perfectly but after some time some of the vids are completely scrambled, like that:
It does not always happen and sometime it happens after 30 mins sometime after an hour or more.
The program does not use much memory but it's quite CPU intensive. I've tried to make some of the processes threaded and the CPU usage went down but the bug did not disappear... I've also tried most of the codec available: mjpeg, h264, mpeg4 and even hap but at some point this bug keeps reappearing.
Did anyone run into a similar problem? Any suggestions?
Console error message :
Using makefile: Makefile
Execution of 'make.exe -s -f Makefile Debug' in 'C:\Users\Samuel\Desktop\ofxVideoRecorder-master\ofxVideoRecorderExample' failed.
Nothing to be done.
I have an application where I read a video file with ofVideoPlayer (presumably AVFoundation), apply effects to it, and write each frame to ofxVideoRecorder. However, I'm having difficulty figuring out how exactly to pipe in the audio. I read the example source code, but that's getting it from a device and not from the videoplayer and I'm not sure how to bridge that gap.
Where I am currently is getting a segfault when I close and not recording any audio, despite my audio event handler being called. I'm doing the following:
recorder_.setVideoCodec("mjpeg");
recorder_.setVideoBitrate("2500k");
recorder_.setAudioCodec("mp3");
recorder_.setAudioBitrate("192k");
recorder_.setup("out-" + ofGetTimestampString() + ".mov", video_->getWidth(), video_->getHeight(), 60);
recorder_.start();
// int nOutputChannels, int nInputChannels, ofBaseApp *appPtr, int sampleRate, int bufferSize, int nBuffers
ofSoundStreamSetup(2, 0, this, 44100, 256, 4);
void ofApp::audioReceived(float *input, int bufferSize, int nChannels){
if (recording_) {
recorder_.addAudioSamples(input, bufferSize, nChannels);
}
}
But receive the following error and a segfault:
[ fatal ] ofThreadErrorLogger::exception: System exception: cannot lock mutexits/s speed=1.04x
frame= 433 fps= 63 q=24.8 Lsize= 33543kB time=00:00:07.20 bitrate=38164.4kbits/s speed=1.05x
video:33541kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.008100%
Segmentation fault: 11
I assume there is something that I'm doing wrong. Any help would be appreciated.
In the close() methods there are calls to setNonblocking():
//set pipes to non_blocking so we dont get stuck at the final writes
setNonblocking(audioPipeFd);
setNonblocking(videoPipeFd);
But it seems that the variables audioPipeFd and videoPipeFd are never initialized.
Should the calls the setNonblocking() be removed?
Basically, the addon used to work perfectly, then it suddenly stopped working (without me changing any code anywhere). Now, ffmpeg no longer starts to encode until after I try to close the program, so all my files end up being empty. This is the output of compiling and running the ofxVideoRecorderExample
code:
<< imagine this frame skipping message keeps going for a while>>
[verbose] ofxVideoRecorder: recDelta = -0.0333333. Too many video frames, skipping.
[verbose] ofxVideoRecorder: recDelta = -0.0333333. Too many video frames, skipping.
[verbose] ofxVideoRecorder: recDelta = -0.0333333. Too many video frames, skipping.
The recoded video file is now complete.
[verbose] ofxAudioDataWriterThread: closing pipe: /home/job/Dev/OpenFrameworks/of_v0.9.3_linux64_release/apps/myApps/videoRecorderExample/bin/data/ofxarpipe0
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s16le, from '/home/job/Dev/OpenFrameworks/of_v0.9.3_linux64_release/apps/myApps/videoRecorderExample/bin/data/ofxarpipe0':
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
[warning] ofxVideoDataWriterThread: got file descriptor 16
[verbose] ofxVideoDataWriterThread: closing pipe: /home/job/Dev/OpenFrameworks/of_v0.9.3_linux64_release/apps/myApps/videoRecorderExample/bin/data/ofxvrpipe0
Input #1, rawvideo, from '/home/job/Dev/OpenFrameworks/of_v0.9.3_linux64_release/apps/myApps/videoRecorderExample/bin/data/ofxvrpipe0':
Duration: N/A, bitrate: 221184 kb/s
Stream #1:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 640x480, 221184 kb/s, 30 tbr, 30 tbn, 30 tbc
Please use -b:a or -b:v, -b is ambiguous
Output #0, mov, to '/home/job/Dev/OpenFrameworks/of_v0.9.3_linux64_release/apps/myApps/videoRecorderExample/bin/data/testMovie2016-06-06-21-58-50-363.mov':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 640x480, q=2-31, 800 kb/s, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc56.60.100 mpeg4
Stream #0:1: Audio: mp3 (libmp3lame) (.mp3 / 0x33706D2E), 44100 Hz, stereo, s16p, 192 kb/s
Metadata:
encoder : Lavc56.60.100 libmp3lame
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Stream #0:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
void ofApp::recordingComplete(ofxVideoRecorderOutputFileCompleteEventArgs& args){
cout << "The recoded video file is now complete." << endl;
shared_ptr<ofVideoPlayer> player = std::make_shared<ofVideoPlayer>();
player->load(args.fileName); // error
players.push_back(player);
}
console says
error loading asset tracks: Cannot Open
Do you know why I can't load the file there?
Hi,
I just create new iOS project with ofxVideoRecorder add ons.
I copied code from ofApp.cpp & ofApp.h.
When I run this project it give me following error.
[verbose] ofxiOSSoundStreamDelegate: SoundInputStream :: Unknown (1718449215)
[verbose] ofxiOSSoundStreamDelegate: SoundInputStream :: Unknown (1718449215)
[verbose] Recording.
[ error ] ofxVideoDataWriterThread: 14:26:52:411 - write to PIPE failed with error -> 9 - Bad file descriptor.
[warning] The video recorder failed to write some frames!:
[warning] The video recorder failed to write some frames!:
[verbose] ofxVideoRecorder: recDelta = -0.0333333. Too many video frames, skipping.
It can prompt for permission of Camera and Microphone. But not recording video.
Please help. Thanks in advance.
Hi there,
When using your example code. The recorded video seems 2 times to fast. So if I record a video of a stopwatch for 10 seconds. The resulting video file is around 5 seconds long. If I record 20 seconds, the video file is roughly 10 seconds long.
Any clues on what is going on?
My setup:
Mac OS X,
Xcode 6.1
OpenFrameworks: 0.8.4
I'm trying to record 2 videos at once but it hangs when trying to create the 2nd pipe. Know of any reason why this might be happening?
Hello,
I am trying to get ofxVideoRecorder to work in Windows (works great on Ubuntu).
I am using the branch osx-and-win which has no issue tracker.
The application output looks ok to me though... any ideas? Thanks
edit:
There seems to be some sound in the video, but I am only getting a little zap sound in the first few milliseconds of the movie. Could there be something wrong with the samplerate?
***** VIDEOINPUT LIBRARY - 0.2000 - TFW2013 *****
SETUP: Setting up device 0
SETUP: Logitech Webcam C930e
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 640 by 480
SETUP: trying requested format RGB24 @ 1280 by 720
SETUP: trying format RGB24 @ 1280 by 720
SETUP: trying format RGB32 @ 1280 by 720
SETUP: trying format RGB555 @ 1280 by 720
SETUP: trying format RGB565 @ 1280 by 720
SETUP: trying format YUY2 @ 1280 by 720
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.
[notice ] ofSoundStream::listDevices:
[0] Default Device [in:2 out:2] (default in) (default out)
[1] Speakers (Realtek High Definition Audio) [in:0 out:2]
[2] Microfoon (Logitech Webcam C930e) [in:2 out:0]
[3] Microphone (Realtek High Definition Audio) [in:2 out:0]
[0] Default Device [in:2 out:2] (default in) (default out)
[1] Speakers (Realtek High Definition Audio) [in:0 out:2]
[2] Microfoon (Logitech Webcam C930e) [in:2 out:0]
[3] Microphone (Realtek High Definition Audio) [in:2 out:0]
[notice ] FFMpeg Command1: ffmpeg -y -f s16le -acodec mp3 -ar 44100 -ac 2 -i \\.\pipe\videoPipe505 -b:a 192k C:\Users\Frans\Desktop\movie2016-11-26-15-26-49-267.mp4_atemp.m4a
[notice ] Audio Pipe:
==========================
Audio Pipe Connected Successfully
==========================
[notice ] FFMpeg Command2: ffmpeg -y -r 30 -s 1280x720 -pix_fmt rgb24 -f rawvideo -i \\.\pipe\videoPipe46 -pix_fmt yuv420p -vcodec mpeg4 -b:v 2000k C:\Users\Frans\Desktop\movie2016-11-26-15-26-49-267.mp4_vtemp.mp4
[notice ] Video Pipe:
==========================
Video Pipe Connected Successfully
==========================
[verbose] Recording.
[verbose] ofxVideoRecorder: recDelta = 0.0147846. Not enough video frames for desired frame rate, copied this frame 6 times.
(...)
[verbose] ofxVideoRecorder: recDelta = 0.0258503. Not enough video frames for desired frame rate, copied this frame 2 times.
[warning] ofxAudioDataWriterThread: 15:26:53:867 - The thread is not running anymore let's get out of here!
[warning] ofxVideoDataWriterThread: 15:26:53:867 - The thread is not running anymore let's get out of here!
[notice ] FFMpeg Merge:
==============================================
Merge Command
==============================================
[notice ] FFMpeg Merge: ffmpeg -y -i C:\Users\Frans\Desktop\movie2016-11-26-15-26-49-267.mp4_vtemp.mp4 -i C:\Users\Frans\Desktop\movie2016-11-26-15-26-49-267.mp4_atemp.m4a -c:v copy -c:a copy -strict experimental C:\Users\Frans\Desktop\movie2016-11-26-15-26-49-267.mp4.mp4
[notice ] ofxVideoRecorder:
==============================================
Closed ffmpeg
==============================================
SETUP: Disconnecting device 0
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer...
SETUP: filter removed NullRenderer
SETUP: removing filter Sample Grabber...
SETUP: filter removed Sample Grabber
SETUP: removing filter AVI Decompressor...
SETUP: filter removed AVI Decompressor
SETUP: removing filter Smart Tee...
SETUP: filter removed Smart Tee
SETUP: removing filter Logitech Webcam C930e...
SETUP: filter removed Logitech Webcam C930e
SETUP: freeing Capture Graph
SETUP: freeing Main Graph
SETUP: Device 0 disconnected and freed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.