Open hornetmadness opened 4 years ago
Your usage of wait_recording
is incorrect. It is "wait whilst recording", ie call it after start_recording
. It is preferable compared to time.sleep in that it handles any exceptions thrown by the library.
See docs https://picamera.readthedocs.io/en/release-1.13/api_camera.html#picamera.PiCamera.wait_recording https://picamera.readthedocs.io/en/release-1.13/recipes1.html#recording-video-to-a-file
I'm trying to get picamera to stream indefinitely and I think the wait_record is close to --timeout in raspivid. When I try to use it, its throwing exceptions.
pi@raspberrypi:~ $ pip3 list | grep picamera picamera 1.13 pi@raspberrypi:~ $ cat thing.py import picamera import subprocess import time
if name == "main": gstreamer = subprocess.Popen([ 'gst-launch-1.0', '-v', 'fdsrc', '!', 'h264parse', '!', 'rtph264pay', 'config-interval=1', 'pt=96', '!', 'gdppay', '!', 'tcpserversink', 'host=0.0.0.0', 'port=5006' ], stdin=subprocess.PIPE)
camera = picamera.PiCamera(resolution=(1280, 720), framerate=30) camera.hflip = True camera.wait_recording(10) camera.start_recording(gstreamer.stdin, format='h264', bitrate=1000000)
print("Hello World!")
time.sleep(30)
camera.stop_recording()
gstreamer.stdin.close()
gstreamer.wait()
pi@raspberrypi:~ $ python3 thing.py Setting pipeline to PAUSED ... Pipeline is PREROLLING ... /GstPipeline:pipeline0/GstTCPServerSink:tcpserversink0: current-port = 5006 Traceback (most recent call last): File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1161, in wait_recording encoder = self._encoders[splitter_port] KeyError: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "thing.py", line 17, in
camera.wait_recording(timeout=10, splitter_port=1)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1165, in wait_recording
'port %d' % splitter_port)
picamera.exc.PiCameraNotRecording: There is no recording in progress on port 1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.000381678
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...