mpv-player / mpv

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

How to loop a video to a specified duration #13368

Closed ZreXoc closed 2 weeks ago

ZreXoc commented 7 months ago

I'm using mpvpaper and some wallpapers download from wallpaper engine. However, some of them are too short (like 15s) and I want to loop them to at least 30min. I can't simply use --loop-file=N (issue 10562) since the length of each video is uncertain.

Is there some way to loop a video to a specified duration, and what about a picture?

(I write a script and it works for video, but I wonder if there is a better way without script :) )

Traneptora commented 7 months ago

Currently there's no way to do this without a lua script. However, if your script works, I don't see an issue.

Do note that the duration field can be iffy as not every file exposes it. You can work around this if it's not present by seeking to the end of the file (such as seeking to 9999:99:99) and then getting the property playback-time.