raspberrypi / rpicam-apps

BSD 2-Clause "Simplified" License
406 stars 220 forks source link

[BUG] Libcamera-vid Only 1st segment playable? #376

Closed Mattncb closed 2 years ago

Mattncb commented 2 years ago

I'm having a strange problem with segmented videos

libcamera-vid -t 30000 --segment 10000 -o video%04d.h264

Run the command without error and successfully creates 3 files all of similar file size. Unfortunately, only the first file is playable and the following 2 seem to be corrupted.

Can anyone offer any suggestions on how to resolve?

Linux raspberrypi 5.15.61-v7+ #1579 SMP Fri Aug 26 11:10:59 BST 2022 armv7l GNU/Linux libcamera-apps build: 1bf0ccacf2ef 31-08-2022 (16:16:34) libcamera build: v0.0.0+3866-0c55e522

Pi Zero W 2 HQ Camera Module

naushir commented 2 years ago

What are you using to play back the files? Could you attach one good and one bad file for us to have a look at please?

Additionally, you might want to use --inline option when using segments to ensure frame headers are written appropriately.

6by9 commented 2 years ago

Raspivid automatically enabled inline headers if segmentation was selected. Does libcamera-vid not do the same? https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/raspicam/RaspiVid.c#L757

naushir commented 2 years ago

No it does not, but probably makes sense if it does...

Mattncb commented 2 years ago

Inline solved it thanks. Agree with the above or maybe at least documentation on segment should be amended to show inline is needed.

thanks!

naushir commented 2 years ago

Looking at the code here: https://github.com/raspberrypi/libcamera-apps/blob/22a52590c33a813743b4e6337478c208201c77b1/core/video_options.hpp#L134 you should have seen the error message printed out. If it did not, it's something to look at.

naushir commented 2 years ago

Resolving...