Fix(examples): Ensure correct video resolution in record-video.py#245
Open
Optimized-Brain wants to merge 1 commit intodamiafuentes:masterfrom
Open
Fix(examples): Ensure correct video resolution in record-video.py#245Optimized-Brain wants to merge 1 commit intodamiafuentes:masterfrom
Optimized-Brain wants to merge 1 commit intodamiafuentes:masterfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses issue #232
Problem:
On certain operating systems, particularly Windows, the record-video.py example script fails to save the video correctly. This is due to a race condition where the
videoRecorderthread initialises thecv2.VideoWriteruses the dimensions of an initial, low-resolution placeholder frame (400x300) before the actual video stream from the drone has started.When the high-resolution frames (e.g., 960x720) arrive,
cv2.VideoWriterfails to write them because their dimensions do not match the dimensions it was configured with, preventing the video from being saved.Solution:
This pull request resolves the race condition by explicitly waiting for the first real video frame to be received from the drone before initialising the
cv2.VideoWriter.A while loop has been added to pause the script until the frame's shape no longer matches the placeholder dimensions. This guarantees that the
VideoWriteris always created with the correct, final resolution of the video stream, making the example script robust and reliable across all platforms.