mirror of
https://github.com/matthew1000/gstreamer-cheat-sheet.git
synced 2024-11-24 09:11:00 +00:00
Fix markdown
This commit is contained in:
parent
5065eecd11
commit
98e56613d7
4 changed files with 23 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Basics (GStreamer command-line cheat sheet)
|
# Basics (GStreamer command-line cheat sheet)
|
||||||
|
|
||||||
|
|
||||||
## Playing content
|
## Playing content
|
||||||
|
|
||||||
These examples assume that bash variable `SRC` to be set to a video file (e.g. an mp4 file). You can do this by, e.g.
|
These examples assume that bash variable `SRC` to be set to a video file (e.g. an mp4 file). You can do this by, e.g.
|
||||||
|
@ -8,6 +9,7 @@ These examples assume that bash variable `SRC` to be set to a video file (e.g. a
|
||||||
export SRC=/home/me/videos/test.mp4
|
export SRC=/home/me/videos/test.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Play a video (with audio)
|
### Play a video (with audio)
|
||||||
|
|
||||||
The magical element `playbin` can play anything:
|
The magical element `playbin` can play anything:
|
||||||
|
@ -34,6 +36,7 @@ gst-launch-1.0 filesrc location=$SRC ! \
|
||||||
decodebin ! videoconvert ! videoscale ! autovideosink
|
decodebin ! videoconvert ! videoscale ! autovideosink
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Play a video (no audio)
|
### Play a video (no audio)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -46,6 +49,7 @@ which could also have been done as:
|
||||||
gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! autovideosink
|
gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! autovideosink
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Play just the audio from a video
|
### Play just the audio from a video
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -97,6 +97,7 @@ gst-launch-1.0 \
|
||||||
|
|
||||||
Use the `audiomixer` element to mix audio. It replaces the `adder` element, which struggles under some circumstances (according to the [GStreamer 1.14 release notes](https://gstreamer.freedesktop.org/releases/1.14/)).
|
Use the `audiomixer` element to mix audio. It replaces the `adder` element, which struggles under some circumstances (according to the [GStreamer 1.14 release notes](https://gstreamer.freedesktop.org/releases/1.14/)).
|
||||||
|
|
||||||
|
|
||||||
### Mix two (or more) test audio streams
|
### Mix two (or more) test audio streams
|
||||||
|
|
||||||
Here we use two different frequencies (tones):
|
Here we use two different frequencies (tones):
|
||||||
|
@ -108,10 +109,12 @@ gst-launch-1.0 \
|
||||||
audiotestsrc freq=600 ! mix.
|
audiotestsrc freq=600 ! mix.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Mix two test streams, dynamically
|
### Mix two test streams, dynamically
|
||||||
|
|
||||||
[This Python example](python_examples/audio_dynamic_add.py) shows a dynamic equivalent of this example - the second test source is only mixed when the user presses Enter.
|
[This Python example](python_examples/audio_dynamic_add.py) shows a dynamic equivalent of this example - the second test source is only mixed when the user presses Enter.
|
||||||
|
|
||||||
|
|
||||||
### Mix two (or more) MP3 files
|
### Mix two (or more) MP3 files
|
||||||
|
|
||||||
Ensure `$AUDIO_SRC` and `$AUDIO_SRC2` environment variables are set to mp3 files.
|
Ensure `$AUDIO_SRC` and `$AUDIO_SRC2` environment variables are set to mp3 files.
|
||||||
|
@ -123,6 +126,7 @@ gst-launch-1.0 \
|
||||||
filesrc location=$AUDIO_SRC2 ! mpegaudioparse ! decodebin ! mix.
|
filesrc location=$AUDIO_SRC2 ! mpegaudioparse ! decodebin ! mix.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Mix a test stream with an MP3 file
|
### Mix a test stream with an MP3 file
|
||||||
|
|
||||||
Because the audio streams are from different sources, they must each be passed through `audioconvert`.
|
Because the audio streams are from different sources, they must each be passed through `audioconvert`.
|
||||||
|
@ -134,8 +138,10 @@ gst-launch-1.0 \
|
||||||
filesrc location=$AUDIO_SRC ! mpegaudioparse ! decodebin ! audioconvert ! mix.
|
filesrc location=$AUDIO_SRC ! mpegaudioparse ! decodebin ! audioconvert ! mix.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Mixing video & audio together
|
## Mixing video & audio together
|
||||||
|
|
||||||
|
|
||||||
### Mix two fake video sources and two fake audio Sources
|
### Mix two fake video sources and two fake audio Sources
|
||||||
|
|
||||||
We use `compositor` to mix the video and `audiomixer` to mix the audio.
|
We use `compositor` to mix the video and `audiomixer` to mix the audio.
|
||||||
|
@ -172,6 +178,7 @@ gst-launch-1.0 \
|
||||||
audiotestsrc freq=600 ! audiomix.
|
audiotestsrc freq=600 ! audiomix.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Mix a AV file with fake video and audio
|
### Mix a AV file with fake video and audio
|
||||||
|
|
||||||
This one puts a bouncing ball in the corner of a file:
|
This one puts a bouncing ball in the corner of a file:
|
||||||
|
@ -232,6 +239,7 @@ gst-launch-1.0 \
|
||||||
audiotestsrc freq=400 volume=0.2 ! audiomix.
|
audiotestsrc freq=400 volume=0.2 ! audiomix.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Mix two AV files
|
### Mix two AV files
|
||||||
|
|
||||||
This does picture-in-picture, with the audio from both files included.
|
This does picture-in-picture, with the audio from both files included.
|
||||||
|
|
|
@ -23,11 +23,11 @@ _As with the rest of this site, this is a rough guide, and is probably not compl
|
||||||
| Name | Description | Points to note | Further reading |
|
| Name | Description | Points to note | Further reading |
|
||||||
| ---- | ----------- | -------------- | --------------- |
|
| ---- | ----------- | -------------- | --------------- |
|
||||||
| *shmsink and shmsrc* | Allows video to be read/written from shared memory | Used to send/receive from Snowmix | See below |
|
| *shmsink and shmsrc* | Allows video to be read/written from shared memory | Used to send/receive from Snowmix | See below |
|
||||||
| *appsrc/appsink* | Allows video data to leave/enter the pipeline from your own application | n/a | https://thiblahute.github.io/GStreamer-doc/app-1.0/index.html?gi-language=c |
|
| *appsrc/appsink* | Allows video data to leave/enter the pipeline from your own application | n/a | [Docs](https://thiblahute.github.io/GStreamer-doc/app-1.0/index.html?gi-language=c) |
|
||||||
| *fdsrc/fdsink* | Allows communication via a file descriptor | n/a | https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fdsrc.html |
|
| *fdsrc/fdsink* | Allows communication via a file descriptor | n/a | [Docs](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fdsrc.html) |
|
||||||
| *interpipe* | Allows simple communication between two or more independent pipelines. Very powerful. | * Not part of GStreamer (though it is open-source... I'm not sure why it's not been included) | * Well-documented at https://developer.ridgerun.com/wiki/index.php?title=GstInterpipe<br>* https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2015/Melissa%20Montero%20-%20GST%20Daemon%20and%20Interpipes:%20A%20simpler%20way%20to%20get%20your%20applications%20done%20.pdf |
|
| *interpipe* | Allows simple communication between two or more independent pipelines. Very powerful. | * Not part of GStreamer (though it is open-source... I'm not sure why it's not been included) | [Great RidgeRun docs](https://developer.ridgerun.com/wiki/index.php?title=GstInterpipe) [Presentation](https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2015/Melissa%20Montero%20-%20GST%20Daemon%20and%20Interpipes:%20A%20simpler%20way%20to%20get%20your%20applications%20done%20.pdf) |
|
||||||
| *inter* (intervideosink, etc) | Send/receive AV between two pipelines in the same process | Only support raw audio or video, and drop events and queries at the boundary (source: [Nirbheek's blog](http://blog.nirbheek.in/2018/02/decoupling-gstreamer-pipelines.html)) | See below |
|
| *inter* (intervideosink, etc) | Send/receive AV between two pipelines in the same process | Only support raw audio or video, and drop events and queries at the boundary (source: [Nirbheek's blog](http://blog.nirbheek.in/2018/02/decoupling-gstreamer-pipelines.html)) | See below |
|
||||||
| *ipcpipeline* | Allows communication between pipelines *in different processes*. | Arrived with GStreamer 1.14 (Spring 2018) | https://www.collabora.com/news-and-blog/blog/2017/11/17/ipcpipeline-splitting-a-gstreamer-pipeline-into-multiple-processes/ |
|
| *ipcpipeline* | Allows communication between pipelines *in different processes*. | Arrived with GStreamer 1.14 (Spring 2018) | [Collabora post](https://www.collabora.com/news-and-blog/blog/2017/11/17/ipcpipeline-splitting-a-gstreamer-pipeline-into-multiple-processes/) |
|
||||||
| *gstproxy (proxysink and proxysrc)* | Send/receive AV between two pipelines in the same process. | Arrived with GStreamer 1.14 (Spring 2018) | See below |
|
| *gstproxy (proxysink and proxysrc)* | Send/receive AV between two pipelines in the same process. | Arrived with GStreamer 1.14 (Spring 2018) | See below |
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,12 +76,14 @@ I've used `proxysink` and `proxysrc` to split larger pipelines into smaller ones
|
||||||
|
|
||||||
Unlike _inter_ below, _proxy_ will keep timing in sync. This is great if it's what you want... but if you want pipelines to have their own timing, it might not be right for your needs..
|
Unlike _inter_ below, _proxy_ will keep timing in sync. This is great if it's what you want... but if you want pipelines to have their own timing, it might not be right for your needs..
|
||||||
|
|
||||||
|
|
||||||
### gstproxy documentation
|
### gstproxy documentation
|
||||||
|
|
||||||
* Introduced by the blog mentioned above (http://blog.nirbheek.in/2018/02/decoupling-gstreamer-pipelines.html)
|
* Introduced by the blog mentioned above (http://blog.nirbheek.in/2018/02/decoupling-gstreamer-pipelines.html)
|
||||||
* Example code on proxysrc here: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-plugins/html/gst-plugins-bad-plugins-proxysrc.html
|
* Example code on proxysrc here: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-plugins/html/gst-plugins-bad-plugins-proxysrc.html
|
||||||
* Equivalent proxysink: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-plugins/html/gst-plugins-bad-plugins-proxysink.html
|
* Equivalent proxysink: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-plugins/html/gst-plugins-bad-plugins-proxysink.html
|
||||||
|
|
||||||
|
|
||||||
### gstproxy examples
|
### gstproxy examples
|
||||||
|
|
||||||
It's not possible to use them via the command-line, because you connect them by having the receiver (`proxysrc`) reference the sender (`proxysink`).
|
It's not possible to use them via the command-line, because you connect them by having the receiver (`proxysrc`) reference the sender (`proxysink`).
|
||||||
|
@ -105,6 +107,7 @@ A slightly more interesting example can be found at
|
||||||
* separate proxies for audio and video
|
* separate proxies for audio and video
|
||||||
* that when the video ends, the other pipelines continue.
|
* that when the video ends, the other pipelines continue.
|
||||||
|
|
||||||
|
|
||||||
## inter (intervideosink/intervideosrc and their audio & subtitle counterparts)
|
## inter (intervideosink/intervideosrc and their audio & subtitle counterparts)
|
||||||
|
|
||||||
The 'inter' versions of 'proxy' are dumber. They don't attempt to sync timings. But this can be useful if you want pipelines to be more independent. (Pros and cons on this discussed [here](http://gstreamer-devel.966125.n4.nabble.com/How-to-connect-intervideosink-and-intervideosrc-for-IPC-pipelines-td4684567.html).)
|
The 'inter' versions of 'proxy' are dumber. They don't attempt to sync timings. But this can be useful if you want pipelines to be more independent. (Pros and cons on this discussed [here](http://gstreamer-devel.966125.n4.nabble.com/How-to-connect-intervideosink-and-intervideosrc-for-IPC-pipelines-td4684567.html).)
|
||||||
|
@ -121,4 +124,4 @@ An example can't be done via the command-line, but here is a simple example usin
|
||||||
|
|
||||||
Here's a more complex example, showing how two files can have separate seeking by being in different pipelines:
|
Here's a more complex example, showing how two files can have separate seeking by being in different pipelines:
|
||||||
|
|
||||||
[/python_examples/gstinter_02_separate_seeking](/python_examples/gstinter_02_separate_seeking)
|
[/python_examples/gstinter_02_separate_seeking.py](/python_examples/gstinter_02_separate_seeking.py)
|
||||||
|
|
|
@ -4,6 +4,7 @@ The [`filesink`](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstre
|
||||||
|
|
||||||
Note that, when using the command-line, the `-e` parameter ensures the output file is correctly completed on exit.
|
Note that, when using the command-line, the `-e` parameter ensures the output file is correctly completed on exit.
|
||||||
|
|
||||||
|
|
||||||
### Write to an mp4 file
|
### Write to an mp4 file
|
||||||
|
|
||||||
This example creates a test video (animated ball moving, with clock), and writes it as an MP4 file.
|
This example creates a test video (animated ball moving, with clock), and writes it as an MP4 file.
|
||||||
|
@ -20,8 +21,10 @@ gst-launch-1.0 -e videotestsrc pattern=ball ! \
|
||||||
mp4mux name=mux ! filesink location=file.mp4
|
mp4mux name=mux ! filesink location=file.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Other examples
|
### Other examples
|
||||||
|
|
||||||
|
*TODO* more descriptions here!
|
||||||
|
|
||||||
```
|
```
|
||||||
gst-launch-1.0 -e videotestsrc ! video/x-raw-yuv, framerate=25/1, width=640, height=360 ! x264enc ! \
|
gst-launch-1.0 -e videotestsrc ! video/x-raw-yuv, framerate=25/1, width=640, height=360 ! x264enc ! \
|
||||||
|
|
Loading…
Reference in a new issue