Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Why does Unity insist on transcoding MP4 files?

Discussion in 'Editor & General Support' started by frjtrifork, Sep 16, 2015.

  1. frjtrifork


    Mar 12, 2015
    We have an Android only (for now at least) game that has some tutorial-like videos that play natively in Android using Handheld. These need to be mp4 format in the Android apk.

    Whenever someone on the team move an mp4 to another folder or a new mp4 is added, or an existing one is updated Unity takes a really really long time with a modal progress bar where it is 'importing' the MP4. We have had cases where a dev machine was blocked for close to two hours doing this. And yes we do use the cache server, but sometimes someone get lucky and get a really long coffee break.

    I have read in other posts that it is transcoding the file to ogg which Unity uses for video. Which seems stupid since we need the file in the format we added it in.

    But - just to test - I tried transcoding a video to ogg using the transcoder in Unity and putting that in the project - and then I get an error saying this video format is not supported by the target platform. Which is true - Android does not officially support ogg.

    So since ogg is not even supported by Android why does import of the MP4 file take so long?
    Is there any way I can tell Unity NOT to do anything to the file but add it to the apk in the assets folder when building (they are all located in the StreamingAssets folder as instructed in the docs for Handheld).

    We are using 4.6.

    The pragmatic solution I was thinking of was to remove the mp4s from our project, and then add them to the apk after it has been built by Unity using the Android build-tool aapt and then re-signing and zipaligning the apk before upload to Google Play - I'm pretty sure that would work (as we have done this for other resources in other projects - but it seems like a fairly standard usecase needing to have video resources and not have them disrupt development)
    Last edited: Sep 16, 2015
  2. GXMark


    Oct 13, 2012
    A very simple solution that I use in my MMO game is to import the mp4 files as audmp4 extension which stops the unity asset importer from processing them. Since I build out a cache of audio I can create UUID for each and change the extension back to mp4 which is outside of the unity assets folder. There maybe a workaround for you like this depending on the kind of game your making.

    If anyone knows how to ignore transcoding maybe via creating an asset importer for this then please post.