Search Unity

Video Unity Recorder movie output is too fast

Discussion in 'Audio & Video' started by hedgefield, Apr 19, 2019.

  1. hedgefield

    hedgefield

    Joined:
    Jan 1, 2014
    Posts:
    39
    Hey there,

    I'm using the Unity Recorder 2.0.0-preview6 package with Unity 2018.3.8f1 on Windows 10, and I'm having some trouble with the movie output speed. When I render an MP4, the resulting video footage is faster than it should be when played in the editor, while the audio track is at the correct speed. For example, I have one recorder clip set up to record 10 seconds of the timeline in 4k. The resulting video output is 8 seconds. What's even weirder, is that when I set the output to 1080p, the resulting video is 6 seconds.

    Here is my setup:
    - I have one timeline in my scene, set to 30 FPS.
    - The Playable Director is set to update on the DSP clock, because the timeline is animated to an audio track.
    - I use a mixture of activation tracks, animation tracks with clips, and animation tracks recorded inline.
    - I have a RecorderClip set up in the timeline to output a 1080p MP4. Settings are shown in the screenshot.

    cc @marief_unity
     

    Attached Files:

  2. pintianz

    pintianz

    Joined:
    Mar 1, 2015
    Posts:
    25
    Having the same problem. The recorded video is way too fast. The video was designed to be in sync with the background music, but the recorded version is out of sync with audio playing at normal speed.
    Unity 2018.3.14,
    Recorder ver. 2.0.1-preview.1
    Record format: mp4
    Constant playback, Film(24), cap
    @marief_unity
     
  3. BenCS

    BenCS

    Joined:
    Jun 21, 2018
    Posts:
    1
    still running into this problem as well
     
  4. Teejay5

    Teejay5

    Joined:
    Feb 26, 2010
    Posts:
    106
    I'd like to bump this issue, happens here too. It's even worse if you're using a video texture in the game, the video texture will play back at like 10x the speed it's supposed to.
     
  5. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Can someone from Unity get in here and help to figure this out? Please?

    I am trying to make some trailers and it is impossible to get the recorder to output at the correct speed.

    Regards,
    Carlos
     
  6. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    I think I figured out a way to get the right speed in the output of the recorder! I set the sync in Quality Settings to every second v blank, I pressed the game window's top right button VSync to activate it, and set the Recorder target setting in the top right to NTSC(29.97), and finally I unchecked Capture audio in the recorder. After I set these and recorded the output was at the right speed. Of course I had to take the video to AE or other software to like it to add the audio back.

    I hope this helps someone.

    Regards,
    Carlos
     
    yanghj306, IMC-Lab and GeorgeAdamon like this.
  7. SkareMedia

    SkareMedia

    Joined:
    Jan 8, 2019
    Posts:
    6
    Im having this same issue too. I tried your steps but cant figure out where/how to activate the game windows VSync "I pressed the game window's top right button VSync to activate it"

    Where is this buttoin exactly?
     
  8. Romaleks360

    Romaleks360

    Joined:
    Sep 9, 2017
    Posts:
    72
    Any updates? That's very annoying! Basically makes Unity Recorder totally useless
     
  9. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    157
    here:
     

    Attached Files:

  10. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    And here as well:
     

    Attached Files:

  11. SolutionStudios

    SolutionStudios

    Joined:
    Aug 1, 2014
    Posts:
    109
    This problem still occurs even when using the VSync setting above. To fix this you can manually control the frame of the video the VideoPlayer is displaying like this:
    Code (CSharp):
    1. void Update() {
    2.     videoPlayer.Pause();
    3.     if (videoPlayer.frame / videoPlayer.frameRate < Time.time) {
    4.         videoPlayer.StepForward();
    5.     }
    6. }
    This works if the framerate of the playing video is lower than the framerate you are trying to record at (if not then you could try replacing the if statement with a while loop). And it assumes you start playing the video when the scene starts. If not just subtract the time the video starts from Time.time above.
    You also might be tempted to do this by setting the frame number directly with `videoPlayer.frame = ...`. But don't do this as it just causes more problems. Using `StepForward` and `Pause` is your best option.
    @Teejay5
     
    jhuertas and IMC-Lab like this.
  12. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    157
    So I had the same problem - a Video texture playing on a billboard (plane) in the engine, will not record with UnityRecorder.
    I've done all the error checking so far:
    - Set Vblank and even tried Vblank to every second frame, in game window and main settings/
    - Set fps to 30 in Unity Recorder
    - set timeline to 30 fps (the billboard video is on a plane gameobject and has a simple translation movement on x axis)
    - Video on billboard is also 30 fps and plays fine in Unity when NOT recording with UnityRecorder.

    - Even worse should you decide to play the video at slower speed using Unity Player slider and recording to 4k.


    Solution:
    Luckily I own the VR panorama asset from the asset store and it has a script called videoSync. Which is the same code as the post by @SolutionStudios

    Come on Unity, UnrealEngine is miles ahead in Video production and Unity is lagging in fixing solutions that make or break a feature.

    Has this previous problem with Unity Recorder not recording Camera iSO/aperture and depthof field been fixed?
    https://forum.unity.com/threads/rec...ecord-a-take-to-timeline.892168/#post-5905694

    @cguertin , any insights?
    Kind Regards
     
    Rensoburro_Taki likes this.
  13. Matjio

    Matjio

    Unity Technologies

    Joined:
    Dec 1, 2014
    Posts:
    108
    Hi everyone,

    Sorry to have missed this thread.

    Synchronization between audio and rendering with video recorder should be fixed at leat in the latest Recorder package (2.2). If you still have issues, please share it here (ideally with a small project to reproduce and a ticket submitted in the Editor so that you can track our progress).

    Note: With the Recorder Window, for video recording, you must select frame rate option to Constant and matching your main Timeline frame rate. With a Recorder clip on Timeline this is set automatically.

    @Dirrogate The VideoPlayer and the Unity Recorder are not generally compatible because the VideoPlayer does not support the use of Time.captureFramerate and this is how the recorder changes the execution speed to perform non-realtime rendering. Check this thread which lists workarounds or solutions depending on your usage: https://forum.unity.com/threads/frame-accurate-video-or-image-sequence-playback.854203/

    @Dirrogate Re. animation clip recording of Camera ISO and aperture, we have not yet a solution. But this is high on our priority list.

    Best,
    Mathieu
     
    _slash_ and Dirrogate like this.
  14. Matjio

    Matjio

    Unity Technologies

    Joined:
    Dec 1, 2014
    Posts:
    108
    Another warning, about synchronization when baking anything: Make sure that the Playable Director update method is set to Game Time. DSP clock is for real-time playback only.
    upload_2020-7-1_11-34-13.png
     
    kingpanks and Dirrogate like this.
  15. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    @Matjio for some Reason it still doesn't work for me. :(

    I want to record Animation Clips from gameobjects in sync to music because I am basically trying to record a rythm based aniamtion that can be replayed in the timeline.
    Oddly enough when I simply use the example Code from the GameObjectRecorder Class it seems to work just fine:
    https://docs.unity3d.com/ScriptReference/Animations.GameObjectRecorder.html

    I have not yet tried to record something over a longer period of time so I don't know if the recording will still go out of sync over a longer period.

    The Timelie Recorder in comparison is completely unuseable for me, though. I notice drastically delayed/slowed down input during Play mode and while I try to keep in sync with music as soon as I load in the animation clip into the timeline I can immediately see that even over 1 - 2 minutes the clip is only half the length of the time it is supposed to be.
    As with the others in this thread the clip plays expectedly waaay too fast.

    The Playable Director is set to GameTime.
    I am using Unity 2019.4.4f1 LTS
    The gameobject recorded is using BOLT Scripts but the scene has only this one gameObject in it for testing reasons. So It's not likely that it's the overall scene performance capping the recording.
     
  16. spacecataz42

    spacecataz42

    Joined:
    Feb 8, 2018
    Posts:
    1
    this helped me out a lot, only issue now is i'm a bit stumped at the logic to have the video player loop once it's played through. any suggestions?
     
  17. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    You can just tick the option 'Loop' on the video player script
     
  18. Matiasbru

    Matiasbru

    Joined:
    Sep 1, 2015
    Posts:
    20
    Enabling Vsync like this solved my problem. Thanks!
     
  19. OmegaFalcon

    OmegaFalcon

    Joined:
    Jun 15, 2018
    Posts:
    2
    Setting the recorder fps to NTSC(29.97) is what worked for me. Idk why it can't work at higher frame rate.
     
  20. imh3ro

    imh3ro

    Joined:
    Jul 8, 2020
    Posts:
    1
    None of these "solutions" helped me about this. Sadly these bugs still exist in the latest versions and keeps making it unusable..
     
    customphase likes this.
  21. UnityXizor21

    UnityXizor21

    Joined:
    Jan 14, 2021
    Posts:
    36
    This thread for this problem was opened on Apr 19, 2019 by hedgefield.
    I can report this is still a problem on Jul 17, 2022.

    The above listed solutions do not resolve the fast playback issue in Unity Recorder:
    • Activating Sync in Game View
    • Changing Unity Recorder's frame rate (no frame rates work as expected.)
    Is there a solution?
    Is there an alternative to Unity Recorder?
    Is there a work around?
     
  22. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    We just released a feature allowing the VideoPlayer to follow different clock sources in 2022.2. If you are on an earlier version which is highly likely what I saw most people do is manually change the frames like this. When recording the update will be called at the right time if I am not wrong.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Video;
    3.  
    4. public class VideoStepper : MonoBehaviour
    5. {
    6.     private VideoPlayer videoPlayer; // sibling video player
    7.     private bool ready = false;
    8.  
    9.     private void Start() {
    10.         videoPlayer = GetComponent<VideoPlayer>();
    11.         videoPlayer.playOnAwake = false;
    12.         videoPlayer.playbackSpeed = 0f;
    13.         videoPlayer.isLooping = true;
    14.         videoPlayer.prepareCompleted += OnVideoPrepared;
    15.         videoPlayer.Prepare();
    16.     }
    17.  
    18.     private void OnVideoPrepared(VideoPlayer videoPlayer) {
    19.         videoPlayer.Play();
    20.         ready = true;
    21.         Debug.Log("Video done prepared.");
    22.     }
    23.  
    24.     private void Update() {
    25.         if (ready)
    26.         {
    27.             videoPlayer.frame++;
    28.             videoPlayer.Play();
    29.         }
    30.     }
    31. }
     
    JumpingGuy and fxlange like this.
  23. unity_QueHsCYBKkCZLQ

    unity_QueHsCYBKkCZLQ

    Joined:
    Aug 12, 2021
    Posts:
    2
    Using 2021.3.
    That VideoStepper script worked for me.
    Cheers.
    (recording a .mov at 30fps)