Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion data leaks into h264 output #177

Closed
andyg24 opened this issue Oct 20, 2014 · 3 comments

Comments

@andyg24
Copy link

commented Oct 20, 2014

Not sure if this is intended behavior, but somehow motion data occasionally shows up in H264 output.

import picamera

camera = picamera.PiCamera()
camera.resolution = (1024, 768)
camera.vflip = 1
camera.hflip = 1
camera.framerate = 15

h264_stream = picamera.PiCameraCircularIO(camera, size = 5000000)
camera.start_recording(h264_stream, format='h264',
    resize=(1024, 768), motion_output = '/dev/null')
camera.wait_recording(10)
camera.stop_recording()

for frame in h264_stream.frames:
  if frame.frame_type == picamera.PiVideoFrameType.motion_data:
    print 'Found motion frame at index %d' % frame.index

pi@cam0 ~/stream $ python bug2.py
Found motion frame at index 120
Found motion frame at index 241

If I set motion_output to None, the motion frames disappear. Is there a reason for motion data to be in H264 output? Or is this a bug?

@waveform80

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2014

Eurgh - that certainly sounds like a bug, but it might just be incorrect association of frame meta-data. I'll have to test it and find out; unfortunately I'm rather busy for the next couple of weeks but I'll mark this for 1.9 as it certainly looks worth investigating.

@waveform80 waveform80 self-assigned this Oct 20, 2014

@waveform80 waveform80 added this to the 1.9 milestone Oct 20, 2014

@waveform80 waveform80 added the bug label Oct 20, 2014

@waveform80

This comment has been minimized.

Copy link
Owner

commented Nov 29, 2014

Okay, I think I understand what's going on here. It's not actually leaking motion data into the stream, but the metadata that PiCameraCircularIO captures is incorrect. Specifically, when a partial frame buffer follows a motion data buffer, metadata gets incorrectly associated. Not sure how to fix this yet ... there's some rather subtle interplay between the encoder updating the frame meta-data and how PiCameraCircularIO captures it ...

@waveform80

This comment has been minimized.

Copy link
Owner

commented Nov 29, 2014

Damn ... I'm going to need to break backward compatibility to fix this. On the other hand, the current frame implementation is definitely broken and does the wrong thing when frames are output in multiple chunks. Hopefully the new version won't break things for too many people!

@waveform80 waveform80 closed this in 1e3277a Jan 1, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.