NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.31k stars 13.54k forks source link

mpv: cannot take screenshots in AVIF, JXL or WebP #330125

Open KucharczykL opened 1 month ago

KucharczykL commented 1 month ago

Describe the bug

A clear and concise description of what the bug is.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Set screenshot-format to avif, jxl or webp
  2. Press "s", "S", or "Ctrl+s"
  3. See error

Expected behavior

Taking screenshots in these formats works.

Screenshots

If applicable, add screenshots to help explain your problem.

mpv --screenshot-avif-encoder=dav1d ~/Downloads/How\ to\ Start\ Adding\ Modularity\ to\ your\ NixOS\ Config\ \[bV3hfalcSKs\].mp4
 (+) Video --vid=1 (*) (vp9 1920x1080 60.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 44100Hz)
Using hardware decoding (nvdec).
AO: [pipewire] 192000Hz stereo 2ch double
VO: [gpu-next] 1920x1080 cuda[nv12]
[screenshot] Could not open libavcodec encoder for saving images
[screenshot] Error writing file '/home/lukas/Pictures/Screenshots/mpv/How to Start Adding Modularity to your NixOS Config [bV3hfalcSKs].mp4_2024-07-26-11-04-40_00:00:00.883.jxl'!
Error writing screenshot!
[screenshot] Could not find encoder 'libaom-av1', for saving images
[screenshot] Error writing file '/home/lukas/Pictures/Screenshots/mpv/How to Start Adding Modularity to your NixOS Config [bV3hfalcSKs].mp4_2024-07-26-11-21-42_00:00:01.867.avif'!
Error writing screenshot!
[screenshot] Could not open libavcodec encoder for saving images
[screenshot] Error writing file '/home/lukas/Pictures/Screenshots/mpv/How to Start Adding Modularity to your NixOS Config [bV3hfalcSKs].mp4_2024-07-26-11-22-33_00:00:00.950.webp'!
Error writing screenshot!

my mpv config

screenshot-format = "jxl";
screenshot-avif-pixfmt = "yuv420p10le";
# screenshot_$FILENAME_$YEAR-$MONTH-$DAY-$HOURS-$MINUTES-$SECONDS_$PLAYBACKTIME_INCL_MILLISECONDS;
screenshot-template = "%f_%tY-%tm-%td-%tH-%tM-%tS_%P";
screenshot-dir = "~/Pictures/Screenshots/mpv";
screenshot-tag-colorspace = "no";
screenshot-high-bit-depth = "yes";
autofit = "50%";
audio-channels = "stereo";
audio-normalize-downmix = "yes";
vo = "gpu-next";
hwdec = "auto";
#tone-mapping=clip;
af = "lavfi=[loudnorm=I=-16]";
screenshot-sw = "yes";

Additional context

I've using different decoders for avif but none of them work. Setting screenshot-avif-encoder to libsvtav1 takes the screenshot without error but the file is corrupted and cannot be opened.

Notify maintainers

@AndersonTorres @fpletz @globin @Ma27

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

> nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.41, NixOS, 24.05 (Uakari), 24.05.20240724.d0907b7`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"home-manager-24.05.tar.gz, nixos-24.05"`
 - nixpkgs: `/nix/store/svas0rbjm1vfiqhls8rmzcygwiwvcj32-source`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 1 month ago

330056 might solve your webp woes

but if you want jxl you'll probably need to override mpv to use ffmpeg-full

KucharczykL commented 1 month ago

330056 might solve your webp woes but if you want jxl you'll probably need to override mpv to use ffmpeg-full

Thanks, I didn't know about that solution. I don't mind at all using ffmpeg-full and testing it just now, all the screenshot formats work, including JXL, AVIF, and WebP.

Reading through the topic you linked made me wonder: why is size considered so important? Shouldn't the program working without throwing errors be more important?

KucharczykL commented 1 month ago

As for this topic, feel free to close it if you think there's nothing to be done here :slightly_smiling_face: