summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-04-26 13:49:15 +0200
committerJonas Smedegaard <dr@jones.dk>2017-04-26 13:49:15 +0200
commit880a7b1c1337dfb1824d284238e6f7b075b25985 (patch)
tree76ba071f6585de1ca3577018f33bd2a360da23ed
parent78a005809f830b8f9133c61ad45e7446f4e0f63a (diff)
Refactor to compose pipelines from arrays (not scalars).
-rwxr-xr-xbin/capture+encode+serve51
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();