mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Support export VideoClip
This commit is contained in:
90
Unity Studio/Unity Classes/VideoClip.cs
Normal file
90
Unity Studio/Unity Classes/VideoClip.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class VideoClip
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_VideoData;
|
||||
|
||||
public VideoClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var m_OriginalPath = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
var m_ProxyWidth = a_Stream.ReadUInt32();
|
||||
var m_ProxyHeight = a_Stream.ReadUInt32();
|
||||
var Width = a_Stream.ReadUInt32();
|
||||
var Height = a_Stream.ReadUInt32();
|
||||
var m_PixelAspecRatioNum = a_Stream.ReadUInt32();
|
||||
var m_PixelAspecRatioDen = a_Stream.ReadUInt32();
|
||||
var m_FrameRate = a_Stream.ReadDouble();
|
||||
var m_FrameCount = a_Stream.ReadUInt64();
|
||||
var m_Format = a_Stream.ReadInt32();
|
||||
//m_AudioChannelCount
|
||||
var size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += size * 2;
|
||||
a_Stream.AlignStream(4);
|
||||
//m_AudioSampleRate
|
||||
size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += size * 4;
|
||||
//m_AudioLanguage
|
||||
size = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
//StreamedResource m_ExternalResources
|
||||
var m_Source = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/", ""));
|
||||
var m_Offset = a_Stream.ReadUInt64();
|
||||
var m_Size = a_Stream.ReadUInt64();
|
||||
var m_HasSplitAlpha = a_Stream.ReadBoolean();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (m_Source == null)
|
||||
{
|
||||
m_VideoData = a_Stream.ReadBytes((int)m_Size);
|
||||
}
|
||||
else if (File.Exists(m_Source) || File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source))))
|
||||
{
|
||||
using (var reader = new BinaryReader(File.OpenRead(m_Source)))
|
||||
{
|
||||
reader.BaseStream.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out var reader))
|
||||
{
|
||||
reader.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {Path.GetFileName(m_Source)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = Path.GetExtension(m_OriginalPath);
|
||||
if (m_Name != "") { preloadData.Text = m_Name; }
|
||||
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
|
||||
if (m_Source != null)
|
||||
preloadData.fullSize = preloadData.Size + (int)m_Size;
|
||||
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.fullSize.ToString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user