Hey, I would like to share an a much better way to record timelapse video in real-time, using slightly modified rpicam-vid. No ffmpeg is required.
Note that this is just proof-of-concept just to show that it works, so expect some poor coding standard. I'll leave it to the rest to provide better code implementation.
This is a follow-up from the last approach that I used for capturing timelapse in real-time and upload to Youtube (viewtopic.php?p=2126573). That approach, however, uses rpicam-still and ffmpeg which can be CPU intensive and requires a cooling fan.
Currently, rpicam-vid has "--framerate" option that applies to both camera control settings and video encoder setting.
So for timelapse capture, I decided to have "--framerate" option only apply to camera control settings, while I hardcoded the framerate in the encoder setting.
Here are my modified code for files originated from https://github.com/raspberrypi/rpicam-a ... in/encoder:
https://gist.github.com/ongeelim/25034e ... 458846e6d0
Modified code lines for:
Here are the results when running it on Raspberry Pi 3B+ and Camera Module 3.
This is the 1080p timelapse video recorded for 3 hours, and outputted as 3 minutes video.
Camera framerate set to 1fps, while encoder (libav) set to 60fps
https://www.youtube.com/watch?v=ER5jm7KAaAI
Performance wise, rpicam-vid was running within 3% CPU or less, throughout the recording.
(On the side note, my temperature-controlled cooling fan was not enabled throughout the recording (It will need to be at least 65C to be enabled)) Here's another surprising result.
I was able to run 4k timelapse recording for 30 minutes, and outputted as 30 second video without any issue.
Camera framerate set to 1fps, while encoder (libav with libx264 codec) set to 60fps
(My temperature-controlled cooling fan was enabled after 7 minutes of recording)
https://www.youtube.com/watch?v=3GrUZELmNGU
To put this into perspective, when I tried to use rpicam-still to capture 4k images and then pipe these images to fffmpeg for stitching in real-time, my Raspberry Pi just hang/crash after less than 20 frames processed.
I would like to hear your feedback on these findings. Thanks
Note that this is just proof-of-concept just to show that it works, so expect some poor coding standard. I'll leave it to the rest to provide better code implementation.
This is a follow-up from the last approach that I used for capturing timelapse in real-time and upload to Youtube (viewtopic.php?p=2126573). That approach, however, uses rpicam-still and ffmpeg which can be CPU intensive and requires a cooling fan.
Currently, rpicam-vid has "--framerate" option that applies to both camera control settings and video encoder setting.
So for timelapse capture, I decided to have "--framerate" option only apply to camera control settings, while I hardcoded the framerate in the encoder setting.
Here are my modified code for files originated from https://github.com/raspberrypi/rpicam-a ... in/encoder:
https://gist.github.com/ongeelim/25034e ... 458846e6d0
Modified code lines for:
- libav_encoder.hpp: Line 60
- libav_encoder.cpp: Line 22 (Encoder framerate value goes there), 28, 233, 334, 394-395, 402
- h264_encoder.cpp: Line 134-135 (Encoder framerate value goes there)
Here are the results when running it on Raspberry Pi 3B+ and Camera Module 3.
This is the 1080p timelapse video recorded for 3 hours, and outputted as 3 minutes video.
Camera framerate set to 1fps, while encoder (libav) set to 60fps
https://www.youtube.com/watch?v=ER5jm7KAaAI
Performance wise, rpicam-vid was running within 3% CPU or less, throughout the recording.
(On the side note, my temperature-controlled cooling fan was not enabled throughout the recording (It will need to be at least 65C to be enabled)) Here's another surprising result.
I was able to run 4k timelapse recording for 30 minutes, and outputted as 30 second video without any issue.
Camera framerate set to 1fps, while encoder (libav with libx264 codec) set to 60fps
(My temperature-controlled cooling fan was enabled after 7 minutes of recording)
https://www.youtube.com/watch?v=3GrUZELmNGU
To put this into perspective, when I tried to use rpicam-still to capture 4k images and then pipe these images to fffmpeg for stitching in real-time, my Raspberry Pi just hang/crash after less than 20 frames processed.
I would like to hear your feedback on these findings. Thanks
Statistics: Posted by ongeelim — Sun Nov 17, 2024 5:46 pm