EDIT: @zach ofxTurboJpeg seems to be working very well- I can draw four delays + the camera feed @ 32-35fps. We’ll see how it goes when I start adding effects, but it’s a start!
My computer died and I had to buy a new one but got back on this project today. I’m trying three approaches based on your suggestions. Here’s how they’re going.
(N.b: I want to display up to five different videos at once with five different delays. I might want to change these, but for now it’d be: 0 seconds, 5 seconds, 30 seconds, 5 minutes and 1 hour. For 0 I can just draw the camera feed. For 5 and 30 seconds I could use a shared circular buffer. For 5 minutes and more are what I need a solution for, though of course it’d be more elegant to use the same solution for everything)
Solution 1:@theo I’ve tried your suggestion of writing raw jpgs. It seems to work well enough for just one image stream @ 30fps, but loading and drawing a second image every frame drops the framerate to the 21-23 range. My code is as follows:
void ofApp::update(){
m_camera.update();
ofImage f = m_camera.getPixels();
f.save(std::to_string(frameIndex++) + ".jpg");
}
//--------------------------------------------------------------
void ofApp::draw(){
int readIndexA = frameIndex - 30;
if (readIndexA < 0)
{
return;
}
ofImage a,b,c,d;
a.load(std::to_string(readIndexA) + ".jpg");
int readIndexB = frameIndex - 25;
b.load(std::to_string(readIndexB) + ".jpg");
//int readIndexC = frameIndex - 20;
//c.load(std::to_string(readIndexC) + ".jpg");
//int readIndexD = frameIndex - 10;
//d.load(std::to_string(readIndexD) + ".jpg");
ofEnableBlendMode(OF_BLENDMODE_ADD);
ofSetColor(255, 255, 255, 170);
a.draw(0, 0, 1920, 1080);
b.draw(0, 0, 1920, 1080);
//c.draw(0, 0, 1920, 1080);
//d.draw(0, 0, 1920, 1080);
ofDisableAlphaBlending();
ofSetColor(0, 255, 0);
ofDrawBitmapStringHighlight("FPS: " + std::to_string(ofGetFrameRate()), 10, 16);
}
While writing this I just re-noticed @zach 's message about /ofxTurboJpeg. Will give that a shot next!
Solution 2: Continue trying to get ofxDSHapVideoPlayer working with ofxFFmpegRecord-ed videos: @NickHardeman Using setOutputPixelFormat gets rid of the warning/auto-format-setting message but setting it to the OF_IMAGE_COLOR_ALPHA doesn’t help, even though this is the same pixel format used by ofxDSHapVideoPlayer for hapAlpha:
//from ofxDSHapVideoPlayer.cpp
else if (textureFormat == HapTextureFormat_RGBA_DXT5){
texData.glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
pix.allocate(width, height, OF_IMAGE_COLOR_ALPHA);
@pierre_tardif00 I tried ffmpeg -h encoder=hap -hide_banner
like you said and got this:
-format <int> E..V.... (from 11 to 15) (default hap)
hap E..V.... Hap 1 (DXT1 textures)
hap_alpha E..V.... Hap Alpha (DXT5 textures)
hap_q E..V.... Hap Q (DXT5-YCoCg textures)
-chunks <int> E..V.... chunk count (from 1 to 64) (default 1)
-compressor <int> E..V.... second-stage compressor (from 160 to 176) (default snappy)
none E..V.... None
snappy E..V.... Snappy
Besides format, which I know is being set correctly, could chunks or compressor have something to do with the problem…? I also ran ffmpeg -i on both the compatible virtualDub video and the incompatible ofxFFmpegRecorded video files and got this:
VirtualDub:
[avi @ 00000000006c7380] mov tag found in avi (fourcc Hap5)
[avi @ 00000000006c7380] non-interleaved AVI
Input #0, avi, from '120.avi':
Duration: 00:01:18.63, start: 0.000000, bitrate: 427040 kb/s
Stream #0:0: Video: hap (Hap5 / 0x35706148), rgba, 1920x1080, 427118 kb/s, 59.94 fps, 59.94 tbr, 59.94 tbn, 59.94 tbc
ofxFFmpegRecorder:
[avi @ 0000000000e97380] mov tag found in avi (fourcc Hap5)
Input #0, avi, from '0.avi':
Metadata:
encoder : Lavf57.67.100
Duration: 00:00:02.70, start: 0.000000, bitrate: 120392 kb/s
Stream #0:0: Video: hap (Hap5 / 0x35706148), rgba, 1280x720, 121874 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Do you think the lack of the “non-interleaved AVI” data point in the second video is concerning? I guess the next step is to follow the ofxDSHapVideoPlayer’s load() and play() through each line of code and spot differences between what happens with each of the two videos, though that’s so tedious I think I’ll try to advance the other two solutions first.
Solution 3: Trying to record in other codecs: @fresla Did you mean H264/265 ? I didn’t see 254/265 on the codec list for the ffmpeg version included with ofxFFmpegRecorder. 5 video playback with ofVideoPlayer seems to run smoothly enough with h264 avis… Trying to switch between reading a file and writing it on the same frame doesn’t work, so maybe I need three files per delay: one for writing, one for loading and one for recording. This seems inefficient, but I’ll give it a try if I don’t make progress with the jpeg solution. Haven’t tried .mp4 yet. @theo Do you recommend a fast codec for mp4?