lagurus
Posts: 46
Joined: Wed Aug 07, 2013 8:02 am

Callback on video port

Thu Dec 06, 2018 1:59 pm

Hello all,

I've been trying to use callback on video port and then put data directly to encoder (without mmal port connections) and with use of encoding
MMAL_ENCODING_OPAQUE.

For MMAL_ENCODING_H264 and MMAL_ENCODING_MJPEG it works.

But if is used MMAL_ENCODING_JPEG (and MMAL_COMPONENT_DEFAULT_IMAGE_ENCODER) it lead to freeze of whole PI.
Is it possible to use it in such way?

Test source code https://github.com/lagurus/rpi-mmal-ope ... tect-mjpeg

With enabled logs it shows:

Code: Select all

mmal: mmal_port_alloc: component:vc.ril.camera type:1 extra:0
mmal: mmal_port_alloc: vc.ril.camera:ctr:0: created at 0x244e0
mmal: mmal_vc_component_create: vc.ril.camera
mmal: mmal_vc_component_create: vc.ril.camera: handle 0x40 status 0 reply status 0
mmal: mmal_port_free: vc.ril.camera:ctr:0 at 0x244e0
mmal: mmal_port_alloc: component:vc.ril.camera type:1 extra:384
mmal: mmal_port_alloc: vc.ril.camera:ctr:0: created at 0x248a0
mmal: mmal_port_alloc: component:vc.ril.camera type:3 extra:384
mmal: mmal_port_alloc: vc.ril.camera:out:0: created at 0x24bb0
mmal: mmal_port_alloc: component:vc.ril.camera type:3 extra:384
mmal: mmal_port_alloc: vc.ril.camera:out:0: created at 0x24ec0
mmal: mmal_port_alloc: component:vc.ril.camera type:3 extra:384
mmal: mmal_port_alloc: vc.ril.camera:out:0: created at 0x251d0
mmal: mmal_port_alloc: component:vc.ril.camera type:4 extra:384
mmal: mmal_port_alloc: vc.ril.camera:clk:0: created at 0x255a0
mmal: mmal_vc_component_create:  handle 64
mmal: mmal_vc_port_info_get: get port info (1:0)
mmal: mmal_vc_port_info_get: get port info (3:0)
mmal: mmal_vc_port_info_get: get port info (3:1)
mmal: mmal_vc_port_info_get: get port info (3:2)
mmal: mmal_vc_port_info_get: get port info (4:0)
mmal: mmal_pool_create_with_allocator: allocating 48 + 24 + 472 * 4 bytes for pool
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 0/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 1/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 2/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 3/4
mmal: mmal_component_create_core: created 'vc.ril.camera' 0 0x24310
mmal: mmal_port_enable: vc.ril.camera:ctr:0 port 0x248a0, cb 0x11054, buffers (4/0/4,740/0/740)
mmal: mmal_port_parameter_set: vc.ril.camera(1:0) port 0x248a0, param 0x7efffa54 (10015,48)
mmal: mmal_port_format_commit: vc.ril.camera(3:0) port 0x24bb0 format 3:OPQV
mmal: mmal_vc_port_info_set: set port info (3:0)
mmal: mmal_vc_port_info_get: get port info (3:0)
mmal: mmal_port_format_commit: vc.ril.camera(3:1) port 0x24ec0 format 3:OPQV
mmal: mmal_vc_port_info_set: set port info (3:1)
mmal: mmal_vc_port_info_get: get port info (3:1)
mmal: mmal_port_pool_create: vc.ril.camera(3:1) port 0x24ec0, headers 3, size 15360
mmal: mmal_pool_create_with_allocator: allocating 48 + 16 + 472 * 3 bytes for pool
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 0/3
mmal: mmal_port_payload_alloc: vc.ril.camera(3:1) port 0x24ec0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocated at 0x27a90
mmal: mmal_port_acquire: port vc.ril.camera:out:1(OPQV)(0x24ec0), refcount 0
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 1/3
mmal: mmal_port_payload_alloc: vc.ril.camera(3:1) port 0x24ec0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocated at 0x2b6b0
mmal: mmal_port_acquire: port vc.ril.camera:out:1(OPQV)(0x24ec0), refcount 1
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 2/3
mmal: mmal_port_payload_alloc: vc.ril.camera(3:1) port 0x24ec0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.camera:out:1(OPQV): allocated at 0x2f2e0
mmal: mmal_port_acquire: port vc.ril.camera:out:1(OPQV)(0x24ec0), refcount 2
mmal: mmal_port_enable: vc.ril.camera:out:1(OPQV) port 0x24ec0, cb 0x110d4, buffers (3/10/3,15360/128/128)
mmal: mmal_component_enable: vc.ril.camera 0
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0x2b6b0,0,0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0x2f2e0,0,0)
mmal: mmal_component_create: vc.ril.image_encode
mmal: mmal_port_alloc: component:vc.ril.image_encode type:1 extra:0
mmal: mmal_port_alloc: vc.ril.image_encode:ctr:0: created at 0x334c0
mmal: mmal_vc_component_create: vc.ril.image_encode
mmal: mmal_vc_component_create: vc.ril.image_encode: handle 0x38 status 0 reply status 0
mmal: mmal_port_free: vc.ril.image_encode:ctr:0 at 0x334c0
mmal: mmal_port_alloc: component:vc.ril.image_encode type:1 extra:384
mmal: mmal_port_alloc: vc.ril.image_encode:ctr:0: created at 0x33880
mmal: mmal_port_alloc: component:vc.ril.image_encode type:2 extra:384
mmal: mmal_port_alloc: vc.ril.image_encode:in:0: created at 0x33ba0
mmal: mmal_port_alloc: component:vc.ril.image_encode type:3 extra:384
mmal: mmal_port_alloc: vc.ril.image_encode:out:0: created at 0x33eb0
mmal: mmal_vc_component_create:  handle 56
mmal: mmal_vc_port_info_get: get port info (1:0)
mmal: mmal_vc_port_info_get: get port info (2:0)
mmal: mmal_vc_port_info_get: get port info (3:0)
mmal: mmal_pool_create_with_allocator: allocating 48 + 24 + 472 * 4 bytes for pool
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 0/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 1/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 2/4
mmal: mmal_pool_initialise_buffer_headers: allocating 740 bytes for payload 3/4
mmal: mmal_component_create_core: created 'vc.ril.image_encode' 1 0x33300
mmal: mmal_port_format_commit: vc.ril.image_encode(2:0) port 0x33ba0 format 3:OPQV
mmal: mmal_vc_port_info_set: set port info (2:0)
mmal: mmal_vc_port_info_get: get port info (2:0)
mmal: mmal_vc_port_info_get: get port info (3:0)
mmal: mmal_port_parameter_set: vc.ril.image_encode(3:0) port 0x33eb0, param 0x7efffa4c (10003,12)
mmal: mmal_port_parameter_set: vc.ril.image_encode(3:0) port 0x33eb0, param 0x7efffa4c (10019,12)
mmal: mmal_port_parameter_set: vc.ril.image_encode(3:0) port 0x33eb0, param 0x7efffa68 (10000,24)
mmal: mmal_port_format_commit: vc.ril.image_encode(3:0) port 0x33eb0 format 3:JPEG
mmal: mmal_vc_port_info_set: set port info (3:0)
mmal: mmal_vc_port_info_get: get port info (3:0)
mmal: mmal_port_pool_create: vc.ril.image_encode(2:0) port 0x33ba0, headers 3, size 15360
mmal: mmal_pool_create_with_allocator: allocating 48 + 16 + 472 * 3 bytes for pool
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 0/3
mmal: mmal_port_payload_alloc: vc.ril.image_encode(2:0) port 0x33ba0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocated at 0x35dc0
mmal: mmal_port_acquire: port vc.ril.image_encode:in:0(OPQV)(0x33ba0), refcount 0
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 1/3
mmal: mmal_port_payload_alloc: vc.ril.image_encode(2:0) port 0x33ba0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocated at 0x399f0
mmal: mmal_port_acquire: port vc.ril.image_encode:in:0(OPQV)(0x33ba0), refcount 1
mmal: mmal_pool_initialise_buffer_headers: allocating 15360 bytes for payload 2/3
mmal: mmal_port_payload_alloc: vc.ril.image_encode(2:0) port 0x33ba0, size 15360
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocating 15360 bytes, format OPQV, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:in:0(OPQV): allocated at 0x3d610
mmal: mmal_port_acquire: port vc.ril.image_encode:in:0(OPQV)(0x33ba0), refcount 2
mmal: mmal_port_enable: vc.ril.image_encode:in:0(OPQV) port 0x33ba0, cb 0x113c0, buffers (3/10/3,15360/128/128)
mmal: mmal_port_pool_create: vc.ril.image_encode(3:0) port 0x33eb0, headers 1, size 2088960
mmal: mmal_pool_create_with_allocator: allocating 48 + 8 + 472 * 1 bytes for pool
mmal: mmal_pool_initialise_buffer_headers: allocating 2088960 bytes for payload 0/1
mmal: mmal_port_payload_alloc: vc.ril.image_encode(3:0) port 0x33eb0, size 2088960
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:out:0(JPEG): allocating 2088960 bytes, format JPEG, is_zero_copy 0
mmal: mmal_vc_port_payload_alloc: vc.ril.image_encode:out:0(JPEG): allocated at 0x73901020
mmal: mmal_port_acquire: port vc.ril.image_encode:out:0(JPEG)(0x33eb0), refcount 3
mmal: mmal_port_enable: vc.ril.image_encode:out:0(JPEG) port 0x33eb0, cb 0x113e8, buffers (1/1/1,2088960/2088960/2088960)
mmal: mmal_port_send_buffer: vc.ril.image_encode(3:0) port 0x33eb0, buffer 0x416e8 (0x73901020,0,0)
mmal: mmal_port_parameter_set: vc.ril.camera(3:1) port 0x24ec0, param 0x7efffa94 (10011,12)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0,0x27a90,0,128)
mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0x35dc0,0,128)
mmal: mmal_buffer_header_release: 0x274e0 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0,0x35dc0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0,0x2b6b0,0,128)
mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x359e8 (0x399f0,0,128)
mmal: mmal_buffer_header_release: 0x276b8 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0x2b6b0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0,0x2f2e0,0,128)
mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0x3d610,0,128)
mmal: mmal_buffer_header_release: 0x27890 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0x2f2e0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0,0x27a90,0,128)
mmal: mmal_buffer_header_release: 0x35810 (0)
mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0x35dc0,0,128)mmal: mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)
mmal: mmal: mmal_buffer_header_release: 0x274e0 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal_buffer_header_release: 0x34378 (0)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0,0x3d610,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0,0x2b6b0,0,128)
mmal: mmal_buffer_header_release: 0x35bc0 (0)
mmal: mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)
mmal: mmal_buffer_header_release: 0x34550 (0)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0,0x35dc0,0,0)
mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0x3d610,0,128)
mmal: mmal_buffer_header_release: 0x276b8 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0x2b6b0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0,0x2f2e0,0,128)
mmal: mmal_buffer_header_release: 0x27890 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0x2f2e0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0,0x27a90,0,128)
mmal: mmal_buffer_header_release: 0x35810 (0)
mmal: mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0x35dc0,0,128)
mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal: mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)
mmal: mmal_buffer_header_release: 0x274e0 (0)
mmal: mmal_buffer_header_release: 0x34728 (0)mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0,0x2b6b0,0,128)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0,0x3d610,0,0)
mmal: mmal_buffer_header_release: 0x276b8 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0x2b6b0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0,0x2f2e0,0,128)
mmal: mmal_buffer_header_release: 0x35bc0 (0)
mmal: mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0x3d610,0,128)
mmal: mmal_buffer_header_release: 0x27890 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0x2f2e0,0,0)mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0,0x27a90,0,128)
mmal: mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)mmal_buffer_header_release: 0x34900 (0)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0,0x35dc0,0,0)
mmal: mmal_buffer_header_release: 0x274e0 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0,0x2b6b0,0,128)
mmal: mmal_buffer_header_release: 0x35810 (0)
mmal: mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0x35dc0,0,128)
mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)
mmal: mmal_buffer_header_release: 0x34378 (0)
mmal: mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0,0x3d610,0,0)
mmal_buffer_header_release: 0x276b8 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0x2b6b0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0,0x2f2e0,0,128)
mmal: mmal_buffer_header_release: 0x27890 (0)
mmal: mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x27890 (0x2f2e0,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0,0x27a90,0,128)
mmal: mmal_buffer_header_release: 0x35bc0 (0)
mmal: mmal: mmal_port_send_buffer: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35bc0 (0x3d610,0,128)
mmal_port_event_get: vc.ril.image_encode(1:0) port 0x33880, event ERRO
mmal: mmal: mmal_buffer_header_release: 0x274e0 (0)
mmal: mmal_port_event_send: event lost on port 1,0 (buffer header callback not defined)mmal_port_send_buffer: vc.ril.camera(3:1) port 0x24ec0, buffer 0x274e0 (0x27a90,0,0)
mmal: mmal_port_buffer_header_callback: vc.ril.camera(3:1) port 0x24ec0, buffer 0x276b8 (0,0x2b6b0,0,128)
mmal_buffer_header_release: 0x34550 (0)
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(2:0) port 0x33ba0, buffer 0x35810 (0,0x35dc0,0,0)
Thanks in advance

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6689
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Callback on video port

Thu Dec 06, 2018 4:23 pm

I'm not seeing a freeze on the whole Pi, but I'll agree that it doesn't work.

There are actually 3 different formats of MMAL_ENCODING_OPAQUE under the hood, and the one that image_encode wants is different to the one that camera->output[1] produces. I thought I'd fixed it up so that they would inter-operate, but you appear to have found a combination that doesn't.
I'll see what I can do about fixing it up.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”