UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Playback rates higher than 400%

Open bloomav opened this issue 1 year ago • 7 comments

It would be nice to have the ability to adjust the playback float to a value greater than 4.

I can play videos encoded with the HAP codec smoothly at up to 1200% of the original speed on other software on the same computer.

Thanks for making a plugin that works so well at 400% anyway!

bloomav avatar Feb 21 '24 10:02 bloomav

Increasing playback rate usually places more demand on the video decoder and also on the disk/network source, so these limit how high you can set the playback rate. Obviously running Unity itself will have increased overheads as well.

What platform are you using? What have you been using to play the videos faster?

Chris-RH avatar Feb 21 '24 10:02 Chris-RH

OK, I have built this PC for this purpose with a RAID drive and decent GPU. I seem to be able to run the same clips at 1000% of the original speed on Resolume without any issues.

I've also use similar videos with VDMX on a Mac rig with similar specs and I was running playback rates this high without an issue.

bloomav avatar Feb 21 '24 10:02 bloomav

You can set the playback rate to values higher than 4x by calling mediaPlayer.Control.SetPlaybackRate. It's set to a maximum of 4 in the editor as we need a reasonable max value to make the slider useful. Simply do the following to playback a video at 30x speed:

	IEnumerator Start()
	{
		MediaPlayer mediaPlayer = null;
		if (!TryGetComponent<MediaPlayer>(out mediaPlayer))
		{
			yield return null;
		}

		// Wait for end of frame to make sure the media player has been initialised
		yield return new WaitForEndOfFrame();

		mediaPlayer.Control.SetPlaybackRate(30.0f);
	}

MorrisRH avatar Feb 27 '24 13:02 MorrisRH

Thanks for taking the time to post that. Unfortunately, that doesn't seem to work for me and I have already tried something similar via VS as it still seems to be capped at 400%.

I can confirm the correct float (30 in your example) is displayed in the Media Player component while I'm running in editor view and I've also tried changing the range in the Media Player script but that didn't help either.

bloomav avatar Feb 27 '24 21:02 bloomav

I can confirm it works and at a much higher frame rate on MacOS when using OpenCore on the same system. Could it be related to the APFS filesystem?

bloomav avatar Mar 22 '24 11:03 bloomav

No idea why using OpenCore would make a difference. Would be interesting to know the spec of the machine you're using and the kind of HAP file you're playing (codec, resolution, frame rate, etc.).

MorrisRH avatar Mar 22 '24 17:03 MorrisRH

I'm not sure either but here are my relevant specs in case it helps and please let me know if you want more details:

Gigabyte X299X MB 10980XE CPU 64GB RAM AMD Radeon VII GPU 960 PRO SSD (MacOS) 4 X 970 EVO Plus SSD RAID (Media)

The videos I'm using are encoded in HAP A at 3840 X 2160 with 120fps and it looks like the exact same project in MacOS is handling 3 of them playing at the same time with at least 10x the playback and the build is running at around twice the frame rate compared to Windows.

Basically, I'm using audio input levels to drive the playback rate of video loops and I've had good results using VDMX to achieve this on the my old X99 board using the Clover boot loader which is why I thought I'd test it out.

bloomav avatar Mar 23 '24 09:03 bloomav