Unity 6.3
0 онлайн 63 гостей 3 в системе
Вход

VideoCodec

перечисление

Описание

Выберите видео кодек, который будет использоваться для импорта видеоклипов.

С помощью этого перечисления задают VideoImporterTargetSettings.codec.

Видеокодек сжимает (кодирует) или декомпрессирует (декодирует) видеоданные, чтобы уменьшить размер файла, но избегать снижения качества, насколько это возможно. Для Unity, чтобы учитывать видеокодек при импорте видео, убедитесь, что вы включили Транскодирование свойство в видеоклипе Inspector окно. Для получения дополнительной информации о кодировании видео, см. Справочник по совместимости кодировки видео.

// This script creates an Editor menu option that reimports a video with your preferred video codec (Auto is default). 
// Put this script in your Assets>Editor folder. If you don't have an Editor folder, create your own.  
// In the script, change the videoPath to a video file in your project. Save the script. 
// In the menu, go to Tools and select Change video codec settings.
// The video reimports with the new video codec. 

using UnityEngine; using UnityEditor;

public class VideoImportSettingsEditor : MonoBehaviour {

[MenuItem("Tools/Change video codec settings")] static void SetVideoImporterSettings() { // Path to the video file in your project. Change the path to suit your own project. string videoPath = "Assets/YourVideo.mp4"; // Change this to your preferred video codec. VideoCodec preferredCodec = VideoCodec.Auto;

// Get the VideoClipImporter for the video file VideoClipImporter importer = AssetImporter.GetAtPath(videoPath) as VideoClipImporter;

if (importer != null) { VideoImporterTargetSettings defaultSettings = importer.defaultTargetSettings; // Set the video codec to your chosen video codec. defaultSettings.codec = preferredCodec;

// Apply the updated settings for standalone. importer.SetTargetSettings("Standalone", defaultSettings);

// Re-import the video file. importer.SaveAndReimport();

Debug.Log($"Updated video importer settings for: {videoPath}"); } else { Debug.LogError($"Failed to find VideoClipImporter for the path: {videoPath}"); } } }

Свойства

Свойство Описание
AutoВыберите кодек, поддерживающий аппаратное декодирование на целевой платформе.
H264Кодировка видео с кодеком H.264.
H265Кодировка видео с кодеком H.265.
VP8Кодировка видео с использованием кодека vp8.