Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Resolved Replacement gif workflow for Unity Recorder

Discussion in 'Audio & Video' started by Livealot, Apr 28, 2021.

  1. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    It looks like Unity Recorder is dropping support for animated gifs.

    That's disappointing because Unity Recorder offered the HIGHEST QUALITY gif capture I've found.

    @markvi Could you share the settings you use in your new recommended approach (capture MP4 and convert) to match the gif quality generated from Unity Recorder?

    Everything I've tried looks like the pixelated garbage from old workflows prior to Unity Recorder.

    Thanks!
     
    LaurieAnnis likes this.
  2. unitybru

    unitybru

    Unity Technologies

    Joined:
    Jan 28, 2020
    Posts:
    225
    Hi,

    we are working hard at improving the quality of MP4 exports, but until this is available to you, your best quality will be obtained by exporting to PNG (because JPEG is at 70% quality in Recorder) and then using one of several tools to do the conversion to GIF. You should make sure that your PNG files have a frame number suffix that ensures that their order is correct.

    I can't recommend certain tools over others, but this Google search should push you in the right direction: https://www.google.com/search?q=script+convert+image+sequence+to+gif

    Hope this helps!
    Bruno
     
    Livealot likes this.
  3. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Thanks @unitybru for the links, and I appreciate that you can't recommend specific tools.

    Personally, I use ScreenToGif because it offers a bunch of easy to use editing tools.

    After doing some benchmarking, it seems that my real question is trying to understand what Encoder was used under the hood to generate the gifs in earlier versions of Unity Recorder.

    It's pretty easy to capture the raw images, either JPG or PNG, with Unity Recorder, and then, as you suggest, load and edit them in a 3rd party tool, like ScreenToGif.

    But when I go to encode the raw images into a gif, I get nothing close to the quality/size that Unity Recorder generates out of the box. That's why I'm especially sad to see it go.

    For benchmarking, I captured 3 seconds of gameplay and got the following:
    • Unity Recorder - best quality, 8mb file
    • FFMpeg Encoder, similar quality 30mb file
    • System Encoder of raw JPGs, similar quality 39mb file
    • System Encoder or raw PNGs, similar quality 37mb file
    • ScreenToGif 2.0 Encoder, crap quality, 15mb file
    So without Unity Recorder, my options are files that look good but are too large to share, or files that look like crap.
     
  4. unitybru

    unitybru

    Unity Technologies

    Joined:
    Jan 28, 2020
    Posts:
    225
    The encoder that was used for GIFs is FrameCapturer, a tool developed by our colleagues at Unity Japan.
    The package has not seen any development in close to 3 years and its integration in Recorder was not straightforward (one of our motivations in removing it).
    https://github.com/unity3d-jp/FrameCapturer you're on your own if you try to compile this and plug it back in Unity

    Under the hood, FrameCapturer uses https://www.jonolick.com/home/gif-writer (a single CPP file) to do the encoding.

    Maybe you want to create a GIF Recorder that uses this library (jo-gif)? Your time to shine ;)
     
    Last edited: Apr 29, 2021
  5. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Thanks for the added info @unitybru . Hopefully it inspires someone to shine, because your Unity colleagues did a nice job.

    While I have a fantasy that there's a single button in the editor called "Capture Twitter Gif", I'm realizing that's only a dream. To meet the Twitter size requirements, there's too many trade-off choices that need to be made.

    So here's my gif workflow for high-def, motion intensive gameplay that approximates the 2.5.5 gif capture quality and stays in the Twitter ballpark:
    1. With your preferred Gif Tool (mine is ScreenToGif), set the capture window to 15fps and 400 x 300 pixels. The smaller you go, the longer the gif can be, and vice versa.
    2. Set up your GameView so that the capture window in #1 fits over the content you want, whether that's the full gameplay or just a corner of it. Don't use 'Maximize on Play'
    3. Play your game and start/stop your gif recording as desired.
    4. Save/Encode the gif with FFmpeg. Most other encoders will create lots of banding and artifacts.
    5. Crop gif dimensions and/or remove frames until you meet the Twitter size requirements.
     
    unitybru likes this.
  6. calliopeb7297

    calliopeb7297

    Joined:
    May 18, 2021
    Posts:
    1
  7. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    481
    I don't understand why you want to use gif for posting on twitter, when twitter converts all gifs to mp4 anyway
     
  8. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Thanks @Steven-1 for pushing me to reconsider the old way.

    The knee-jerk response to "why gif":
    • I've always posted gif
    • Most of the stuff I like on Twitter uses gif
    • Sakura Rabbit, who post the best looking Unity tweets out there, use gif
    The classic "why gif" responses:
    • Autoplay
    • Autoloop
    • Better quality per mb
    Checking the latest Twitter defaults and user options, those "classic" answers unravel
    • Videos < 60 sec autoplay and autoloop
    • User setting to disable autoplay affects both mp4 and gif
    • Mp4 compression delivers better quality per mb
    So the "modern" differences that remain:
    • Gif workflow has easy post-capture editing tools (trim, crop, mix, cut frames, control speed etc.)
    • The "classic" responses may still apply on other platforms
    • Some cosmetic/UI differences, e.g., mp4 has viewcount (nice) but also a full screen option (ugly)
    Net net, I may need to start kicking my gif habit, at least for Twitter.
     
  9. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Steven-1 and unitybru like this.
  10. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    shyamarama likes this.
  11. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    472
    Ooooookay, this explains why the GIF capturing part of Unity's recorder sucks so much. No more support.

    I also have a bug with the audio recording because the recorder intercepts the audio flux and keeps it to itself jealously, so if you say "include audio" you will not hear it while playing in the Game window in the Editor on a mac, but if you don't want to record the audio too, then you can hear it.

    Is there any real benefit going for GIF for such short sequences? MP4 is superior in all possible ways, starting with the obvious advantage in framerate.
    I was wondering what format to pick but no matter what is done, GIF is just plain disgusting. The only thing it had going for it for years was that Twitter would often crash a video's quality three or four seconds into the playing if it detected, I guess, a limited bandwidth. Twitter has now changed some algo, including picture cropping some two weeks ago, and they likely fiddled with the video algo too.
     
  12. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    472
    Has S.R. shared the method they use for producing those GIFs? Is there anything special or is it just creating high resolution and high framerate GIFs from video conversions?