Exemple #1
0
    private void CompleteVideoLoad(bool useBT709)
    {
        // Gather properties
        Volume          = _volume;
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);
        Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));

        // Create format converter
        if (Width < 0 || Width > 4096 || Height < 0 || Height > 4096)
        {
            Debug.LogWarning("[AVProWindowsMedia] invalid width or height");
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, false, isTopDown))
            {
                Debug.LogWarning("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                }
                // TODO: close movie here?
            }
        }

        PreRoll();
    }
Exemple #2
0
    private void CompleteVideoLoad(bool useBT709, bool ignoreFlips, FilterMode textureFilterMode, TextureWrapMode textureWrapMode)
    {
        RequiresFlipY = false;
        Loop          = false;
        Volume        = _volume;

        // Gather properties
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);

        if (AVProWindowsMediaManager.Instance._logVideoLoads)
        {
            Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));
        }

        // Create format converter
        bool hasVideo = (Width > 0 && Width <= 8192 || Height > 0 && Height <= 8192);

        if (!hasVideo)
        {
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }

            bool flipX = false;
            bool flipY = isTopDown;
            if (ignoreFlips)
            {
                if (flipY)
                {
                    RequiresFlipY = true;
                }

                flipX = flipY = false;
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, flipX, flipY, textureFilterMode, textureWrapMode))
            {
                Debug.LogError("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                    Close();
                }
            }
        }

        PreRoll();
    }