This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Record a video #45
Comments
Hi, i was able to record a video with the code below, using pillow=True in the camera.capture(pillow=True) function, but the frame rate is very low, how can i increase it? import numpy as np
from maix import camera
import av
duration = 4
fps = 24
total_frames = duration * fps
# Configura il codec video
output_options = {
'format': 'mp4',
'pix_fmt': 'yuv420p',
'framerate': fps,
'bit_rate': 4000000, # Bit rate desiderato
}
container = av.open("/root/test1.mp4", mode="w")
# mpeg4
stream = container.add_stream("mpeg4", rate=fps)
stream.width = 1280
stream.height = 720
stream.pix_fmt = "yuv420p"
#stream.bit_rate = output_options['bit_rate']
#stream.options = output_options
camera.config(size=(stream.width,stream.height))
for frame_i in range(total_frames):
print("Frame")
img = camera.capture(pillow=True)
numpydata = np.array(img)
frame = av.VideoFrame.from_ndarray(numpydata, format="rgb24")
for packet in stream.encode(frame):
container.mux(packet)
# Flush stream
for packet in stream.encode():
container.mux(packet)
# Close the file
container.close() I made a separate test with this simple code to test the framerate from maix import camera
import time
width= 1280
height= 720
camera.config(size=(width,height))
while True:
start_time = time.time()
img = camera.capture(pillow=True)
#display.show(img)
print("FPS: ", 1.0 / (time.time() - start_time)) # FPS = 1 / time to process loop and i got this results
Can I reach in python 30fps in 720p quality video, or i need to switch in C++? |
Can anyone help me, please? I can pay |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, i tryed to record a video with the sample in the website, but it doesn't work https://wiki.sipeed.com/soft/maixpy3/zh/usage/Audio/play_mp4.html.
I use chatgpt to create this code, but i receive the below error an i don't know how to solve it.
Can anyone share with me the right code to record a video? Thanks
ERROR :
The text was updated successfully, but these errors were encountered: