File: gstreamer.liq

package info (click to toggle)
liquidsoap 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,504 kB
  • sloc: ml: 37,149; python: 956; makefile: 624; sh: 458; perl: 322; lisp: 124; ansic: 53; ruby: 8
file content (68 lines) | stat: -rw-r--r-- 2,440 bytes parent folder | download
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
%ifdef input.gstreamer.video

# Stream from a video4linux 2 input device, such as a webcam.
# @category Source / Input
# @param ~id Force the value of the source ID.
# @param ~device V4L2 device to use.
def input.v4l2(~id="",~device="/dev/video0")
  pipeline = "v4l2src device=#{device}"
  input.gstreamer.video(id=id, pipeline=pipeline)
end

# Stream from a video4linux 2 input device, such as a webcam.
# @category Source / Input
# @param ~id Force the value of the source ID.
# @param ~device V4L2 device to use.
def input.v4l2_with_audio(~id="",~device="/dev/video0")
  audio_pipeline = "autoaudiosrc"
  video_pipeline = "v4l2src device=#{device}"
  input.gstreamer.audio_video(id=id, audio_pipeline=audio_pipeline, video_pipeline=video_pipeline)
end

# Play an http live stream.
# @category Source / Input
# @param ~id Force the value of the source ID.
# @param uri URI of the HLS stream index.
def gstreamer.hls(~id="",uri) =
  pipeline = "souphttpsrc location=#{uri} ! tee name=t"
  audio_pipeline = "t. ! queue"
  video_pipeline = "t. ! queue"
  input.gstreamer.audio_video(id=id, pipeline=pipeline, audio_pipeline=audio_pipeline, video_pipeline=video_pipeline)
end

# Encode an x264 video file using gstreamer
# @category Source / Output
# @param fname Encoded file name
# @param source Source
def gstreamer.encode_x264_avi(fname, source)
  output.gstreamer.video(pipeline="videoconvert ! x264enc ! avimux ! filesink location=\"#{fname}\"", source)
end

# Encode jpeg video file using gstreamer
# @category Source / Output
# @param fname Encoded file name
# @param source Source
def gstreamer.encode_jpeg_avi(fname, source)
  output.gstreamer.video(pipeline="videoconvert ! jpegenc ! avimux ! filesink location=\"#{fname}\"", source)
end

# Encode a mp3 file using gstreamer
# @category Source / Output
# @param fname Encoded file name
# @param source Source
def gstreamer.encode_mp3(fname, source)
  output.gstreamer.audio(pipeline="audioconvert ! lamemp3enc ! filesink location=\"#{fname}\"", source)
end

# Broadcast a video in RTP. In order to play it, save the following in xxx.sdp
# and use vlc xxx.sdp:
# v=0
# m=video 5000 RTP/AVP 96
# c=IN IP4 127.0.0.1
# a=rtpmap:96 MP4V-ES/90000
# @category Source / Output
def gstreamer.rtp.mpeg4(~host="127.0.0.1",~port=5000,source)
  output.gstreamer.video(pipeline="videoconvert ! avenc_mpeg4 ! rtpmp4vpay config-interval=2 ! udpsink host=#{host} port=#{port}", source)
end

%endif