Skip to content

Android H264 / H265 Encoding Bug #23570

@physxP

Description

@physxP

System Information

NDK: 21.4.7075529
SDK: 30.0.3
Android OS: 12
OpenCV: 4.7 (from github releases)
Mobile Device: Pixel 4a 5g

Detailed description

When the input stream's height is greater than width i.e. in portrait mode then there are weird artifacts in the video. As shown in screenshot below. It is a video of a single person from front camera:
Screenshot 2023-05-02 at 2 15 44 PM
However, if I use landscape mode then the video comes out fine.
The feature of h264/h265 encoding is related to #22490 and was added in following merge request: #22503

Steps to reproduce

// four_cc_ is 'H264' or 'H265', frame_rate is 30, output file path is video.mp4 inside application directory
auto writer = cv::VideoWriter(output_file_path_, four_cc_, frame_rate, cv::Size(width, height));
// loop to fetch frame
while ( .... ){
  // other code
 // frame is BGR, tested it is correct by writing it as png image
  writer.write(frame);
}
writer.release();

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions