From 49188f70b86387f64b40aa8c86ec4633ebf534ad Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 17 Aug 2016 13:27:19 +0200 Subject: select vaapi-encoder for preview-output depending on config --- voctocore/default-config.ini | 6 +++++- voctocore/lib/avpreviewoutput.py | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/voctocore/default-config.ini b/voctocore/default-config.ini index 31a49ff..8f816d3 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 +; 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..b2e8b4a 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -23,6 +23,18 @@ class AVPreviewOutput(TCPMultiConnection): if Config.getboolean('previews', 'deinterlace'): deinterlace = "deinterlace mode=interlaced !" + venc = 'jpegenc quality=90' + try: + encoder = Config.get('previews', 'vaapi') + encoders = { + 'h264': 'vaapih264enc', + 'jpeg': 'vaapijpegenc', + 'mpeg2': 'vaapimpeg2enc', + } + venc = encoders[encoder] + except Exception as e: + self.log.error(e) + pipeline = """ intervideosrc channel=video_{channel} ! {vcaps_in} ! @@ -30,7 +42,7 @@ class AVPreviewOutput(TCPMultiConnection): videoscale ! videorate ! {vcaps_out} ! - jpegenc quality=90 ! + {venc} ! queue ! mux. @@ -54,7 +66,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) -- cgit v1.2.3 From bb795bad0b439f6236f74f79c04e88888867b1dd Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 17 Aug 2016 13:40:41 +0200 Subject: tune preview encoders --- voctocore/lib/avpreviewoutput.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index b2e8b4a..b43b5c7 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -27,9 +27,9 @@ class AVPreviewOutput(TCPMultiConnection): try: encoder = Config.get('previews', 'vaapi') encoders = { - 'h264': 'vaapih264enc', - 'jpeg': 'vaapijpegenc', - 'mpeg2': 'vaapimpeg2enc', + 'h264': 'vaapih264enc rate-control=cqp init-qp=23 cabac=false 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: -- cgit v1.2.3 From 9834a6809d49ad63cf1af88b44efb02db6bca7ac Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 17 Aug 2016 13:57:58 +0200 Subject: add configurable decoders into the gui --- voctocore/default-config.ini | 2 +- voctocore/lib/avpreviewoutput.py | 1 + voctogui/lib/videodisplay.py | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/voctocore/default-config.ini b/voctocore/default-config.ini index 8f816d3..4c85abb 100644 --- a/voctocore/default-config.ini +++ b/voctocore/default-config.ini @@ -62,7 +62,7 @@ mix_out=10000 enabled=false deinterlace=false -; use vaapi to encode the previews, can be h264, mpeg2 or jpeg +; 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 diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index b43b5c7..91e2031 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -24,6 +24,7 @@ class AVPreviewOutput(TCPMultiConnection): deinterlace = "deinterlace mode=interlaced !" venc = 'jpegenc quality=90' + if Config.has_option('previews', 'vaapi'): try: encoder = Config.get('previews', 'vaapi') encoders = { diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index 9259f6c..f42775c 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 endoded previews instead of raw-video for gui') 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 endoded-previews for gui') # 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,8 @@ 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, + host=Config.get('server', 'host'), port=port, ) -- cgit v1.2.3 From 7a5fe106524df5cd86ee9dcf6e2cac76c9826321 Mon Sep 17 00:00:00 2001 From: Peter Körner Date: Tue, 27 Sep 2016 10:02:01 +0200 Subject: adapt to pep8 style --- voctocore/lib/avpreviewoutput.py | 31 +++++++++++++++-------------- voctogui/lib/videodisplay.py | 42 ++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index 91e2031..de4c95c 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -23,18 +23,19 @@ 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') - encoders = { - 'h264': 'vaapih264enc rate-control=cqp init-qp=23 cabac=false 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) + venc = 'jpegenc quality=90' + if Config.has_option('previews', 'vaapi'): + try: + encoder = Config.get('previews', 'vaapi') + encoders = { + 'h264': 'vaapih264enc rate-control=cqp init-qp=23' + 'cabac=false 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} ! @@ -43,7 +44,7 @@ class AVPreviewOutput(TCPMultiConnection): videoscale ! videorate ! {vcaps_out} ! - {venc} ! + {venc} ! queue ! mux. @@ -67,8 +68,8 @@ class AVPreviewOutput(TCPMultiConnection): acaps=Config.get('mix', 'audiocaps'), vcaps_in=Config.get('mix', 'videocaps'), vcaps_out=vcaps_out, - deinterlace=deinterlace, - venc=venc + 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 f42775c..9d531d5 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -16,34 +16,34 @@ class VideoDisplay(object): self.drawing_area = drawing_area self.level_callback = level_callback - if Config.has_option('previews', 'videocaps'): - previewcaps = Config.get('previews', 'videocaps') - else: - previewcaps = 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 endoded 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) + 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 endoded-previews for gui') + self.log.info('using raw-video instead of encoded-previews') # Setup Server-Connection, Demuxing and Decoding pipeline = """ @@ -55,7 +55,7 @@ class VideoDisplay(object): if use_previews: pipeline += """ demux. ! - {vdec} ! + {vdec} ! {previewcaps} ! queue ! """ @@ -126,8 +126,8 @@ 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, - host=Config.get('server', 'host'), + vdec=vdec, + host=Config.get('server', 'host'), port=port, ) -- cgit v1.2.3 From 311a72a7c8b35d71287607312e5723a7453c1b09 Mon Sep 17 00:00:00 2001 From: Peter Körner Date: Tue, 27 Sep 2016 10:44:55 +0200 Subject: select old encoder-names for gstreamer <1.8 --- voctocore/lib/avpreviewoutput.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index de4c95c..03c83f7 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -27,12 +27,22 @@ class AVPreviewOutput(TCPMultiConnection): if Config.has_option('previews', 'vaapi'): try: encoder = Config.get('previews', 'vaapi') - encoders = { - 'h264': 'vaapih264enc rate-control=cqp init-qp=23' - 'cabac=false max-bframes=0 keyframe-period=60', - 'jpeg': 'vaapijpegenc quality=90 keyframe-period=0', - 'mpeg2': 'vaapimpeg2enc keyframe-period=60', - } + if Gst.version() < (1, 8): + encoders = { + 'h264': 'vaapiencode_h264 rate-control=cqp init-qp=23' + 'cabac=false 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=23' + 'cabac=false 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) -- cgit v1.2.3 From ad1cc10ba6e7cb813b67ddeb07d28cbbc5c8b48a Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 28 Sep 2016 08:25:52 +0200 Subject: fix broken pipeline strings --- voctocore/lib/avpreviewoutput.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index 03c83f7..0208bf0 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -29,7 +29,7 @@ class AVPreviewOutput(TCPMultiConnection): encoder = Config.get('previews', 'vaapi') if Gst.version() < (1, 8): encoders = { - 'h264': 'vaapiencode_h264 rate-control=cqp init-qp=23' + 'h264': 'vaapiencode_h264 rate-control=cqp init-qp=23 ' 'cabac=false max-bframes=0 keyframe-period=60', 'jpeg': 'vaapiencode_jpeg quality=90' 'keyframe-period=0', @@ -37,7 +37,7 @@ class AVPreviewOutput(TCPMultiConnection): } else: encoders = { - 'h264': 'vaapih264enc rate-control=cqp init-qp=23' + 'h264': 'vaapih264enc rate-control=cqp init-qp=23 ' 'cabac=false max-bframes=0 keyframe-period=60', 'jpeg': 'vaapijpegenc quality=90' 'keyframe-period=0', -- cgit v1.2.3 From 828737d9e26716e6ba9b0db8481479e1d4b93f86 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 28 Sep 2016 08:50:26 +0200 Subject: fix merge issues --- voctogui/lib/videodisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index 9d531d5..fa558dc 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -127,7 +127,6 @@ class VideoDisplay(object): previewcaps=Config.get('previews', 'videocaps'), host=Args.host if Args.host else Config.get('server', 'host'), vdec=vdec, - host=Config.get('server', 'host'), port=port, ) -- cgit v1.2.3 From 7d206f56eb557585986bd259e32293a81899c853 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 28 Sep 2016 21:20:13 +0200 Subject: tune h264 vaapi encoders --- voctocore/lib/avpreviewoutput.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index 0208bf0..4d4f70e 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -29,16 +29,16 @@ class AVPreviewOutput(TCPMultiConnection): encoder = Config.get('previews', 'vaapi') if Gst.version() < (1, 8): encoders = { - 'h264': 'vaapiencode_h264 rate-control=cqp init-qp=23 ' - 'cabac=false max-bframes=0 keyframe-period=60', + '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=23 ' - 'cabac=false max-bframes=0 keyframe-period=60', + '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', -- cgit v1.2.3