Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add video format i420 #15

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog

### v0.0.2 (16.04.2020)
- fixed "iterator not iterable" error (by edumotya)
- support for python3.5
- added blocking to appsrc to reduce memory consumption by queue

### v0.0.1 (18.01.2020)
- Released stable version
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## gstreamer-python
### Purpose
- abstraction over [PyGOBJECT API](https://lazka.github.io/pgi-docs/) for Gstreamer
- work with Gstreamer metadata
- common tools for Gstreamer pipeline management
- easy [gst-python](https://github.com/GStreamer/gst-python) installation

### Install
#### Install OS packages
- [How to install Gstreamer on Ubuntu](http://lifestyletransfer.com/how-to-install-gstreamer-on-ubuntu/)
Expand Down
8 changes: 4 additions & 4 deletions examples/gst_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
VIDEO_FORMAT = GstVideo.VideoFormat.RGB

video_format_str = GstVideo.VideoFormat.to_string(VIDEO_FORMAT)
caps_filter = f"capsfilter caps=video/x-raw,format={video_format_str},width={WIDTH},height={HEIGHT}"
command = f"videotestsrc num-buffers={NUM_BUFFERS} ! {caps_filter} ! appsink emit-signals=True sync=false"
caps_filter = "capsfilter caps=video/x-raw,format={video_format_str},width={WIDTH},height={HEIGHT}".format(**locals())
command = "videotestsrc num-buffers={NUM_BUFFERS} ! {caps_filter} ! appsink emit-signals=True sync=false".format(**locals())

last_buffer = None
with GstContext(), GstVideoSource(command) as pipeline:

while pipeline.is_active or pipeline.queue_size > 0:
buffer = pipeline.pop()
if buffer:
print(f"{Gst.TIME_ARGS(buffer.pts)}: shape {buffer.data.shape}")
print("{}: shape {}".format(Gst.TIME_ARGS(buffer.pts), buffer.data.shape))
last_buffer = buffer

print(f"Read {last_buffer.offset} buffers")
print("Read {} buffers".format(last_buffer.offset))
6 changes: 3 additions & 3 deletions examples/gst_capture_and_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
VIDEO_FORMAT = GstVideo.VideoFormat.RGB

video_format_str = GstVideo.VideoFormat.to_string(VIDEO_FORMAT)
caps_filter = f"capsfilter caps=video/x-raw,format={video_format_str},width={WIDTH},height={HEIGHT}"
capture_cmd = f"videotestsrc num-buffers={NUM_BUFFERS} ! {caps_filter} ! appsink emit-signals=True sync=false"
caps_filter = "capsfilter caps=video/x-raw,format={video_format_str},width={WIDTH},height={HEIGHT}".format(**locals())
capture_cmd = "videotestsrc num-buffers={NUM_BUFFERS} ! {caps_filter} ! appsink emit-signals=True sync=false".format(**locals())

display_cmd = "appsrc emit-signals=True is-live=True ! videoconvert ! gtksink sync=false"

Expand All @@ -29,4 +29,4 @@
if buffer:
display.push(buffer.data, pts=buffer.pts,
dts=buffer.dts, offset=buffer.offset)
# print(f"{Gst.TIME_ARGS(buffer.pts)}: shape {buffer.data.shape}")
# print("{}: shape {}".format(Gst.TIME_ARGS(buffer.pts), buffer.data.shape))
2 changes: 1 addition & 1 deletion examples/gst_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
while pipeline.is_done:
pass

print(f"Displayed {pipeline.total_buffers_count} buffers")
print("Displayed {} buffers".format(pipeline.total_buffers_count))
2 changes: 1 addition & 1 deletion examples/gst_launch_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if __name__ == '__main__':
with GstContext():
pipelines = [GstPipeline(
f"videotestsrc num-buffers={randint(50, 300)} ! gtksink") for _ in range(5)]
"videotestsrc num-buffers={} ! gtksink".format(randint(50, 300))) for _ in range(5)]

for p in pipelines:
p.startup()
Expand Down
Loading