commit 5e23eeb2960bcb19568ba33ace958d1403e8118c
parent d195ef6f1909ef21e807801e52690ed80894d384
Author: rbckman <rob@tarina.org>
Date: Thu, 20 Jan 2022 10:02:01 +0000
stream to local tcp
Diffstat:
M | tarina.py | | | 34 | +++++++++++++++++++++++++++------- |
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/tarina.py b/tarina.py
@@ -80,6 +80,7 @@ def main():
if rundir != '':
os.chdir(rundir)
filmfolder = "/home/pi/Videos/"
+ picfolder = "/home/pi/Pictures/"
if os.path.isdir(filmfolder) == False:
os.makedirs(filmfolder)
tarinafolder = os.getcwd()
@@ -108,6 +109,7 @@ def main():
scene = 1
shot = 1
take = 1
+ pic = 1
filmname = ''
beeps = 0
beepcountdown = 0
@@ -499,6 +501,18 @@ def main():
loadfilmsetings = True
except:
writemessage('hmm.. couldnt enter developer mode')
+ #DEVELOP
+ elif event == 'J':
+ try:
+ stopinterface(camera)
+ run_command('raspistill -ISO 800 -ss 6000000 -o '+picfolder+'test'+str(pic).zfill(3)+'.jpeg')
+ pic = pic + 1
+ #os.system('scp '+picfolder/+'test.jpeg user@10.42.0.1:~/pic.jpeg')
+ startinterface()
+ camera = startcamera(lens,fps)
+ loadfilmsetings = True
+ except:
+ writemessage('hmm.. couldnt enter developer mode')
#REMOVE
#take
elif pressed == 'remove' and menu[selected] == 'TAKE:':
@@ -2969,11 +2983,13 @@ def uploadfilm(filename, filmname):
#-------------Streaming---------------
def startstream(camera, stream, plughw, channels):
- youtube="rtmp://a.rtmp.youtube.com/live2/"
- with open("/home/pi/.youtube-live") as fp:
- key = fp.readlines()
- print('using key: ' + key[0])
- stream_cmd = 'ffmpeg -f h264 -r 25 -i - -itsoffset 5.5 -fflags nobuffer -f alsa -ac '+str(channels)+' -i hw:'+str(plughw)+' -ar 44100 -vcodec copy -acodec libmp3lame -b:a 128k -ar 44100 -map 0:0 -map 1:0 -strict experimental -f flv ' + youtube + key[0]
+ #youtube
+ #youtube="rtmp://a.rtmp.youtube.com/live2/"
+ #with open("/home/pi/.youtube-live") as fp:
+ # key = fp.readlines()
+ #print('using key: ' + key[0])
+ #stream_cmd = 'ffmpeg -f h264 -r 25 -i - -itsoffset 5.5 -fflags nobuffer -f alsa -ac '+str(channels)+' -i hw:'+str(plughw)+' -ar 44100 -vcodec copy -acodec libmp3lame -b:a 128k -ar 44100 -map 0:0 -map 1:0 -strict experimental -f flv ' + youtube + key[0]
+ stream_cmd = 'ffmpeg -f h264 -r 25 -i - -itsoffset 5.5 -fflags nobuffer -f alsa -ac '+str(channels)+' -i hw:'+str(plughw)+' -ar 44100 -vcodec copy -acodec libmp3lame -b:a 128k -ar 44100 -map 0:0 -map 1:0 -strict experimental -f mpegts tcp://0.0.0.0:3333\?listen'
try:
stream = subprocess.Popen(stream_cmd, shell=True, stdin=subprocess.PIPE)
camera.start_recording(stream.stdin, format='h264', bitrate = 2000000)
@@ -3188,12 +3204,16 @@ def startinterface():
call(['./startinterface.sh &'], shell = True)
def stopinterface(camera):
- camera.stop_preview()
- camera.close()
+ try:
+ camera.stop_preview()
+ camera.close()
+ except:
+ print('no camera to close')
os.system('pkill arecord')
os.system('pkill startinterface')
os.system('pkill tarinagui')
run_command('sudo systemctl stop apache2')
+ return camera
def startcamera(lens, fps):
camera = picamera.PiCamera()