You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to write a video after applying some mediapipe operations.
The video with (size: 1080 x 1920, codec: MPEG-4 AAC, Timed Metadata, HEVC) is able to be written by the cv.VideoWriter class, but for some reason a video with (size: 720 x 1080, codec: Timed Metadata, H.264, MPEG-4 AAC) is not being written. I assumed it was due to the H.264 codec. But, I'm not sure how to fix it at the moment. Apologies, if this is an easy fix!
For additional info, the larger video was recorded from a video and the smaller video was downloaded from facebook messenger, which is why i assume they have different codec formats.
Actual behaviour
Both video formats should be able to be written using cv.VideoWriter class.
Also, i have tried saving the video without any of the mediapipe operations. The behaviour is the same. When I view the frames with cv.imshow(), the frames are flipped for the 1080 x 1980 as well.
Steps to reproduce
example code
# OpenCV Capture
cap = cv.VideoCapture(args.input if args.input else 0)
# Create a VideoWriter object so we can save the video output
fourcc = cv.VideoWriter_fourcc(*'mp4v')
output_frames_per_second = 30.0
out = cv.VideoWriter(os.path.join(OUTPUT_DIR, args.output_filename),
fourcc,
output_frames_per_second,
(args.width, args.height))
while cap.isOpened():
hasFrame, frame = cap.read()
print(hasFrame)
if not hasFrame:
# cv.waitKey()
break
# Flip image vertically if model type is mediatype
if args.model_type == 'mediapipe':
frame = cv.flip(frame, -1)
# Get Pose Joints
points = pose.returnPoints(frame)
# Draw Pose Joints on frame
pose.drawJoints(frame, points)
# Display Frame
# cv.imshow('OpenPose using OpenCV', frame)
# Write the frame to the output video file
out.write(frame)
if args.model_type == 'media':
pose.close()
# Stop when the video is finished
cap.release()
# Release the video recording
out.release()
operating system
mac os Ventura
architecture (e.g. x86)
ARM (silicon)
opencv-python version
opencv-contrib-python==4.6.0.66
opencv-python==4.5.5.64
The text was updated successfully, but these errors were encountered:
hkair
changed the title
Video not saving for different formats and dimension
Video not saving for different codec formats and dimension
Dec 16, 2022
cv::VideoWriter capabilities depend on back-end. Could you share cv.getBuildInformation() output and try to run the app with OPENCV_VIDEOIO_DEBUG=1 set in environment. Both logs allows to understand which backend is used.
the frames are flipped for the 1080 x 1980 as well.
Expected behaviour
I am currently trying to write a video after applying some mediapipe operations.
The video with (size: 1080 x 1920, codec: MPEG-4 AAC, Timed Metadata, HEVC) is able to be written by the cv.VideoWriter class, but for some reason a video with (size: 720 x 1080, codec: Timed Metadata, H.264, MPEG-4 AAC) is not being written. I assumed it was due to the H.264 codec. But, I'm not sure how to fix it at the moment. Apologies, if this is an easy fix!
For additional info, the larger video was recorded from a video and the smaller video was downloaded from facebook messenger, which is why i assume they have different codec formats.
Actual behaviour
Both video formats should be able to be written using cv.VideoWriter class.
Also, i have tried saving the video without any of the mediapipe operations. The behaviour is the same. When I view the frames with cv.imshow(), the frames are flipped for the 1080 x 1980 as well.
Steps to reproduce
mac os Ventura
ARM (silicon)
opencv-contrib-python==4.6.0.66
opencv-python==4.5.5.64
The text was updated successfully, but these errors were encountered: