Updates to tcp, clock and tee

This commit is contained in:
Matthew Clark 2018-04-17 23:51:33 +01:00
parent 34d622ceea
commit cce4a1680d
4 changed files with 80 additions and 2 deletions

View file

@ -76,6 +76,12 @@ gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! videoconvert ! vertigotv
Try also rippletv, streaktv, radioactv, optv, quarktv, revtv, shagadelictv, warptv (I like), dicetv, agingtv (great), edgetv (could be great on real stuff) Try also rippletv, streaktv, radioactv, optv, quarktv, revtv, shagadelictv, warptv (I like), dicetv, agingtv (great), edgetv (could be great on real stuff)
### Add A clock
```
gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! clockoverlay font-desc="Sans, 48" ! videoconvert ! autovideosink
```
### Resize video ### Resize video
``` ```

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>gst-stream</title>
</head>
<body>
<h1>Demo TCP video playback</h1>
<h2>I've only managed to get this working on Firefox, not Chrome or Safari.</h2>
<video width=640 height=360 autoplay style="border: 1px solid green" controls>
<source src="http://localhost:9090/">
</video>
</body>
</html>

View file

@ -208,3 +208,46 @@ gst-launch-1.0 \
tcpclientsrc host=127.0.0.1 port=7001 ! \ tcpclientsrc host=127.0.0.1 port=7001 ! \
decodebin name=decoder ! autoaudiosink decoder. ! autovideosink decodebin name=decoder ! autoaudiosink decoder. ! autovideosink
``` ```
## Previewing in a web browser using TCP
I've successfully managed to send video to *Firefox*, but not *Chrome* or *Safari*.
You'll need a HTML page with a video element, like [this one](./html_examples/tcp-receive.html)
Then send video like this:
```
gst-launch-1.0 \
videotestsrc is-live=true ! queue ! \
videoconvert ! videoscale ! video/x-raw,width=320,height=180 ! \
clockoverlay shaded-background=true font-desc="Sans 38" ! \
theoraenc ! oggmux ! tcpserversink host=127.0.0.1 port=9090
```
Video and audio together:
```
gst-launch-1.0 \
videotestsrc is-live=true ! queue ! \
videoconvert ! videoscale ! video/x-raw,width=320,height=180 ! \
clockoverlay shaded-background=true font-desc="Sans 38" ! \
theoraenc ! queue2 ! mux. \
audiotestsrc ! audioconvert ! vorbisenc ! mux. \
oggmux name=mux ! tcpserversink host=127.0.0.1 port=9090
```
Play a source rather than test:
```
gst-launch-1.0 \
filesrc location=$SRC ! \
qtdemux name=demux \
demux.audio_0 ! queue ! decodebin ! vorbisenc ! muxer. \
demux.video_0 ! queue ! decodebin ! \
videoconvert ! videoscale ! video/x-raw,width=320,height=180 ! \
theoraenc ! muxer. \
oggmux name=muxer ! \
tcpserversink host=127.0.0.1 port=9090 recover-policy=keyframe sync-method=latest-keyframe
```

19
tee.md
View file

@ -2,6 +2,8 @@
The `tee` command allows audio & video streams to be sent to more than one place. The `tee` command allows audio & video streams to be sent to more than one place.
## Tee to two local video outputs
Here's a simple example that sends shows video test source twice (using `autovideosink`) Here's a simple example that sends shows video test source twice (using `autovideosink`)
``` ```
@ -12,8 +14,10 @@ gst-launch-1.0 \
t. ! queue ! videoconvert ! autovideosink t. ! queue ! videoconvert ! autovideosink
``` ```
## Tee to two different outputs
Here's an example that sends video to both `autovideosink` and a TCP server (`tcpserversink`). Here's an example that sends video to both `autovideosink` and a TCP server (`tcpserversink`).
Note how `async=false` is required on both sinks. Note how `async=false` is required on both sinks, because the encoding step on the TCP branch takes longer, and so the timing will be different.
``` ```
gst-launch-1.0 videotestsrc ! \ gst-launch-1.0 videotestsrc ! \
@ -22,7 +26,7 @@ gst-launch-1.0 videotestsrc ! \
t. ! queue ! x264enc ! mpegtsmux ! tcpserversink port=7001 host=127.0.0.1 recover-policy=keyframe sync-method=latest-keyframe async=false t. ! queue ! x264enc ! mpegtsmux ! tcpserversink port=7001 host=127.0.0.1 recover-policy=keyframe sync-method=latest-keyframe async=false
``` ```
However, as discussed [here](http://gstreamer-devel.966125.n4.nabble.com/tee-won-t-go-in-playing-state-td4680128.html), `async=false` can cause issues. Adding `tune=zerolatency` to the `x264enc` also resolves the issue. However, as discussed [here](http://gstreamer-devel.966125.n4.nabble.com/tee-won-t-go-in-playing-state-td4680128.html), `async=false` can cause issues. Adding `tune=zerolatency` to the `x264enc` also resolves the issue, by telling the encoding step not to add a delay, and thus making its branch as quick as the `autovideosink` one.
``` ```
gst-launch-1.0 videotestsrc ! \ gst-launch-1.0 videotestsrc ! \
@ -31,6 +35,17 @@ gst-launch-1.0 videotestsrc ! \
t. ! queue ! x264enc tune=zerolatency ! mpegtsmux ! tcpserversink port=7001 host=127.0.0.1 recover-policy=keyframe sync-method=latest-keyframe t. ! queue ! x264enc tune=zerolatency ! mpegtsmux ! tcpserversink port=7001 host=127.0.0.1 recover-policy=keyframe sync-method=latest-keyframe
``` ```
Or, if you'd rather not reduce the quality of x264 encoding, you can increase the queue size:
```
gst-launch-1.0 videotestsrc ! \
decodebin ! tee name=t \
t. ! queue max-size-time=3000000000 ! videoconvert ! autovideosink \
t. ! queue ! x264enc ! mpegtsmux ! tcpserversink port=7001 host=127.0.0.1 recover-policy=keyframe sync-method=latest-keyframe
```
## Tee on inputs
You can also use `tee` in order to do multiple things with inputs. This example combines two audio visualisations: You can also use `tee` in order to do multiple things with inputs. This example combines two audio visualisations:
``` ```