You can import many video file formats into Unity. Unity stores imported video files as VideoClip assets.
For Unity to preview video files, the files must be compatible with the platform where you run the Unity Editor. Your files must also be compatible with the target build platforms. Unity provides options for transcoding files to commonly supported formats, but you can also manage compatibility yourself. See Compatibility with target platforms below for more information.
Video source files must use a format that your Editor platform supports. Each platform supports different video file formats.
Extension | Windows | macOS | Linux |
---|---|---|---|
.asf | ✓ | ||
.avi | ✓ | ||
.dv | ✓ | ✓ | |
.m4v | ✓ | ✓ | |
.mov | ✓ | ✓ | |
.mp4 | ✓ | ✓ | |
.mpg | ✓ | ✓ | |
.mpeg | ✓ | ✓ | |
.ogv | ✓ | ✓ | ✓ |
.vp8 | ✓ | ✓ | ✓ |
.webm | ✓ | ✓ | ✓ |
.wmv | ✓ |
Encoding for video file tracks must use a supported codec. Each platform supports specific codecs that can change with each version of the platform.
Video files that use unsupported codecs trigger an error message in the Editor and you must convert them to a compatible codec before you can use them.
H.264 is the optimal supported video codec for most platforms. It offers the best cross-platform compatibility, but the Linux Editor doesn’t support this codec.
For Linux, the optimal encoding is a .webm container with the following codecs:
For information about codec support, see the official platform documentation for your Editor. See the links below for codec compatibility for Windows and macOS:
The Video Clip Importer can transcode video files that you import into Unity. This is useful when your videos use a codec that the Editor platform supports, but the files aren’t compatible with your target platform.
To use video files that are compatible with your target platforms, but not your Editor platform, set them up as streaming assets. For example, you might want to use the VP9 codec for an Android build, even though the Editor only supports VP8.
To set video files up as streaming assets, place them in the StreamingAssets
folder of your project. Use the URL property to point the Video Player component to streaming assets.
You can also use Application.streamingAssetsPath to access platform-specific paths to streaming assets via scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary. You can’t preview these paths in the Editor.
If you want to have placeholder versions that are compatible with your Editor but use a different version for your target platform, you can include both versions in your project, use Editor-compatible versions as placeholders, and decide which version to use at run time.
The example below demonstrates how to use different video URLs for different platforms. For more information, see the documentation on Platform-dependent compilation.
void SetupMovieFile(VideoPlayer vp)
{
#if UNITY_EDITOR || UNITY_LINUX
vp.url = pathToMyVp8File;
#elif UNITY_ANDROID
vp.url = pathToMyVp9File;
#elif UNITY_STANDALONE_WIN
vp.url = pathToMyWmvFile;
#else
vp.url = pathToMyMp4File;
#endif
}
The Video Player 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.
The best natively supported video codec for hardware acceleration is H.264
When cross-platform support is a high priority, VP8 is a good choice. It’s widely supported and has a comprehensive feature setA feature set is a collection of related packages that you can use to achieve specific results in the Unity Editor. You can manage feature sets directly in Unity’s Package Manager. More info
See in Glossary, but it consumes more resources than hardware-accelerated codecs such as H.264.
H.265 is available on devices that support it. See H.265 Compatibility 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 (H.264) or .webm (VP8) depending on the target platform.
The table below lists key values to look for in your encoding parameters:
Parameter | Description |
---|---|
Video Codec | H.264, H.265 or VP8. |
Resolution | The resolution of your display. For example: 1280 × 720. |
Profile | The profile is a set of capabilities and constraints, often specified by the vendor, such as Baseline or Main. Applies to H.264/H.265.See H.264 or H.265. |
Profile Level | Applies for H.264/H.265. Within a given profile, the level specifies performance requirements, for example, Baseline 3.1. |
Audio Codec | AAC (for mp4 videos using H.264/H.265) or Vorbis (for webm videos using VP8). |
Audio Channels | Dependent on the platform. Refer to the developer guide for your platform. For example, the article on Supported media formats for Android. |
The Video Clip Importer provides the option to transcode VideoClip assets into one of the following video codecs:
Transcoded VideoClips use the appropriate audio codec automatically:
Note: The Video Clip Importer provides only basic transcoding options. Depending on how your source files are encoded, you might not get optimal performance from clips transcoded with the importer options. In that case, you might get better results with an external transcoding program.
If you use videos that the target system definitely supports, you can leave the Video Clip Importer’s transcoding options disabled. If disabled, Unity doesn’t modify the files. You can manage encoding with an external program, which allows for finer control.
This section provides useful information about video compatibility, and links to external resources.
Follow vendor recommendations for codec support. On older mobile platforms, codec choices are limited . You might need to inspect and convert or re-encode videos that you intend to include in a game running on multiple devices.
The table below provides platform-specific requirements and information for the H.265 codec.
Platform | Requirements | Encoding/Decoding | Notes |
---|---|---|---|
macOS | SDK 10.13+ |
Hardware encoding: 6th Generation Intel Core processor Software encoding: All Macs Hardware decoding: 6th Generation Intel Core processor Software decoding: All Macs |
|
Windows | Windows 10 + HEVC extensions |
Encoder Decoder |
HEVC extension (Hardware only) HEVC extension (Hardware + software support) |
iOS | SDK 11.0+ |
Hardware decoding: A9 Chip Software decoding: All iOS Devices |
|
tvOS | SDK 11.0+ | ||
UWP | Windows 10+ | If a device lists support for H.265, that might not apply to all devices within the device family. | |
Android | 5.0+ |
2019–05–07 Page amended
New feature in Unity 5.6
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.