Simply put: How do I record from a
mjpg-streamer stream and add the current DATETIME as an overlay at the same time without re-encoding/using a lot of CPU power?
I would like to have the current date/time as an overlay in my
mjpg-streamer stream. I'm using a Raspberry Pi 2 and a MJPEG USB webcam connected to it.
Online I've found out that this isn't super easy because
mjpg-streamer simply streams the video and nothing else, and for an overlay to be added it would have to re-compress the frames.
My question would be how to do this in the most efficient way. I don't really need this to happen in the actual live stream, but I am also recording and I would very much like it to be included in the recording. This is how I am recording at the moment:
timeout 1h wget -O outfile.mjpg http://localhost:8760/?action=stream
This runs in an hourly cronjob. The
.mjpg file is quite big, but I re-encode later to
.mp4 on an external machine. I've used ffmpeg on the Raspberry Pi 2 in the past (directly from network stream to mp4 or avi) but it can't keep up and recording one hour would take more than an hour. After a day you suddenly got three ffmpeg processes still running and the whole system just can't keep up with anything anymore.
I know how to embed current date/time with ffmpeg, but obviously embedding it during re-encoding on another machine would not be the time of frame recording but re-encoding. Useless.
A thought: Each file is exactly one hour in recording length. For some reason the actual video length of the output file is less (~25mins for the
mp4 encoded file and I think ~40min for the
mjpg file). I don't know why but this doesn't bother me at all so I never cared. The filename contains the start of the recording.. Maybe there is a way to take that filename, use it as a start DATETIME and during ffmpeg encoding add 1 second to it everytime 1 second in the video has passed, and then embed that string in the video during re-encoding. No idea how to do that, especially since 1 second in the video doesn't equal 1 second of playback-time, but maybe someone knows... Doesn't sound practical but if that's the only way I'm okay with it.