CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 03:47:30 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/opencv/opencv.git
etag: W/"af6df2bc4a91100633e522963a8e3bd0"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=M%2BmiB%2ByQaU1ovbf%2FS21VppRwYFPb8a4SugY4YFUcTOjW4GWXTSzSvbvwFNegaIfKpPGWPVAYAOjPkz3azmgV4VPStYvxXc6tjXlAez2YNNk4kIIdsTphq5dgzeKjI3Cxk4Wx9nLlBStbG6BUu0lf6oP02iKLk04vAvmYs9UbJtvi6u6E6DZhJ0mbCh4NNH7Dtuk44WzBbrTyGmjggoBvOvA7%2B0kiM9a%2BogkZjJhCGkeCP0MgghyyzVEZgnnBXXd6SVtEKG7pryAI83ws8Nd2wQ%3D%3D--2%2FKqomfAMJBKgI7G--aj7vuTP1S6rciQNlrwbXXA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.59374709.1753588049; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 03:47:29 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 03:47:29 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 8CCC:3240E6:A5D1ED:DD2C65:6885A151
Merge pull request #27153 from 03kiko:fix-videowriter-writing-colorle… · opencv/opencv@62b3649 · GitHub
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_ffmpeg.cpp
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_ffmpeg_impl.hpp
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_gstreamer.cpp
Copy file name to clipboardExpand all lines: modules/videoio/test/test_ffmpeg.cpp
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Commit 62b3649
authored
Merge pull request #27153 from 03kiko:fix-videowriter-writing-colorless-images-26276
fix #26276: cv::VideoWriter fails writing colorless images #27153
When writing grayscale images (`isColor=false`), `cv::VideoWriter` failed as FFmpeg backend requires input frames to be in a grayscale format. Unlike other backends, FFmpeg doesn't perform this conversion internally and expects the input to be pre-converted. To fix this, I inserted a check in the `CvVideoWriter_FFMPEG_proxy::write` to convert input frames to grayscale when the input has more than 1 channel. If this is true, then the input is converted to a gray image using `cv::cvtColor` (with `cv::COLOR_BGR2GRAY`).
Additionally, as suggested in the issue comments, I have correctly propagated the return value of `CvVideoWriter_FFMPEG::writeFrame` back to the `CvVideoWriter_FFMPEG_proxy::write`. This return value wasn't being used, and `writeFrame` was always returning false since the FFmeg's return code `AVERROR(EAGAIN)` was mistakenly being treated as an error. Now it's handled as a signal for additional input (current input was successfully written, and a new frame should be sent. [See FFmpeg documentation for `avcodec_receive_packet`](https://ffmpeg.org/doxygen/6.1/group__lavc__decoding.html)). A warning is displayed if `CvVideoWriter_FFMPEG::writeFrame` returns false. Alternatively, this could be propagated back up to the user, making cv::VideoWriter::write a boolean.
Finally, I added a test case to verify if the grayscale conversion is being done correctly.
Fixes #26276
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake1 parent d6864cd commit 62b3649Copy full SHA for 62b3649
File tree
Expand file treeCollapse file tree
4 files changed
+86
-4
lines changedFilter options
- modules/videoio
- src
- test
Expand file treeCollapse file tree
4 files changed
+86
-4
lines changedmodules/videoio/src/cap_ffmpeg.cpp
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_ffmpeg.cpp+2-1Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
194 | 194 |
| |
195 | 195 |
| |
196 | 196 |
| |
197 |
| - | |
| 197 | + | |
| 198 | + | |
198 | 199 |
| |
199 | 200 |
| |
200 | 201 |
| |
|
modules/videoio/src/cap_ffmpeg_impl.hpp
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_ffmpeg_impl.hpp+6-2Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2525 | 2525 |
| |
2526 | 2526 |
| |
2527 | 2527 |
| |
| 2528 | + | |
2528 | 2529 |
| |
2529 | 2530 |
| |
2530 | 2531 |
| |
2531 | 2532 |
| |
2532 | 2533 |
| |
| 2534 | + | |
2533 | 2535 |
| |
2534 | 2536 |
| |
2535 | 2537 |
| |
| |||
2640 | 2642 |
| |
2641 | 2643 |
| |
2642 | 2644 |
| |
2643 |
| - | |
| 2645 | + | |
| 2646 | + | |
2644 | 2647 |
| |
2645 | 2648 |
| |
2646 | 2649 |
| |
2647 | 2650 |
| |
2648 | 2651 |
| |
2649 | 2652 |
| |
2650 |
| - | |
| 2653 | + | |
| 2654 | + | |
2651 | 2655 |
| |
2652 | 2656 |
| |
2653 | 2657 |
| |
|
modules/videoio/src/cap_gstreamer.cpp
Copy file name to clipboardExpand all lines: modules/videoio/src/cap_gstreamer.cpp+1-1Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2699 | 2699 |
| |
2700 | 2700 |
| |
2701 | 2701 |
| |
2702 |
| - | |
| 2702 | + | |
2703 | 2703 |
| |
2704 | 2704 |
| |
2705 | 2705 |
| |
|
modules/videoio/test/test_ffmpeg.cpp
Copy file name to clipboardExpand all lines: modules/videoio/test/test_ffmpeg.cpp+77Lines changed: 77 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
953 | 953 |
| |
954 | 954 |
| |
955 | 955 |
| |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
956 | 1033 |
|
You can’t perform that action at this time.
0 commit comments