forked from stb-tester/stb-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstbt-tv
executable file
·81 lines (71 loc) · 3.09 KB
/
stbt-tv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Copyright 2013 YouView TV Ltd.
# License: LGPL v2.1 or (at your option) any later version (see
# https://github.com/stb-tester/stb-tester/blob/master/LICENSE for details).
#/ usage: stbt tv [-h] [-f] [-v] [source pipeline]
#/
#/ Show the video captured from the GStreamer source pipeline specified on the
#/ command line or in your stbt config file.
#/
#/ The appropriate sink for your system will be used, regardless of the
#/ sink_pipeline specified in your stbt configuration file.
#/
#/ Options:
#/ -h, --help Show this help message and exit.
#/ -f Do not show video output (i.e. direct the output to
#/ 'fakesink'). This is to activate the pass-through output of
#/ Blackmagic cards for monitoring.
#/ -l Listen to client connections and stream compressed video
#/ through a TCP socket. Port number and video bandwidth (in
#/ bps) are read from the 'port' and 'bandwidth' parameters of
#/ the [tv] section of the stb-tester config file, or the
#/ default values 4953 for port number and 1500000 bps for
#/ bandwidth are used. Watch the stream on a remote computer
#/ with VLC by opening 'tcp://<host>:<port>', or with
#/ GStreamer's 'tcpclientsrc'.
#/ -v Enable 'gst-launch' verbose output.
set -eu
script_dir="$(dirname "$0")"
usage() { grep '^#/' "$0" | cut -c4-; }
die() { echo "stbt tv: error: $*" >&2; exit 1; }
while [ $# -gt 0 ]; do
case "$1" in
-h|--help) usage; exit 0;;
-f) sink="fakesink silent=true";;
-l) gst-inspect ffenc_mpeg4 &>/dev/null ||
die "'-l' requires gstreamer-ffmpeg package"
port=$(stbt config tv.port 2>/dev/null || echo 4953);
bw=$(stbt config tv.bandwidth 2>/dev/null || echo 1500000);
sink="queue leaky=downstream ! ffenc_mpeg4 bitrate=$bw !
mpegtsmux ! tcpserversink port=$port"
echo "Point vlc at: tcp://$(hostname):$port"
;;
-v) v="-v";;
-*) usage >&2; exit 1;;
*) break;;
esac
shift
done
get_config () { "$script_dir/stbt-config" "$1" ; }
source_pipeline="${*:-$(get_config global.source_pipeline)}"
transformation_pipeline="$(get_config global.transformation_pipeline)"
: ${sink:=$(
case "$(uname)" in
(Darwin) echo "osxvideosink force-aspect-ratio=true";;
(Linux) lspci | grep -Eq '(VMware|VirtualBox)' &&
echo "ximagesink force-aspect-ratio=true" || \
echo "xvimagesink force-aspect-ratio=true";;
(*) echo "ximagesink force-aspect-ratio=true";;
esac)}
set -x
eval gst-launch-1.0 ${v:-} \
$source_pipeline \
! queue name=_stbt_user_data_queue max-size-buffers=0 \
max-size-bytes=0 max-size-time=1000000000 \
! decodebin \
! queue name=_stbt_raw_frames_queue max-size-buffers=2 leaky=upstream \
! videoconvert \
! video/x-raw,format=BGR \
! $transformation_pipeline \
! videoconvert \
! $sink sync=false