Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
R S Nikhil Krishna
gst-docs
Commits
ddbe5ce8
Commit
ddbe5ce8
authored
Dec 29, 2020
by
R S Nikhil Krishna
Committed by
Thibault Saunier
Jan 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated python port of Tutorial 2 with fixed line numbers
Part-of: <
!126
>
parent
be19c302
Pipeline
#253507
waiting for manual action with stages
in 17 seconds
Changes
4
Pipelines
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
278 additions
and
211 deletions
+278
-211
.gitignore
.gitignore
+2
-0
examples/tutorials/python/basic-tutorial-2.py
examples/tutorials/python/basic-tutorial-2.py
+64
-0
images/basic-concepts-pipeline.png
images/basic-concepts-pipeline.png
+0
-0
markdown/tutorials/basic/concepts.md
markdown/tutorials/basic/concepts.md
+212
-211
No files found.
.gitignore
View file @
ddbe5ce8
/built_doc
.vscode
build/
/hotdoc-private*
/.hotdoc.d
/*.stamp
...
...
examples/tutorials/python/basic-tutorial-2.py
0 → 100644
View file @
ddbe5ce8
#!/usr/bin/env python3
import
sys
import
gi
import
logging
gi
.
require_version
(
"GLib"
,
"2.0"
)
gi
.
require_version
(
"GObject"
,
"2.0"
)
gi
.
require_version
(
"Gst"
,
"1.0"
)
from
gi.repository
import
Gst
,
GLib
,
GObject
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
"[%(name)s] [%(levelname)8s] - %(message)s"
)
logger
=
logging
.
getLogger
(
__name__
)
# Initialize GStreamer
Gst
.
init
(
sys
.
argv
[
1
:])
# Create the elements
source
=
Gst
.
ElementFactory
.
make
(
"videotestsrc"
,
"source"
)
sink
=
Gst
.
ElementFactory
.
make
(
"autovideosink"
,
"sink"
)
# Create the empty pipeline
pipeline
=
Gst
.
Pipeline
.
new
(
"test-pipeline"
)
if
not
pipeline
or
not
source
or
not
sink
:
logger
.
error
(
"Not all elements could be created."
)
sys
.
exit
(
1
)
# Build the pipeline
pipeline
.
add
(
source
,
sink
)
if
not
source
.
link
(
sink
):
logger
.
error
(
"Elements could not be linked."
)
sys
.
exit
(
1
)
# Modify the source's properties
source
.
props
.
pattern
=
0
# Can alternatively be done using `source.set_property("pattern",0)`
# or using `Gst.util_set_object_arg(source, "pattern", 0)`
# Start playing
ret
=
pipeline
.
set_state
(
Gst
.
State
.
PLAYING
)
if
ret
==
Gst
.
StateChangeReturn
.
FAILURE
:
logger
.
error
(
"Unable to set the pipeline to the playing state."
)
sys
.
exit
(
1
)
# Wait for EOS or error
bus
=
pipeline
.
get_bus
()
msg
=
bus
.
timed_pop_filtered
(
Gst
.
CLOCK_TIME_NONE
,
Gst
.
MessageType
.
ERROR
|
Gst
.
MessageType
.
EOS
)
# Parse message
if
msg
:
if
msg
.
type
==
Gst
.
MessageType
.
ERROR
:
err
,
debug_info
=
msg
.
parse_error
()
logger
.
error
(
f
"Error received from element
{
msg
.
src
.
get_name
()
}
:
{
err
.
message
}
"
)
logger
.
error
(
f
"Debugging information:
{
debug_info
if
debug_info
else
'none'
}
"
)
elif
msg
.
type
==
Gst
.
MessageType
.
EOS
:
logger
.
info
(
"End-Of-Stream reached."
)
else
:
# This should not happen as we only asked for ERRORs and EOS
logger
.
error
(
"Unexpected message received."
)
pipeline
.
set_state
(
Gst
.
State
.
NULL
)
images/basic-concepts-pipeline.png
0 → 100644
View file @
ddbe5ce8
13.7 KB
markdown/tutorials/basic/concepts.md
View file @
ddbe5ce8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment