Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
video_write_container
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
video_write_container
Commits
3ca3d803
Commit
3ca3d803
authored
Jan 11, 2023
by
sikhin.vc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
a67480a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
app.py
app.py
+64
-0
No files found.
app.py
0 → 100644
View file @
3ca3d803
# Python program to save a
# video using OpenCV
import
cv2
import
os
# Create an object to read
# from camera
video
=
cv2
.
VideoCapture
(
os
.
environ
[
'RTSP_URL'
])
# We need to check if camera
# is opened previously or not
if
(
video
.
isOpened
()
==
False
):
print
(
"Error reading video file"
)
# We need to set resolutions.
# so, convert them from float to integer.
frame_width
=
int
(
video
.
get
(
3
))
frame_height
=
int
(
video
.
get
(
4
))
size
=
(
frame_width
,
frame_height
)
# Below VideoWriter object will create
# a frame of above defined The output
# is stored in 'filename.avi' file.
file_name
=
os
.
path
.
join
(
os
.
getcwd
()
,
os
.
environ
[
"FILE_NAME"
]
+
".avi"
)
result
=
cv2
.
VideoWriter
(
file_name
,
cv2
.
VideoWriter_fourcc
(
*
'MJPG'
),
10
,
size
)
while
(
True
):
ret
,
frame
=
video
.
read
()
if
ret
==
True
:
# Write the frame into the
# file 'filename.avi'
print
(
type
(
result
))
result
.
write
(
frame
)
# Display the frame
# saved in the file
# cv2.imshow('Frame', frame)
# Press S on keyboard
# to stop the process
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
's'
):
break
# Break the loop
else
:
break
# When everything done, release
# the video capture and video
# write objects
video
.
release
()
# result.release()
# Closes all the frames
cv2
.
destroyAllWindows
()
print
(
"The video was successfully saved"
)
\ No newline at end of file
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