Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] video/image_writer: add bgra screenshot support #12149

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4332,6 +4332,7 @@ Screenshot
:webp: WebP
:jxl: JPEG XL
:avif: AVIF
:bgra: BGRA

``--screenshot-tag-colorspace=<yes|no>``
Tag screenshots with the appropriate colorspace (default: yes).
Expand Down
2 changes: 2 additions & 0 deletions DOCS/man/vo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ Available video output drivers are:
PNG files.
webp
WebP files.
bgra
BGRA files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like

Suggested change
BGRA files.
Raw BGRA (32bpp) pixel data without header or padding.

would be more descriptive


``--vo-image-png-compression=<0-9>``
PNG compression factor (speed vs. file size tradeoff) (default: 7)
Expand Down
4 changes: 4 additions & 0 deletions video/image_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const struct m_opt_choice_alternatives mp_image_writer_formats[] = {
{"jpeg", AV_CODEC_ID_MJPEG},
{"png", AV_CODEC_ID_PNG},
{"webp", AV_CODEC_ID_WEBP},
{"bgra", AV_CODEC_ID_RAWVIDEO},
#if HAVE_JPEGXL
{"jxl", AV_CODEC_ID_JPEGXL},
#endif
Expand Down Expand Up @@ -706,6 +707,9 @@ bool write_image(struct mp_image *image, const struct image_writer_opts *opts,
int alpha = image->fmt.flags & MP_IMGFLAG_ALPHA;
destfmt = alpha ? pixfmt2imgfmt(AV_PIX_FMT_YUVA420P) : IMGFMT_420P;
}
if (opts->format == AV_CODEC_ID_RAWVIDEO) {
destfmt = IMGFMT_BGRA;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're better off writing a new function that dumps the mp_image contents than trying to reuse write_lavc


if (!destfmt)
destfmt = get_target_format(&ctx);
Expand Down