mpv-player / mpv-build

🔨 Helper scripts to compile mpv on Linux
http://mpv.io
408 stars 107 forks source link

Builds succesfully but image output generation doesn't seem to work #161

Closed karkirowle closed 3 years ago

karkirowle commented 3 years ago

After some tedious attempts, I built my own mpv version from source. It's not clear to me what are the list of dependencies that are needed for building so I went on a trial-and-error attempt based on the README.

This is the version info, see below:

mpv 0.33.1 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
 built on Mon Jul 12 13:30:11 CEST 2021
FFmpeg library versions:
   libavutil       57.0.100
   libavcodec      59.3.101
   libavformat     59.4.100
   libswscale      6.0.100
   libavfilter     8.0.103
   libswresample   4.0.100
FFmpeg version: N-102963-ga948e47960

When I attempt to run

mpv my_favourite_video.mp4 --loop-file=no --frames=1 -o='test_image.jpg'

I obtain the output

Cannot find main.* for any supported scripting backend in: /home/boomkin/.config/mpv/scripts/mpvacious
Disabling audio (not supported by target format).
 (+) Video --vid=1 (*) (h264 1280x720 23.976fps)
     Audio --aid=1 --alang=jpn (*) (aac 2ch 48000Hz)
     Audio --aid=2 --alang=jpn (*) (aac 2ch 48000Hz)
VO: [lavc] 1280x720 yuv420p
[vo/lavc] Opening encoder: MJPEG (Motion JPEG) [mjpeg]
[ffmpeg] mjpeg: Non full-range YUV is non-standard, set strict_std_compliance to at most unofficial to use it.
[vo/lavc] Could not initialize encoder.
Could not initialize video chain.
Video: no video

[encode] no data written to target file
Exiting... (Interrupted by error)

I guess it is some dependency that's missing, or a wrong FFmpeg version is built, Is there any way I could figure out what else I need to install to make this command work?

sfan5 commented 3 years ago

Your mpv is fine you're just hitting a quirk with how JPEG is encoded. The following works: mpv video.mp4 --frames=1 -vf scale=out_range=pc -o test_image.jpg

If you want to extract multiple frames (and not MJPEG) also consider vo-image.

karkirowle commented 3 years ago

Thanks, this solves my issues!

There was one minor hiccup that I discovered during the debugging process, which will be a relatively obscure case for most users. Namely, that the combination of libass commit hash 9a2b38e8f5957418362e86b525f72794565deed and Lua didn't work for me.

However, this is solved by simply changing to the last hash of libass (as of 12th of July 2021).