vuquangtrong / pi_streaming

Streaming camera on Raspberry Pi using HLS, MPEG-DASH, MJPEG (MJPG), and H264
https://www.codeinsideout.com/blog/pi/stream-picamera-h264/
MIT License
45 stars 14 forks source link

Use with Picamera2? #2

Open rsrawley opened 1 year ago

rsrawley commented 1 year ago

Any chance you could adapt this to work with the new Picamera2 library? I've tried, but the docs are full of examples and don't show much of the syntax. This is needed to use the new module 3 camera. Great job on this as it stands!

woutersf commented 1 year ago

Chiming in here. This would be awesome. My python skills are below zero, but I think it needs something like this:

import picamera2
from picamera2.encoders import H264Encoder

in def stream

    with picamera2.Picamera2() as camera:
        camera.configure(camera.create_video_configuration(main={"size": (640, 480)}))

also this (but I think this is wrong somehow:

        frame_buffer = FrameBuffer()
        encoder = H264Encoder(qp=30)
        camera.capture_file(frame_buffer, format='jpeg')
        camera.start_recording(encoder, frame_buffer)
woutersf commented 1 year ago

https://github.com/vuquangtrong/pi_streaming/compare/main...woutersf:pi_streaming:main

woutersf commented 1 year ago

the above changes give me a working page but the stream seems not to work.

image
Cylon-interrogator commented 1 year ago

Hey, how is going? Did you make it work? Cheers.