picamera2 icon indicating copy to clipboard operation
picamera2 copied to clipboard

[BUG] capture_MJPEG no timestamp

Open tf4ong opened this issue 3 years ago • 3 comments

Hi,

I tried to capture_MJPEG example script for video, and added pts='timestamp.txt' in the start_recording similar to h264.

But the timestamp.txt was empty.

tf4ong avatar Oct 12 '22 16:10 tf4ong

Thanks for reporting this, will work on this soon.

In the meantime if you add the pts parameter in this example - https://github.com/raspberrypi/picamera2/blob/main/examples/capture_mjpeg_v4l2.py you should get a timestamp.txt file.

chrisruk avatar Oct 13 '22 09:10 chrisruk

Hi Chris,

I tried and the timestamp does seem to work but there seem to be a slight issue? I am not that familiar with codecs so it might not be concerning?

I have tried to use that script but I cannot open the video file without changing its name extension to .h264 Is there a way I can confirm the video file codec?

tf4ong avatar Oct 13 '22 14:10 tf4ong

Thanks for pointing that out! That appears to be a bug too, it shouldn't be h264 data.

chrisruk avatar Oct 13 '22 15:10 chrisruk

I remember ages ago there was a problem where the mjpeg hardware encoder wasn't (always) getting included in the firmware builds, and it would fall back to h264. Might this be the same thing?

davidplowman avatar Oct 19 '22 10:10 davidplowman

Ah yeah it could well be that. I checked that I am still setting V4L2_PIX_FMT_MJPEG.

When using 'file' on the output it says - test.mjpeg: JVT NAL sequence, H.264 video @ L 40

chrisruk avatar Oct 19 '22 11:10 chrisruk

Just found something interesting @davidplowman

If I add start_x=1, to /boot/config.txt I do get - test.mjpeg: JPEG image data, baseline, precision 8, 1280x720, components 3

I think that might of been the behaviour we saw before

chrisruk avatar Oct 19 '22 11:10 chrisruk

Yes, start_x=1 will be the workaround. But I thought we'd sorted this out... evidently not. I'll have another look. Anyway, it's not a Picamera2 issue, it'll require an OS/firmware update, so no need to hold up our bugfix 0.3.5 release I think.

You can check the state of your image using v4l2-ctl -d /dev/video11 --list-formats. If that doesn't list MJPG then you'll end up with h264.

davidplowman avatar Oct 19 '22 11:10 davidplowman

Thanks, that's a useful command to know.

Added a pull request regarding timestamps for MJPEG here - https://github.com/raspberrypi/picamera2/pull/365

chrisruk avatar Oct 19 '22 11:10 chrisruk

Indeed there is still a problem enabling the MJPEG encoder in non-"start_x" builds. Should be fixed now, but will take a few days to appear via sudo rpi-update (usual caveats apply about that, of course).

davidplowman avatar Oct 19 '22 13:10 davidplowman

This should be available through sudo rpi-update now if you feel like trying it. As I said, it's the bleeding edge firmware so don't try it on a system where there's stuff you can't afford to lose!

davidplowman avatar Oct 27 '22 15:10 davidplowman