-
Notifications
You must be signed in to change notification settings - Fork 148
Gstreamer video recorder: add python bindings #1518
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
Merged
bhashemian
merged 37 commits into
nvidia-holoscan:main
from
tecnalia-medical-robotics:feature/gstreamer-python-binding
Apr 27, 2026
Merged
Changes from 17 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
8d28b19
Gstreamer video recorder: add python bindings
asierfernandez f7fb101
Fix linter
asierfernandez c0c2a1e
Update operators/gstreamer/python/gst_video_recorder_op.cpp
asierfernandez cecfeaf
Fix identation
asierfernandez 48d7ecf
delete duplicated comments
asierfernandez aedee55
Connect docstrings to bindings
asierfernandez 93498ff
Clean text in pydoc
asierfernandez 4f104cf
Merge branch 'main' into feature/gstreamer-python-binding
bhashemian f21d34f
Add new layout to handle cpp and python applications
asierfernandez d38520e
Add python gst_video_recoder application
asierfernandez 5f140be
Install gstreamer tools for development and debugging
asierfernandez 7ce6073
Update documentation for the python gst_video_recorder application
asierfernandez 668d687
Fix the inconsistency between default storage and cupy
asierfernandez c46e64f
Complete cli arguments validation
asierfernandez ce15c98
Apply black formatter
asierfernandez d71230d
Fix pre-commit errors
asierfernandez e47b070
Merge branch 'main' into feature/gstreamer-python-binding
bhashemian f5e0e4d
fix gst_video_recorder common include path
asierfernandez 6c68bd0
Remove stale recorder output for tests
asierfernandez 9b094e4
vectorize SMPTE color bar generation
asierfernandez 63bc0bd
Align GstVideoRecorderOp pydoc symbol naming
asierfernandez a967bde
Add Python import smoke test for GstVideoRecorderOp binding
asierfernandez 90b04f6
Set default device storage in python implementation
asierfernandez 197ca99
Add required tests
asierfernandez e6009a4
Handle invalid --property values with SystemExit
asierfernandez 549a488
Remove unused allocator from Python pattern generator
asierfernandez 074ead6
Accept --count 0 as explicit unlimited alias
asierfernandez a0a6f6a
Fix mode order
asierfernandez 9f2310c
Adjust metadata version release numbers
asierfernandez 46ca63c
Remove unreachable CuPy guard in pattern generator
asierfernandez 178236b
Move GstVideoRecorderOp Python bindings to holoscan namespace
asierfernandez 0ca0515
Fix gst_video_recorder launching command example
asierfernandez 80c6b18
Document Python binding usage for GstVideoRecorderOp
asierfernandez a5fbf2d
The Python docstring now includes both fragment and name
asierfernandez 4437b75
Added a minimal Python test suite for the binding covering importability
asierfernandez ee7ecd7
Clarify CuPy requirement in Python gst_video_recorder
asierfernandez 50d8b0f
fix metadata and readme
bhashemian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
applications/gstreamer/gst_video_recorder/cpp/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| project(gst_video_recorder CXX) | ||
|
|
||
| find_package(holoscan REQUIRED CONFIG | ||
| PATHS "/opt/nvidia/holoscan" "/workspace/holoscan-sdk/install") | ||
|
|
||
| add_executable(gst-video-recorder | ||
| ../../common/pattern_generator.cpp | ||
| gst_video_recorder.cpp | ||
| ) | ||
|
|
||
| target_include_directories(gst-video-recorder | ||
| PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../common | ||
| ) | ||
|
|
||
| target_link_libraries(gst-video-recorder | ||
| PRIVATE | ||
| holoscan::core | ||
| holoscan::ops::gstreamer_bridge | ||
| holoscan::ops::v4l2 | ||
| holoscan::ops::format_converter | ||
| ) | ||
|
|
||
| # Install target | ||
| install(TARGETS gst-video-recorder DESTINATION bin/gst_video_recorder) | ||
|
|
||
|
|
||
| if(BUILD_TESTING) | ||
| # Set and create the recording directory | ||
| set(RECORDING_DIR ${CMAKE_CURRENT_BINARY_DIR}/recording_output) | ||
| file(MAKE_DIRECTORY ${RECORDING_DIR}) | ||
|
|
||
| # Set the output file | ||
| set(OUTPUT_FILE ${RECORDING_DIR}/test_output.mp4) | ||
| message(STATUS "Output test file: ${OUTPUT_FILE}") | ||
|
|
||
| # Test 1: check if the pipeline runs successfully | ||
| add_test( | ||
| NAME gst_video_recorder_test | ||
| COMMAND $<TARGET_FILE:gst-video-recorder> --source pattern --count 10 -o ${OUTPUT_FILE} | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| ) | ||
|
|
||
| # Set the test passing if the pipeline runs successfully | ||
| set_tests_properties(gst_video_recorder_test PROPERTIES | ||
| PASS_REGULAR_EXPRESSION "EOS processed, pipeline finished cleanly" | ||
| ) | ||
|
|
||
| # Test 2: check if the output file was created | ||
| add_test( | ||
| NAME gst_video_recorder_output_file_test | ||
| COMMAND bash -c "test -f ${OUTPUT_FILE}" | ||
| ) | ||
|
|
||
| # Make the file check test depend on the pipeline test | ||
| set_tests_properties(gst_video_recorder_output_file_test PROPERTIES | ||
| DEPENDS gst_video_recorder_test | ||
| ) | ||
|
|
||
| # Test 3: check if the output file is a valid MPEG video file | ||
| add_test( | ||
| NAME gst_video_recorder_valid_mpeg_test | ||
| COMMAND bash -c "ffprobe -v error ${OUTPUT_FILE}" | ||
| ) | ||
|
|
||
| # Make the validation test depend on the file check test | ||
| set_tests_properties(gst_video_recorder_valid_mpeg_test PROPERTIES | ||
| DEPENDS gst_video_recorder_output_file_test | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
applications/gstreamer/gst_video_recorder/python/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, TECNALIA. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Copy gst_video_recorder application file | ||
| add_custom_target(python_gst_video_recorder ALL | ||
| COMMAND ${CMAKE_COMMAND} -E copy | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/gst_video_recorder.py" | ||
| ${CMAKE_CURRENT_BINARY_DIR} | ||
| DEPENDS "gst_video_recorder.py" | ||
| BYPRODUCTS "gst_video_recorder.py" | ||
| ) | ||
|
|
||
| # Add testing | ||
| if(BUILD_TESTING) | ||
| # To get the environment path | ||
| find_package(holoscan 1.0 REQUIRED CONFIG PATHS "/opt/nvidia/holoscan" "/workspace/holoscan-sdk/install") | ||
|
|
||
| set(RECORDING_DIR ${CMAKE_CURRENT_BINARY_DIR}/recording_output) | ||
| file(MAKE_DIRECTORY ${RECORDING_DIR}) | ||
|
|
||
| add_test( | ||
| NAME gst_video_recorder_python_test | ||
| COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/gst_video_recorder.py | ||
| --source pattern | ||
| --count 10 | ||
| -o ${RECORDING_DIR}/python_gst_video_recorder_output.mp4 | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| ) | ||
|
|
||
| set_property( | ||
| TEST gst_video_recorder_python_test | ||
| PROPERTY ENVIRONMENT | ||
| "PYTHONPATH=${GXF_LIB_DIR}/../python/lib:${CMAKE_BINARY_DIR}/python/lib" | ||
| ) | ||
|
|
||
| set_tests_properties(gst_video_recorder_python_test PROPERTIES | ||
| PASS_REGULAR_EXPRESSION "EOS processed, pipeline finished cleanly" | ||
| FAIL_REGULAR_EXPRESSION "[^a-z]Error;ERROR;Failed" | ||
| ) | ||
| endif() | ||
|
|
||
| # Install application into the install/ directory for packaging | ||
| install( | ||
| FILES gst_video_recorder.py | ||
| DESTINATION bin/gst_video_recorder/python | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.