Unity Can anyone tell me whether mp4 or webm video clips would be easier to insert into a Unity game?

rb813

Active Member
Aug 28, 2018
976
574
I've got a little game that I'm working on, not big or important enough for me to pay someone else for artwork, but I still want to have something visually pleasing when the character gets to have sex. So I was thinking I'd drop in some short video clips of real porn, which is something I already have a pretty extensive collection of. I have one collection that's mostly mp4, then I converted some of those and some new ones to webm (for a HTML game I'm trying to mod). Would one of those file formats work better than the other in a Unity game? I did the conversions to webm because that was the only thing that worked for the HTML game (and I was just building on what was already there, or else I never would've picked that engine), but I'm guessing Unity isn't so restrictive. What I'm hoping to do is have a function where each time a specific type of scene is triggered, it'll select a random clip from a specified folder (meaning that I or whoever else might play the game could just add or subtract any clips that suit one's interest at the moment, without needing to manually import each one into the game). Does anyone know whether one particular file type would work better than another for that?

While you're reading this, I wouldn't mind some general advice about how to set up the programming for the videos as well. I've played around in Unity a lot, but never really bothered much with multimedia. There was one time when I tried to do a similar thing with porn clips, and the best I could figure out was getting it to show up as the background for the whole screen. I figured I'd just google for tutorials, but if anyone has any good resources on the subject close at hand, feel free to share them.
 

Houtamelo

Member
Game Developer
Jul 25, 2017
236
257
Back in 2020, while working on Bonds of Blood, we tried using mp4 videos for our animations (we considered webm but at the time Unity didn't support it, idk if it does now). The videos would not loop correctly (they would stutter a little bit at the end even though we made sure they did loop correctly outside unity) and whenever we switched the currently-playing video the image would also stutter a bit and sometimes flicker. I never managed to fix those issues so we ended up giving up on mp4 and switched to frame-by-frame animations instead.

That was 2 years ago so I can't say if you'll have a better experience, though that could quickly be tested.

Anyway, if you need assistance with Unity just hit me up on discord: Houtamelo#8697, I'd be happy to help.
 

rb813

Active Member
Aug 28, 2018
976
574
Well, I tried following a simple , and it did get me as far as having a looping video play without being the background of the whole screen, but the aspect ratio is kinda wonky and it doesn't have sound. Come to think of it, that might be why I set it up the way I did last time, not because the video wouldn't play otherwise, but because the sound wouldn't work. I'm not sure, I'm the type of person who usually just mutes the games that I play (a lot of sex games don't have sex noises anyway, but I found the other sound effects and background music annoying), so I never spent much time learning how to work with Unity in my programming.
 

dakifaki

New Member
Aug 3, 2023
9
0
Back in 2020, while working on Bonds of Blood, we tried using mp4 videos for our animations (we considered webm but at the time Unity didn't support it, idk if it does now). The videos would not loop correctly (they would stutter a little bit at the end even though we made sure they did loop correctly outside unity) and whenever we switched the currently-playing video the image would also stutter a bit and sometimes flicker. I never managed to fix those issues so we ended up giving up on mp4 and switched to frame-by-frame animations instead.

That was 2 years ago so I can't say if you'll have a better experience, though that could quickly be tested.

Anyway, if you need assistance with Unity just hit me up on discord: Houtamelo#8697, I'd be happy to help.
I remember having the same issue. The way I did it was having two render texture with the same video, but only one enabled at a single point in time. On each loop, I would disable the render texture that was currently playing and enabled the other one that was waiting ready on frame. That way I had no stuttering and was able to loop properly.
 

Houtamelo

Member
Game Developer
Jul 25, 2017
236
257
I remember having the same issue. The way I did it was having two render texture with the same video, but only one enabled at a single point in time. On each loop, I would disable the render texture that was currently playing and enabled the other one that was waiting ready on frame. That way I had no stuttering and was able to loop properly.
We tried it again a few months ago and the looping was working fine, we figured that the changing video problem was due to not releasing the video texture before changing.
 

aereton

Member
Mar 9, 2018
364
692
Specifically this part should answer OPs questions:

Compatibility with target platforms
The component uses the native audio and video decoding libraries of your Editor platform to play video files in the Editor. You must confirm that the files also meet the requirements for the target platform.

Encoding recommendations
  • The best natively supported video codec for hardware acceleration is
  • When cross-platform support is a high priority, is a good choice. It’s widely supported and has a comprehensive feature set
    , but it consumes more resources than hardware-accelerated codecs such as H.264.
  • is available on devices that support it. See below, for more information.
  • Android supports VP8 using native libraries, so VP8 might also be hardware-assisted on some Android devices.
  • The Unity Editor supports the .ogv format, but it isn’t widely supported on other platforms. Transcode .ogv files into .mp4 ( ) or .webm ( ) depending on the target platform.