Capturing images

This commit is contained in:
Matthew Clark 2018-02-20 13:12:12 +00:00
parent e365f6a1c1
commit c557004c9d
9 changed files with 48 additions and 2 deletions

View file

@ -8,6 +8,7 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line.
* [Basics](basics.md) * [Basics](basics.md)
* [RTMP](rtmp.md) * [RTMP](rtmp.md)
* [Mixing video](mixing.md) * [Mixing video](mixing.md)
* [Capturing images](capturing_images.md)
## Sources and references ## Sources and references

29
capturing_images.md Normal file
View file

@ -0,0 +1,29 @@
# Capturing images (GStreamer command-line cheat sheet)
### Capture an image as png
```
gst-launch-1.0 videotestsrc ! pngenc ! filesink location=foo.png
```
### Capture an image as jpeg
```
gst-launch-1.0 videotestsrc ! jpegenc ! filesink location=foo.jpg
```
### Capturing images every X seconds
This example captures one frame every 3 seconds, and places it in files with the format `img00001.jpg`.
It also displays the video (as the `tee` command sends the video to both `multifilesink` and `autovideosink`).
To change the frequency, change the `framerate=1/3`.
e.g. `framerate=2/1` would capture a frame twice a second.
```
gst-launch-1.0 videotestsrc ! \
videoscale ! videoconvert ! video/x-raw,width=640,height=480 ! \
queue ! decodebin ! tee name=t ! queue ! videoconvert ! videoscale ! \
videorate ! video/x-raw,width=640,height=480,framerate=1/3 ! \
jpegenc ! multifilesink location=img%05d.jpg t. ! queue ! autovideosink
```

BIN
images/test-pattern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/test_colors.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/test_pinwheel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
images/test_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

BIN
images/test_smpte100.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

BIN
images/test_snow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -1,12 +1,28 @@
# Test streams (GStreamer command-line cheat sheet) # Test streams (GStreamer command-line cheat sheet)
Display a test pattern: ### Display a test pattern
``` ```
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
``` ```
Listen to a test audio (beep): This should display the test pattern in a window, that looks a
bit like this:
![Test pattern window](images/test-pattern.png "Test pattern window")
There are multiple test patterns available, such as
| `videotestsrc pattern=snow` | !(images/test_snow.png) |
| `videotestsrc pattern=red` (and blue and green) | !(images/test_red.png) |
| `videotestsrc pattern=red` (and blue and green) | !(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)
``` ```
gst-launch-1.0 audiotestsrc ! audioconvert ! autoaudiosink gst-launch-1.0 audiotestsrc ! audioconvert ! autoaudiosink