diff options
-rwxr-xr-x | bin/capture+encode+serve | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/bin/capture+encode+serve b/bin/capture+encode+serve index 6a6da0d..bc85167 100755 --- a/bin/capture+encode+serve +++ b/bin/capture+encode+serve @@ -61,24 +61,32 @@ my $QUEUE = "queue max-size-bytes=100000000 max-size-time=0"; my %PIPELINE = ( AMR => { - AENC => "amrnbenc ! $QUEUE ! rtpamrpay", + AENC => [ 'amrnbenc', $QUEUE, 'rtpamrpay' ], }, H264 => { # * let x264 use low-latency sliced-threads (i.e. don't disable treads) - VENC => - "x264enc speed-preset=ultrafast tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\" ! video/x-h264,profile=baseline ! $QUEUE ! rtph264pay", + VENC => [ + "x264enc speed-preset=ultrafast tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\"", + 'video/x-h264,profile=baseline', + $QUEUE, + 'rtph264pay', + ], }, OPUS => { - AENC => "opusenc ! $QUEUE ! rtpopuspay", + AENC => [ 'opusenc', $QUEUE, 'rtpopuspay' ], }, VP8 => { - VENC => - "vp8enc threads=4 cpu-used=15 deadline=1000000 end-usage=1 target-bitrate=$VBITRATE undershoot=95 keyframe-max-dist=999999 max-quantizer=56 deadline=5000 static-threshold=500 ! video/x-vp8 ! $QUEUE ! rtpvp8pay", + VENC => [ + "vp8enc threads=4 cpu-used=15 deadline=1000000 end-usage=1 target-bitrate=$VBITRATE undershoot=95 keyframe-max-dist=999999 max-quantizer=56 deadline=5000 static-threshold=500", + 'video/x-vp8', + $QUEUE, + 'rtpvp8pay', + ], }, RAW => { - AENC => "rtpL16pay", - VENC => "rtpvrawpay", + AENC => ['rtpL16pay'], + VENC => ['rtpvrawpay'], }, ); @@ -89,10 +97,18 @@ sub cam my $device = shift; my $payload = "pay" . $nextpayload++; - my $factory = Gst::RTSPMediaFactory->new(); - $factory->set_launch( - "( v4l2src device=$device ! $QUEUE ! videoconvert ! $VCAPS ! $QUEUE ! $PIPELINE{$VFORMAT}{'VENC'} name=$payload )" + my $factory = Gst::RTSPMediaFactory->new(); + my $pipeline = join( + ' ! ', + ( "v4l2src device=$device", + $QUEUE, + 'videoconvert', + $VCAPS, + $QUEUE, + @{ $PIPELINE{$VFORMAT}{'VENC'} }, + ) ); + $factory->set_launch("( $pipeline name=$payload )"); $factory->set_shared(TRUE); say "media ($device): " . $factory->get_launch(); @@ -107,10 +123,17 @@ sub mic my $device = shift; my $payload = "pay" . $nextpayload++; - my $factory = Gst::RTSPMediaFactory->new(); - $factory->set_launch( - "( alsasrc device=$device buffer-time=$ABUFFERS ! $QUEUE ! audioconvert ! $QUEUE ! $PIPELINE{$AFORMAT}{'AENC'} name=$payload )" + my $factory = Gst::RTSPMediaFactory->new(); + my $pipeline = join( + ' ! ', + ( "alsasrc device=$device buffer-time=$ABUFFERS", + $QUEUE, + 'audioconvert', + $QUEUE, + @{ $PIPELINE{$AFORMAT}{'AENC'} }, + ) ); + $factory->set_launch("( $pipeline name=$payload )"); $factory->set_shared(TRUE); #say "media ($device): " . $factory->get_launch(); |