scripts/libraries: Fix RTSP library to work with VLC.

This commit is contained in:
Kwabena W. Agyeman 2024-03-17 15:43:29 -07:00
parent b037b2208a
commit 3aea9f9687
3 changed files with 23 additions and 11 deletions

View File

@ -7,7 +7,8 @@
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
# OpenMV Cam's IP address. However, OpenMV IDE has an FFPLAY based RSTP Viewer built-in which
# you can use by going to Tools->Video Tools->Play RSTP Stream.
import network
import omv
@ -15,11 +16,15 @@ import rtsp
import sensor
import time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# If you are using VLC on linux you may need to install the live555 library for RTSP support to
# work. If you are using Ubuntu then run the following command:
#
# sudo apt-get install livemedia-utils
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
# Regarding latency on programs like VLC, the default is typically set to buffer 1 second of video
# before playback. To reduce this you need to reduce the network caching which can be set using
# "show more options" when you open the network stream in VLC. You can reduce this to like 10ms
# to make the video real-time.
sensor.reset()

View File

@ -7,7 +7,8 @@
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
# OpenMV Cam's IP address. However, OpenMV IDE has an FFPLAY based RSTP Viewer built-in which
# you can use by going to Tools->Video Tools->Play RSTP Stream.
import network
import omv
@ -15,11 +16,15 @@ import rtsp
import sensor
import time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# If you are using VLC on linux you may need to install the live555 library for RTSP support to
# work. If you are using Ubuntu then run the following command:
#
# sudo apt-get install livemedia-utils
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
# Regarding latency on programs like VLC, the default is typically set to buffer 1 second of video
# before playback. To reduce this you need to reduce the network caching which can be set using
# "show more options" when you open the network stream in VLC. You can reduce this to like 10ms
# to make the video real-time.
sensor.reset()

View File

@ -6,6 +6,7 @@
# This work is licensed under the MIT license, see the file LICENSE for details.
import errno
import image
import random
import re
import socket
@ -294,7 +295,8 @@ class rtsp_server:
self.__close_udp_socket()
def __send_rtp(self, image_callback, quality): # private
img = image_callback(self.__pathname, self.__session).to_jpeg(quality=quality)
img = image_callback(self.__pathname, self.__session)
img = img.to_jpeg(quality=quality, subsampling=image.JPEG_SUBSAMPLING_422)
if img.width() >= 2040:
raise ValueError("Maximum width is 2040")
if img.height() >= 2040: