mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.14k stars 2.89k forks source link

--video-pan and --video-align not working properly #7675

Open fitipe opened 4 years ago

fitipe commented 4 years ago

Important Information

Provide following Information:

0.32.0

10.13.6 (although I also noticed this issue on a Debian Linux)

https://vimeo.com/414270181

If you're not using git master or the latest release, update. Releases are listed here: https://github.com/mpv-player/mpv/releases

Reproduction steps

In order to play multiple image files in sequence, each one with a different crop and duration, I'm combining zoom and video-pan options separated by the per-file markers as shown in the following code line:

mpv --fs --no-border --{ --video-zoom=1.85 --video-pan-y=0.02 --video-pan-x=0.14 --image-display-duration=6.21 41.jpg --} --{ --video-zoom=2.63 --video-pan-y=-0.01 --video-pan-x=-0.25 --image-display-duration=7.18 44.jpg --} --{ --video-zoom=1.41 --video-pan-y=-0.02 --video-pan-x=-0.08 --image-display-duration=5.56 60.jpg --} --{ --video-zoom=0.59 --video-pan-y=0.01 --video-pan-x=-0.03 --image-display-duration=2.46 13.jpg --} --{ --video-zoom=1.87 --video-pan-y=-0.04 --video-pan-x=0.01 --image-display-duration=2.36 76.jpg --}

I've also made attempts with "--video-align-y" and "--video-align-x", but it behaves in the same way.

The same code with videos (.mov) instead of images (.jpg) also doesn't work as expected.

Expected behavior

I expect each image (or video) to be played in a specific crop (zoom + video-pan or video-align) during all the time specified by the --image-duration or --length option.

Actual behavior

As shown in the vimeo link posted above: each file is been played in the specified crop, but before changing to the next one, it makes a quick new crop: A new crop of the actual image is flashed right before changing to the next file. It happens in about 90% of the times and I couldn't figure out the causes.

Log file

https://0x0.st/i2A-.txt

Sample files

Sample files needed to reproduce this issue can be uploaded to https://0x0.st/ or similar sites. (Only needed if the issue cannot be reproduced without it.) Do not use garbage like "cloud storage", especially not Google Drive.

ghost commented 4 years ago

That's simply not possible without significant further work. Applying per-file options, going to the next file, and showing the new frame are all not atomic. In theory you could probably achieve something similar with video filters.

fitipe commented 4 years ago

Thanks for the quick reply, @wm4

I got that it's not possible, but couldn't figure out exactly why: mpv sort of has to rearrange the frame every time it connects a file to another using per-file options?

Are there video filters I could use to crop the image in file separated by per-file options?

Cheers!

fitipe commented 4 years ago

update

In order to check if it's related to the per-file options, I've made a test using sockets launching mpv this way: mpv --image-display-duration=100 9.jpg --input-ipc-server=/tmp/mpvsocket

Then, created a python file that keeps sending, at the same time, these three messages to the shell, changing the values randomly:

echo '{ "command": ["set_property", "video-zoom", 0.726083108818561 ] }' | sudo socat - /tmp/mpvsocket

echo '{ "command": ["set_property", "video-pan-x", "-0.06657309423140914" ] }' | sudo socat - /tmp/mpvsocket

echo '{ "command": ["set_property", "video-pan-y", "0.010658178178249206" ] }' | sudo socat - /tmp/mpvsocket

The problem persists. Every time mpv receives the json messages, there is a quick flash of another crop (randomly coming from who knows where), in between each trio of values.

So, I assume it's not related to the per-file options.

I've searched for a way of achieving the same crop-changing effects with video filters, as kindly suggested by our fellow above, but couldn't find out any on mpvs references :/

Someone has any further ideas?

Thanks!

ghost commented 4 years ago

The ffmpeg crop video filter can be used in mpv.

Regarding your recent example, maybe it could be made possible to apply multiple options at once (at least if they're closely related like the pan options), and/or provide a single option that does the entire crop (so you wouldn't have the problem in the first place). But that doesn't change that you might see a "flash" when changing files and using file local options.

fitipe commented 4 years ago

update

Thanks again, @wm4.

I found ffmpegs crop filter documentation and spent this day learning its usage. It worked way better! But not 100% ... let's say the zoom+pan method would give these "flashes" in 90% of the changing file moments and the crop filter does it in 30%.

That made me assume that the "problem" is not related to either of the functions, but to something deeper on mpv. Any ideas? Maybe thats what you meant by the entire process been "not atomic"?

Anyways, the 30% of "flashes" given by the filter method is ok for my project. It replaces the pan or align functions, but still doesn't let me vary between different "zooms". I've tried to combine ffmpegs crop filter with mpvs zoom option, but the "flashes" frequency returns 90%.

I also tried to apply zoom and/or zoompan ffmpeg filters to mpvs --vf option, but mpv seams to not recognize them. Do someone knows a trick about it?

berkley4 commented 4 years ago

Lots of filters, durations and inputs makes me think that you'd be better off using a lool like vapoursynth to produce a video, rather than trying to do everything 'on the fly' with mpv.

It might be possible to use pipes or something to feed the output into mpv, similar to how I often use mpv to play the result of a vapoursynth job soon after starting it (ie before it's finished).

Off the top of my head, ffmpeg filters need syntaxt similar to --vf=lavfi=[....]

ghost commented 4 years ago

Using video filters as file local options should not affect the image from a previous file. You're using vo_libmpv; not exactly sure how this might be affected, but I can't think of a problem.

@berkley4 using --vf=lavfi=[...] uses exactly the same syntax as ffmpeg within the ..., --vf=... also works, but merely uses "similar" syntax and prefers mpv builtin filters over lavfi.

fitipe commented 4 years ago

Hi there. Sorry for taking so long to reply - I ran out of internet during last week.

@berkley4 it's the first time I get in touch with vapoursynth. I'll check that out! Would you tell me what exactly is a "lool"?

@wm4 I've tried the filter method using --vo=gpu and it did the job! Mpv spawns a yellow message "[vo/gpu] opengl cocoa backend is deprecated, use vo=libmpv instead" but it seams to not affect anything.

I still haven't got any success on searching for ffmpegs zoom filters. Maybe there is nom?

Thanks a lot for both contributions!