Forum rules - please read before posting.

What is the best/fasted way to play an h264 video with AC in unity, in a cut scene?

edited May 2020 in Technical Q&A

Hi guys,

As you might know, I'm really in the beginning here, with AC and Unity.

I decided to do my cut scenes in After Effects. It is faster for me... I already have some videos exported in H264.

I want to include them in different scene/cut scenes, they will be played, once the scene is loaded; those scenes can be skipped if we click while the video is playing... so I was wondering...

What s the easiest way, and fastest to do this? There is no interaction in that scene, except for the ability to skip it, with a mouse click...

Can you help me here, what steps do I need to take? Please mind that I'm really a newbie... I can only o scenes, I don't even know how to join them :(

Thanks :)

Comments

  • edited May 2020

    oh man, some of my vieos has 3GB... ups, maybe it is too much... what would be the maximum size you advise per minute of video? I'm rendering them at 1080p

  • Video playback is handled by the Video Player component. This is a Unity component, so what formats and codex it accepts is handled by them - but you can find such details here.

    To have such a component play as part of an AC ActionList, use the Engine: Play movie clip Action. This Action supports skipping upon pressing a supplied input name.

    To switch scene once a clip has finished, check Wait until finish? and then follow this Action up with a Scene: Switch Action. In here, you can supply the name or index number of the scene to switch to. The index number is the number shown when the scene is added to Unity's Build Settings. You will need to ensure that all scenes in your game are added to the build settings before they can be switched to at runtime.

    I can't give too much advice about file-sizes, though 3 gigs does sound too large. I personally use ffmpeg to reduce the bitrate if I want to reduce a video's filesize.

  • Thanks Brian :) Can you give me a acceptable video file size per minute? If you can? please? :) I intend to have 10 to 20, or more videos as cut scenes...

  • edited May 2020

    It's Chris.

    I'd say 3-4 Mb per minute, but that's just my opinion.

  • Ok, thanks a lot :) It is good to now, because rendering videos take some time... now I can render them, with the right size more or less do I won't have to worry about file sizes later... :)

  • Hi Chris, sorry to bother you again. I already manage to play my videos, but the video is not synced with the audio. I didn't add a audio component to my video player, because it has sound. I don't have a sound board, I'm using direct. What do you think the problem might be? Could it be related to the size of my video files? What should I try? Thanks :)

  • The video itself has the audio?

    If there's an a/v syncing issue, it will be to do with Unity - not AC.

    The Unity forums have a few threads related to this, e.g.: https://forum.unity.com/threads/audio-lag-in-video-player.472752/

  • Thanks, I went to that thread, did everything there, and still there is this 1 second video delay. My game is based on videos, so I don't know what to do :( I'm getting frustrated... I followed this tutorial:

    Also, when I do a cut scene, and put the video playing, I though the video plays immediately but but it plays audio with no image. I created an object (as before) to render the video, put it somewhere in the scene, change the camera, and I saw the image finnaly (Am I doing the way I should? This is so time consuming) However when I add a button to skip the cutscene nothing happens. It doesn' t skip the video... Do I have to put the button key between comas? I tried it but still nothing happens. You see there are a lot of people complaining about the same issues... did they manage to solved them?
    https://adventurecreator.org/forum/discussion/449/endcutscene-skip-cutscene-input-solved

  • edited June 2020

    I went to that thread, did everything there, and still there is this 1 second video delay.

    If the audio is coming from the VideoPlayer, then its delay is not due to AC. I suspect it'll be based on the video's format and import settings, but this really is an issue on the Unity side of things. You're welcome to PM me the video for me to see for myself, however.

    One thing that AC can do to try to help is prepare the video before it needs to be run. This can be done with the Engine: Play movie clip Action, referencing the Video Player and checking Prepare only?.

    Am I doing the way I should? This is so time consuming

    You don't need a separate camera for each video, and the Action can optionally change the VideoPlayer component's video clip, so that you can use a single VideoPlayer. The "Prepare only?" option will not have an effect, though.

    You see there are a lot of people complaining about the same issues...

    That thread is related to skipping cutscenes in general - not movie sequences in particular. Which are you looking to do?

    The "EndCutscene" input will skip ActionLists that are marked as skippable in their properties. To skip the currently-running movie, you need to supply an input name in the Engine: Play movie clip Action's Skip with Input Button field.

    Bear in mind that both of these are input names - not the input keys themselves, such as "tab". They need to be defined in Unity's Input Manager, and mapped to the intended key there.

    If you'd like specific advice to your situation, post some screenshots showing what you've got - I can only give general advice otherwise.

  • edited June 2020

    Do be aware that while AC tries to be accessible to Unity users of all experience levels, it's still necessary to have a general overview of Unity's principles and systems. It is, ultimately, another layer to an already powerful tool - not a replacement.

    Docs on the Input Manager can be found here: https://docs.unity3d.com/Manual/class-InputManager.html

    I though you just have to add the Keyboard key in the Skip with Input Button field. What should I write there?

    The name of the Input you define in the Input Manager. What key do you ultimately want to map it to?

    As a guided example, enter in "SkipMovie" (without quotes).

    Then open up Unity's Input Manager, and create a new input by increasing the "Size" field at the top by 1. The new input will be added to the bottom of the list, so expand it and set its "Name" field to match that above - "SkipMovie" (again, no quotes).

    Then set the "Type" to "Key or Mouse Button", and the "Positive Button" to the actual keyboard key you want to map to it - e.g. k, tab or space.

    If you need more help, share screens so that I can see your setup.

    maybe I should lower the quality...

    It's a factor of many things, not just the video itself but also the system you're running it on. The best way is to simply reduce it and see. Again, ffmpeg is a good tool to help with this - no need to re-render the video in your video editing software.

  • edited June 2020

    ok, thanks :) I will try it out... is the ffmpeg free? Thanks for replying... sorry to bother you for being so newbe, it is the creative impatience ringing LOL :)

  • It is - see the link in my earlier post.

    A video tutorial on creating an input (for skipping cutscenes, not videos specifically) can be found here.

  • edited June 2020

    Thanks... Everything works fine... I didn't the converting my video yet...

  • Hi, sorry to bother you, I put the quality as low as I could... It is still unsynced... nothing changed... I'm still using H264... I know that AVI files sizes are huge... i'm gonna try AVI, but I really don't understand... I thought H264 was the right format... got any more suggestions? Thanks :)

  • Other than searching the Unity forums for those with the same issue, not really I'm afraid. You're dealing with Unity's behaviour, not AC, so Unity are the best people to ask about it.

  • ok, thanks Chris :) I'm gonna do that...

  • Oh Chris, nobody seems to help me in the unity foruns... snif snif :( Tell me what does prepare video does exactly? Could this lag be over when I build the entire project? Some of my videos still have 300 mb, maybe I should lower the quality... anyway Chirs, just let me tell you, I'm so in love by AC :) It is like a dream come true... I thank you from the bottom of my heart... You made my childwood dreams come true... THANK YOU :)

  • The "Prepare video?" option will trigger the VideoPlayer component's Prepare function.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.