mirror of
https://github.com/matthew1000/gstreamer-cheat-sheet.git
synced 2024-11-21 07:51:00 +00:00
Improve RTMP examples, amongst other things
This commit is contained in:
parent
7eab17fd69
commit
d12138e065
4 changed files with 63 additions and 19 deletions
|
@ -17,3 +17,8 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line.
|
|||
* [List of all Gstreamer plugins](https://gstreamer.freedesktop.org/documentation/plugins.html)
|
||||
* [Handy elements](https://gstreamer.freedesktop.org/documentation/tutorials/basic/handy-elements.html#uridecodebin)
|
||||
|
||||
## Other cheat sheets
|
||||
|
||||
* http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet
|
||||
* https://github.com/xmementoit/gstreamerCheatsheet/blob/master/README.md
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ export SRC=/home/me/videos/test.mp4
|
|||
|
||||
### Play a video (with audio)
|
||||
|
||||
|
||||
|
||||
```
|
||||
gst-launch-1.0 -v playbin uri=file://$SRC
|
||||
```
|
||||
|
@ -18,7 +20,7 @@ or, if you'd rather have more control of the pipeline:
|
|||
|
||||
```
|
||||
gst-launch-1.0 filesrc location=$SRC ! \
|
||||
qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! \
|
||||
qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! \
|
||||
autoaudiosink \
|
||||
demux.video_0 ! queue ! \
|
||||
decodebin ! videoconvert ! videoscale ! autovideosink
|
||||
|
|
68
rtmp.md
68
rtmp.md
|
@ -6,30 +6,66 @@ If you need your own RTMP server, [the Nginx RTMP extension](https://github.com/
|
|||
|
||||
### Play an RTMP stream
|
||||
|
||||
To play from RTMP server, at the path `/live/x`, with the server name in the environment variable `RTMP_SERVER`:
|
||||
To play from RTMP server, playbin can be used (as with files and HLS streams):
|
||||
|
||||
```
|
||||
gst-launch-1.0 uridecodebin uri='rtmp://$RTMP_SERVER/live/x' ! \
|
||||
videoconvert ! videorate ! videoscale ! videoconvert ! \
|
||||
video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive,framerate=24/1, width=640, height=360 ! \
|
||||
autovideosink
|
||||
gst-launch-1.0 playbin uri=$RTMP_SRC
|
||||
```
|
||||
|
||||
Russia Today is available over RTMP at `https://rtmp.api.rt.com/hls/rtdru360.m3u8`. So you can watch it with:
|
||||
A test RTMP stream is available at `rtmp://184.72.239.149/vod/BigBuckBunny_115k.mov` which serves as a useful example:
|
||||
|
||||
```
|
||||
gst-launch-1.0 uridecodebin uri='https://rtmp.api.rt.com/hls/rtdru360.m3u8' ! \
|
||||
videoconvert ! videorate ! videoscale ! videoconvert ! \
|
||||
video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive,framerate=24/1, width=640, height=360 ! \
|
||||
autovideosink
|
||||
gst-launch-1.0 playbin uri='rtmp://184.72.239.149/vod/BigBuckBunny_115k.mov'
|
||||
```
|
||||
|
||||
### Stream TO an RTMP server
|
||||
|
||||
At the path '/live/x', with the server name in the environment variable `RTMP_SERVER`:
|
||||
Instead of using `playbin`, it's possible to get video only with `uridecodebin` then shown with `autovideosink`:
|
||||
|
||||
```
|
||||
gst-launch-1.0 videotestsrc \
|
||||
is-live=true ! queue ! x264enc ! flvmux name=muxer ! \
|
||||
rtmpsink location='rtmp://$RTMP_SERVER/live/x'
|
||||
gst-launch-1.0 uridecodebin uri=$RTMP_SRC ! autovideosink
|
||||
```
|
||||
|
||||
Or as a step further we can split out into the source and decode too. This does video:
|
||||
|
||||
```
|
||||
gst-launch-1.0 rtmpsrc location=$RTMP_SRC ! decodebin ! autovideosink
|
||||
```
|
||||
|
||||
and this does the audio:
|
||||
|
||||
```
|
||||
gst-launch-1.0 rtmpsrc name=rtmpsrc location=$RTMP_SRC ! decodebin ! \
|
||||
queue ! audioconvert ! autoaudiosink
|
||||
```
|
||||
|
||||
We can vget flvdemux to pull out the audio:
|
||||
|
||||
```
|
||||
gst-launch-1.0 rtmpsrc location=$RTMP_SRC ! \
|
||||
flvdemux name=t t.audio ! decodebin ! autoaudiosink
|
||||
```
|
||||
|
||||
Incidentally, all of these work with a direct flv file:
|
||||
|
||||
```
|
||||
gst-launch-1.0 filesrc location="/Users/clarkm22/workspace/silver/assets/test.flv" ! \
|
||||
flvdemux name=t t.audio ! decodebin ! autoaudiosink
|
||||
```
|
||||
|
||||
If you want to use `flvdemux` to do the video, you need to capture the audio too or else it will fail. This example puts it in `fakesink` which is basically discarding it:
|
||||
|
||||
```
|
||||
gst-launch-1.0 rtmpsrc location="$RTMP_SRC" ! \
|
||||
flvdemux name=demux \
|
||||
demux.audio ! queue ! decodebin ! fakesink \
|
||||
demux.video ! queue ! decodebin ! autovideosink
|
||||
```
|
||||
|
||||
You could then use this to capture the RTMP as an MP4, e.g.
|
||||
|
||||
```
|
||||
gst-launch-1.0 -e rtmpsrc location="$RTMP_SRC" ! \
|
||||
flvdemux name=demux \
|
||||
demux.audio ! queue ! decodebin ! audioconvert ! faac bitrate=32000 ! mux. \
|
||||
demux.video ! queue ! decodebin ! videoconvert ! video/x-raw,format=I420 ! x264enc speed-preset=superfast tune=zerolatency psy-tune=grain sync-lookahead=5 bitrate=480 key-int-max=50 ref=2 ! mux. \
|
||||
mp4mux name=mux ! filesink location="out.mp4"
|
||||
```
|
||||
|
|
|
@ -16,14 +16,15 @@ There are multiple test patterns available, such as
|
|||
| Pattern | Example |
|
||||
| ------------- |:-------------:|
|
||||
| `videotestsrc pattern=snow` | ![](images/test_snow.png) |
|
||||
| `videotestsrc pattern=red` (and blue and green) | ![](images/test_red.png) |
|
||||
| `videotestsrc pattern=red` (and blue, green, white and black) | ![](images/test_red.png) |
|
||||
| `videotestsrc pattern=pinwheel` | ![](images/test_pinwheel.png) |
|
||||
| `videotestsrc pattern=smpte100` (color test bars) | ![](images/test_smpte100.png) |
|
||||
| `videotestsrc pattern=colors` | ![](images/test_colors.png) |
|
||||
|
||||
For the full list of patterns, see https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videotestsrc.html
|
||||
|
||||
### Listen to a test audio (beep)
|
||||
|
||||
### Listen to a test audio (beep)
|
||||
|
||||
```
|
||||
gst-launch-1.0 audiotestsrc ! audioconvert ! autoaudiosink
|
||||
|
|
Loading…
Reference in a new issue