diff options
-rw-r--r-- | voctocore/default-config.ini | 6 | ||||
-rw-r--r-- | voctocore/lib/avpreviewoutput.py | 29 | ||||
-rw-r--r-- | voctogui/lib/videodisplay.py | 28 |
3 files changed, 55 insertions, 8 deletions
diff --git a/voctocore/default-config.ini b/voctocore/default-config.ini index 31a49ff..4c85abb 100644 --- a/voctocore/default-config.ini +++ b/voctocore/default-config.ini @@ -62,9 +62,13 @@ mix_out=10000 enabled=false deinterlace=false +; use vaapi to encode the previews, can be h264, mpeg2 or jpeg (BUT ONLY h264 IS TESTED) +; not all encoders are available on all CPUs +;vaapi=h264 + ; default to mix-videocaps, only applicable if enabled=true ; you can change the framerate and the width/height, but nothing else -videocaps=video/x-raw,width=1024,height=576,framerate=25/1 +;videocaps=video/x-raw,width=1024,height=576,framerate=25/1 [stream-blanker] enabled=true diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index 749249b..4d4f70e 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -23,6 +23,30 @@ class AVPreviewOutput(TCPMultiConnection): if Config.getboolean('previews', 'deinterlace'): deinterlace = "deinterlace mode=interlaced !" + venc = 'jpegenc quality=90' + if Config.has_option('previews', 'vaapi'): + try: + encoder = Config.get('previews', 'vaapi') + if Gst.version() < (1, 8): + encoders = { + 'h264': 'vaapiencode_h264 rate-control=cqp init-qp=10 ' + 'max-bframes=0 keyframe-period=60', + 'jpeg': 'vaapiencode_jpeg quality=90' + 'keyframe-period=0', + 'mpeg2': 'vaapiencode_mpeg2 keyframe-period=60', + } + else: + encoders = { + 'h264': 'vaapih264enc rate-control=cqp init-qp=10 ' + 'max-bframes=0 keyframe-period=60', + 'jpeg': 'vaapijpegenc quality=90' + 'keyframe-period=0', + 'mpeg2': 'vaapimpeg2enc keyframe-period=60', + } + venc = encoders[encoder] + except Exception as e: + self.log.error(e) + pipeline = """ intervideosrc channel=video_{channel} ! {vcaps_in} ! @@ -30,7 +54,7 @@ class AVPreviewOutput(TCPMultiConnection): videoscale ! videorate ! {vcaps_out} ! - jpegenc quality=90 ! + {venc} ! queue ! mux. @@ -54,7 +78,8 @@ class AVPreviewOutput(TCPMultiConnection): acaps=Config.get('mix', 'audiocaps'), vcaps_in=Config.get('mix', 'videocaps'), vcaps_out=vcaps_out, - deinterlace=deinterlace + deinterlace=deinterlace, + venc=venc ) self.log.debug('Creating Output-Pipeline:\n%s', pipeline) diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index 9259f6c..fa558dc 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -16,16 +16,34 @@ class VideoDisplay(object): self.drawing_area = drawing_area self.level_callback = level_callback - caps = Config.get('mix', 'videocaps') + if Config.has_option('previews', 'videocaps'): + previewcaps = Config.get('previews', 'videocaps') + else: + previewcaps = Config.get('mix', 'videocaps') + use_previews = (Config.getboolean('previews', 'enabled') and Config.getboolean('previews', 'use')) # Preview-Ports are Raw-Ports + 1000 if use_previews: - self.log.info('using jpeg-previews instead of raw-video for gui') + self.log.info('using encoded previews instead of raw-video') port += 1000 + + vdec = 'image/jpeg ! jpegdec' + if Config.has_option('previews', 'vaapi'): + try: + decoder = Config.get('previews', 'vaapi') + decoders = { + 'h264': 'video/x-h264 ! avdec_h264', + 'jpeg': 'image/jpeg ! jpegdec', + 'mpeg2': 'video/mpeg,mpegversion=2 ! mpeg2dec' + } + vdec = decoders[decoder] + except Exception as e: + self.log.error(e) + else: - self.log.info('using raw-video instead of jpeg-previews for gui') + self.log.info('using raw-video instead of encoded-previews') # Setup Server-Connection, Demuxing and Decoding pipeline = """ @@ -37,8 +55,7 @@ class VideoDisplay(object): if use_previews: pipeline += """ demux. ! - image/jpeg ! - jpegdec ! + {vdec} ! {previewcaps} ! queue ! """ @@ -109,6 +126,7 @@ class VideoDisplay(object): vcaps=Config.get('mix', 'videocaps'), previewcaps=Config.get('previews', 'videocaps'), host=Args.host if Args.host else Config.get('server', 'host'), + vdec=vdec, port=port, ) |