News for hackers. Stuff that matters.
Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @12:22PM (#32140083)
My favorite feature is "video-sync=display-resample". This gives you perfect frame pacing by synchronizing the video to vertical refresh and resampling the audio to match. If you set your refresh rate to an integer multiple of the frame rate, every frame will be shown for the exact same time. The audio resampling compensates for very small discrepancies between speeds by imperceptibly changing the audio speed. It's similar to the proprietary DirectShow filter "ReClock", but AFAIK ReClock does not dynamically adjust the speed to compensate for clock drift like MPV does, in which case you could theoretically still get imperfect frame pacing. (I haven't actually used ReClock so I could be mistaken here.)

Also great is MPV's support for arbitrary OpenGL shaders. This can include very complicated shaders, e.g. real-time neural network upscaling:

https://github.com/igv/FSRCNN-TensorFlow/releases

SD video can look surprisingly good after upscaling with this.

Re:Mpv – A free, open source, and cross-platform media player by nyanpasu64 on Monday July 18, 2022 @01:56PM (#32141177)
One of my least favorite features of VLC (tied with network stream interruptions killing the playback rather than reconnecting) is that VLC guesses your audio hardware's sampling rate itself (rather than using the hardware's self-reported rate), and resamples even audio-only files that match your hardware's self-reported rate. And every time you seek in a file, VLC's guess of the hardware sampling rate is thrown off, causing VLC to start pitch-shifting the sound just enough (usually just barely, but sometimes up to 1 semitone) for you to notice and start doubting your sanity, if the audio pitch actually changed or if you're hallucinating things. There's a long-running bug report at https://code.videolan.org/videolan/vlc/-/issues/14287.

I think PipeWire does something similar to synchronize multiple audio devices without a shared word clock, but I haven't tested how much its rate analyzer drifts when starting/stopping playback or in steady state.

Re:Mpv – A free, open source, and cross-platform media player by n4bz0r on Monday July 18, 2022 @08:42PM (#32146023)
> tied with network stream interruptions killing the playback rather than reconnecting

So I'm not alone in hating this! How come this was never fixed?

I didn't want to switch from MX Player (Android), which worked quite well, for ages, but finally gave up because with MX Player you have to go look for some codecs.zip every (major?) update. (must be related to the licenses)

On top of VLC not being able to reconnect to the source, it also doesn't show the title of the video. So every time the stream dies I have to remember which episode I was on.

Re:Mpv – A free, open source, and cross-platform media player by vjerancrnjak on Monday July 18, 2022 @03:49PM (#32142747)
Exactly the same thing happens with mpv if you shift the audio manually. I experienced that recently. After shifting, whenever I go forward or backward it gets out of sync + the performance decreases ( without the shift going forward or backwards is instant)
Re:Mpv – A free, open source, and cross-platform media player by 867-5309 on Monday July 18, 2022 @04:28PM (#32143233)
I have experienced this with IPTV on Kodi, but I've only ever noticed it on the BBC News countdown tune, sining a semitone up and down. AFAIK that's using ffmpeg
Re:Mpv – A free, open source, and cross-platform media player by capableweb on Monday July 18, 2022 @12:59PM (#32140513)
> Also great is MPV's support for arbitrary OpenGL shaders. This can include very complicated shaders, e.g. real-time neural network upscaling:

Holy shit, I had no idea about this (that mpv could load OpenGL shaders nor that there is shaders that do RT neural upscaling), literally blowing my mind.

Re:Mpv – A free, open source, and cross-platform media player by leeoniya on Monday July 18, 2022 @01:18PM (#32140747)
Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @02:32PM (#32141675)
For line art, try "FSRCNNX_x2_16-0-4-1_anime_enhance.glsl": https://github.com/HelpSeeker/FSRCNN-TensorFlow/releases/tag...

Or if you don't want noise reduction, try "FSRCNNX_x2_8-0-4-1_LineArt.glsl": https://github.com/igv/FSRCNN-TensorFlow/releases (in checkpoints_params.7z)

Both are IMO sharper and more accurate than ACNet.

Re:Mpv – A free, open source, and cross-platform media player by neurostimulant on Monday July 18, 2022 @01:39PM (#32140962)
Wow this one produces even sharper images. Thanks!
Re:Mpv – A free, open source, and cross-platform media player by KennyBlanken on Monday July 18, 2022 @02:49PM (#32141916)
The display sync resampling is amazing.

When I first experienced it, it made me realize how terrible VLC is; VLC can't play back video at a consistent framerate, and this is particularly noticeable in panning scenes in videos, especially anime.

People talk about VLC like it's a poster-child of open source, but really, I just see a bloated, crash-prone program that doesn't even do its primary function particularly well or efficiently.

Re:Mpv – A free, open source, and cross-platform media player by jchw on Monday July 18, 2022 @04:17PM (#32143098)
VideoLAN is responsible for a whole lot of open source code that benefits the entire video ecosystem, like x264/x265/dav1d. Even if you dislike VLC, I think this is underselling their contributions to the world.

Also, I find VLC is a safe recommendation for someone who just wants to casually play some video files. It's fairly user friendly, it runs on literally everything, and it supports most multimedia formats anyone could ever care about. I like and use MPV, but I use VLC on some Android TV devices because it's readily available and runs buttery smooth on crappy hardware.

Re:Mpv – A free, open source, and cross-platform media player by ogurechny on Monday July 18, 2022 @08:03PM (#32145770)
This is probably a interference of a chosen output method and a system compositor behavior (or its recent changes). Compositor redirection broke synchronization for most old code, and available interoperation and bypass methods have been changing with time. This was the reason media players and games introduced new fullscreen modes. Players, including VLC, have been capable of stutter-less video output for decades, the problem is that there is usually more to show on screen than just the video, and the user wants other things to happen in parallel.

It's true that VLC requires arcane knowledge of its architecture to configure all of its options, but basic operation still assumes you've read the fine manual.

Re:Mpv – A free, open source, and cross-platform media player by astrange on Monday July 18, 2022 @03:19PM (#32142315)
Computer monitors (60fps) can’t play anime at a constant framerate (24fps). Computer monitors aren’t TVs.
Re:Mpv – A free, open source, and cross-platform media player by KennyBlanken on Monday July 18, 2022 @03:53PM (#32142798)
Computer monitors are not all 60hz, and I cited anime as one example; TV and movies also have jerky playback.

VLC does the behavior described (jerky playback) on both a Mac with 60hz display that is several years old, and on a cutting edge PC that has a refresh rate more than five times the framerate of anime and supports variable refresh rate.

mpv plays anime butter-smooth on both systems.

I love it when I get a supremely condescending explanation that is also wrong.

Re:Mpv – A free, open source, and cross-platform media player by astrange on Monday July 18, 2022 @05:10PM (#32143766)
> Computer monitors are not all 60hz, and I cited anime as one example; TV and movies also have jerky playback.

The ones that are 60hz are 60hz, and that's not the reason monitors aren't TVs. They aren't TVs because they don't have one of 1. black frame insertion 2. 60->120fps motion interpolation, so you have persistence of vision issues. (aka motion blur, jerkiness, or both at once)

Movies are also 24fps, though of course they're different from animation because they have built in motion blur (same as if you recorded with 1/24 exposure time vs 1/1000).

mpv's video retiming works some of the time, but means it changes the pitch of audio which is sometimes unacceptable, same as old NTSC->PAL transfers.

…if your monitor has variable refresh rate why are you using retiming?

Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @05:20PM (#32143914)
>They aren't TVs because they don't have one of 1. black frame insertion 2. 60->120fps motion interpolation

Most older LCD TVs do not have either black frame insertion or motion interpolation. BFI causes motion artifacts (trailing ghost images) if the frame rate of the video is less than the refresh rate. Motion interpolation also adds its own artifacts.

>mpv's video retiming works some of the time, but means it changes the pitch of audio

The best way to use it is to set custom monitor timings (e.g. with xrandr) so that the adjustment needed is too small to detect. There are various scripts to automate this, although I haven't personally tried any (I just change mode manually).

>if your monitor has variable refresh rate why are you using retiming?

I have a VRR monitor, but I still use retiming because it only has a 6 bit panel, and VRR makes temporal dithering artifacts ("frame rate control") visible.

Re:Mpv – A free, open source, and cross-platform media player by astrange on Tuesday July 19, 2022 @07:11AM (#32149958)
Yeah, those LCD panels aren't actually good enough to be TVs. A lot of them were 60hz as well, or at best 120hz with HDMI 2.0 which didn't support VRR so your playback device probably wouldn't send them 24fps.
Re:Mpv – A free, open source, and cross-platform media player by neurostimulant on Monday July 18, 2022 @01:25PM (#32140807)
Amazing! I tried it with a 360p video and scaling the player window to 1080p and it's looking sharp. The original looks blurry when you scale the window to 1080p.
Re:Mpv – A free, open source, and cross-platform media player by wodenokoto on Monday July 18, 2022 @04:34PM (#32143293)
> My favorite feature is "video-sync=display-resample". This gives you perfect frame pacing by synchronizing the video to vertical refresh …

Does that mean video in 23.976 frames per second will be sped up and play at 30?

Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @05:25PM (#32144018)
You can force it to do that if you really want to, but by default it will speed it up to 24.00fps and play it alternating between 2 and 3 screen refreshes for each frame (i.e. 3:2 pulldown without the interlacing).
Re:Mpv – A free, open source, and cross-platform media player by account42 on Tuesday July 19, 2022 @05:56AM (#32149471)
Is there any way to make it work with adaptive refresh to play the video at exactly its native speed and adjust the display refresh rate instead? Or should that just work automatically?
Re:Mpv – A free, open source, and cross-platform media player by mrob on Tuesday July 19, 2022 @12:17PM (#32153918)
VRR support for MPV is disabled by default in /usr/share/drirc.d/00-mesa-defaults.conf. I am not sure why, because it works for me if enabled. Just fullscreen MPV and it will change the display refresh rate. This requires VRR enabled in both Xorg and your monitor's settings. I have not tried this with Wayland.
Re:Mpv – A free, open source, and cross-platform media player by wodenokoto on Tuesday July 19, 2022 @01:45AM (#32147959)
I have no idea why I wrote 30, when I was thinking 24.

Thank you for the answering the question I didn’t manage to pose!

Re:Mpv – A free, open source, and cross-platform media player by FrostKiwi on Monday July 18, 2022 @08:27PM (#32145911)
No, I forget what the exact limit is, but it does change the speed more than ~0.5%. So going from 59.97 to 60 or vice versa, but not 24 to 30 or 50 to 60.

But Yeah, I am in LOVE with this feature, even for 30fps footage on a 60fps screen. The more stable frame times make a huge difference.

Re:Mpv – A free, open source, and cross-platform media player by ac29 on Monday July 18, 2022 @04:45PM (#32143427)
No.
Re:Mpv – A free, open source, and cross-platform media player by matheusmoreira on Monday July 18, 2022 @07:26PM (#32145468)
Does mpv's resampling have anything to do with RetroArch's dynamic rate control? I remember reading something to that effect years ago.

https://github.com/libretro/docs/blob/master/archive/ratecon...

Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @07:38PM (#32145581)
Yes, it's essentially the same thing.
Re:Mpv – A free, open source, and cross-platform media player by shmerl on Tuesday July 19, 2022 @02:15AM (#32148120)
Shouldn't display adaptive sync work better for syncing to video framerate though? Trying to resample the video to display refresh rate instead sounds like a worse approach.
Re:Mpv – A free, open source, and cross-platform media player by mrob on Tuesday July 19, 2022 @12:20PM (#32153959)
If VRR works well with your hardware then it is probably a better option. You can edit /usr/share/drirc.d/00-mesa-defaults.conf to enable VRR with MPV.
Re:Mpv – A free, open source, and cross-platform media player by shmerl on Tuesday July 19, 2022 @06:53PM (#32159029)
Yeah, I noticed that mpv already uses it in the KDE Wayland session somehow, disregarding Mesa settings.

Also, wasn't there some new VESA standard specifically for video (as an addition to regular adaptive sync)?

MediaSync? https://www.adaptivesync.org

Not sure what it's supposed to mean though.

Re:Mpv – A free, open source, and cross-platform media player by cypress66 on Monday July 18, 2022 @09:19PM (#32146303)
I have a freesync 165hz display. What is the best mpv setting? In theory it should be possible to perfectly show video on my monitor without any stretching or pacing problems.
Re:Mpv – A free, open source, and cross-platform media player by UnlockedSecrets on Monday July 18, 2022 @02:09PM (#32141417)
Nice! Is there any similarly good filter out there for frame interpolation? I love smooth videos just havent had the time to look around too much.
Re:Mpv – A free, open source, and cross-platform media player by 5e92cb50239222b on Monday July 18, 2022 @02:26PM (#32141603)
Have you tried the built-in one?

  interpolation
  tscale=oversample
It makes cheap animation (with low 'real' FPS) pretty smooth, and doesn't seem to affect other videos in any noticeable way.
Re:Mpv – A free, open source, and cross-platform media player by UnlockedSecrets on Monday July 18, 2022 @03:25PM (#32142392)
Unfortunately this is not quite the same thing, It just plays around with how the existing frames are displayed instead of generating new ones based on the motion vectors in video files.

It is best described by MPV's documentation at https://github.com/mpv-player/mpv/wiki/Interpolation

Re:Mpv – A free, open source, and cross-platform media player by tricot on Tuesday July 19, 2022 @02:52AM (#32148316)
Re:Mpv – A free, open source, and cross-platform media player by loeg on Monday July 18, 2022 @02:26PM (#32141609)
How much does it have to adjust playback speed to get frames to an even multiple of refresh rate? Like 2%, or 20? This feature isn't for me -- I'm a big fan of the +/- 10% playback speed '['/']' buttons -- but it sounds neat.
Re:Mpv – A free, open source, and cross-platform media player by mrob on Monday July 18, 2022 @02:36PM (#32141732)
By default, it only makes very small changes. See the "video-sync-max-video-change" setting.
Re:Mpv – A free, open source, and cross-platform media player by zbuf on Monday July 18, 2022 @05:29PM (#32144075)
Agree here. mpv plays for hours without a single frame upset.

The final icing on the cake is I use a small LUA hook to set the refresh rate of the projector to match the source material.

Re:Mpv – A free, open source, and cross-platform media player by willis936 on Monday July 18, 2022 @05:20PM (#32143922)
In my experience with Reclock's interface: it does track CPU clock drift.