MaixPy Playback Video
2024-08-19
Update history
Date | Version | Author | Update content |
---|---|---|---|
2024-08-19 | 1.0.0 | lxowalle | Initial document |
1. Introduction#
This document provides instructions for using the Play Video feature.
MaixPy
supports playing h264
, mp4
and flv
video formats, note that currently only avc
encoded mp4
and flv
files are supported. Additionally, due to hardware encoder limitations, if you encounter issues decoding the video during playback, try re-encoding it with ffmpeg
and then play it again. Refer to the following command:
2. Play MP4
video#
An example of playing an mp4
video, the path to the video file is /root/output.mp4
.
Steps:
Import the module and initialise the camera
disp = display.Display()
is used to initialise the display to show the decoded image
Initialise the
Decoder
moduled = video.Decoder(‘/root/output.mp4’)
is used to initialise the decoder and set the path to the video file that needs to be played. If you need to playflv
files, you can fill in the path of the file withflv
suffix, such as{your_file_path}.flv
, if you need to playh264
files, you can fill in the path of the file withh264
suffix, such as{your_file_path}.h264
Set the decoding location
- can be used to set the position of the video to be played, in seconds.
Get the decoded image
- Each call returns a frame context, and you can obtain img through
ctx.image()
. Currently the decoded output only supports the NV21 format.
- Each call returns a frame context, and you can obtain img through
Display the decoded image
- When displaying images,
ctx.duration_us()
can be used to get the duration of each frame in microseconds.
- When displaying images,
Done, see API documentation for more usage of
Decoder
.