- Home /
The question is answered, right answer was accepted
Read mp4 metadata [Solved]
I am currently using URL to play MP4 videos. But I would like to define only certain MP4 videos will be supported in my application. So I would like to know how to read the metadata ( video info ) in MP4 videos in Unity in order to get Major Brand ( A.K.A ftyp ) value ( mp41 or custom value ).
Hi there!
Does anyone ( @busyxiang ) knows if the above solution allows somehow to read mp4 video chapters/ markers...?
Answer by busyxiang · Jun 05, 2019 at 02:58 PM
After a lot of time wasted, I finally have a solution to retrieve the value of MajorBrand from Mp4 video. I am sharing my solution here, hope it will be able to help other people
FileStream fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
BinaryReader binaryReader = new BinaryReader( fileStream );
binaryReader.BaseStream.Seek( 0, SeekOrigin.Begin );
byte[] verifyArray = binaryReader.ReadBytes( 32 );
binaryReader.Close();
ConvertToString( BitConverter.ToString( verifyArray ) );
private void ConvertToString( string hex )
{
StringBuilder builder = new StringBuilder();
string[] splitHex = hex.Split( new char[] { '-' } );
for (int i = 0; i < splitHex.Length; i++)
{
int value = Convert.ToInt32( splitHex[i], 16 );
string stringValue = char.ConvertFromUtf32( value );
char charValue = (char)value;
if( value != 0 )
builder.Append( stringValue );
}
}
Follow this Question
Related Questions
Import Video Codec H.264 MP4 from Premiere 6 Answers
Play, seek a video 1 Answer
How do I add videos mp4 , wma , files on the game in Unity3d 1 Answer
Camera Stream - Send unity camera video or frames 0 Answers
Getting value from another script 0 Answers