We're trying to make a video flythrough of a pointcloud using pclvisualizer.
What we're doing is updating the camera position, then save a frame, then update the camera position ...
This way we get a lot of png files, which can then be fed to ffmpeg for processing. The individual png's look fine, but we have issues with the video:
- the bitrate of the video is extremely high (I guess because the encoder fails to make deltas between the successive frames)
- the video doesn't appear fluent and there is flicker (when using melt to step thru the individual frames, the frames look okay)
On youtube there are many examples of fluent point cloud videos (eg radiohead house of cards videoclip). I wonder if anybody knows the secret in here.
Currently I am using the following commands for converting the saved frames into a H264 video (the frames are Full HD png's named 'ssht-ddddd.png' where 'd' is a frame number digit): $ ffmpeg -r 120 -f image2 -s 1920x1080 -i ssht-%05d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 $ ffmpeg -y -i test.mp4 -r 30 -s 1920x1080 -c:v libx264 -strict -2 -movflags faststart down_sampled.mp4
This results in a 25 FPS H264 Full HD video with a bit rate of 70.6 Mb/s.
Here is a note i made to myself a long time ago that i barely understand now, but may be helpful. Setting the frame rate is important. I’m pretty sure i scrapped it together based off a number of different resources. The OpenGL stuff is assuming you’re downloading a texture from the GPU or something (I think i was using a frame buffer), so it shouldn’t be too relevant.
However, I think one thing that may be relevant is not having an alpha channel? I hope it is useful, but i sent this note to myself more than two years ago and clearly didn’t do a very good job making it a useful note…
static unsigned long FRAME = 0;
char buffer ;
int n=sprintf (buffer, "%lu", FRAME);
cv::Mat img(height, width, CV_8UC3);
//use fast 4-byte alignment (default anyway) if possible