![]() ![]() In order to use this class, we first need to build an application and deploy a media file with it to examine. getVideoTrackInfo (idx : uint32 ) : TVideoTrackInfo begin Result : = fVideoTracks. getVideoTrackCount : uint32 begin Result : = fVideoTracks. Add (ARecord ) end end end end function TMediaMeta. startsWith (StringToJString ( 'video/' ) ) then begin if format. init (f ) Ĭounter : = 0 for idx : = 0 to pred (numTracks ) do beginįormat : = extractor. init (StringToJString (fFilepath ) ,StringToJString (fFilename ) ) įis : = TJFileInputStream. DisposeOf inherited end procedure TMediaMeta. Create (Filepath, Filename : string ) begin inherited Create ĮxtractMeta end destructor TMediaMeta. / įFilepath : string private procedure ExtractMeta function getVideoTrackCount : uint32 function getVideoTrackInfo (idx : uint32 ) : TVideoTrackInfo public constructor Create ( Filepath : string Filename : string ) reintroduce destructor Destroy override public property VideoTrackCount : uint32 read getVideoTrackCount property VideoTrackInfo : TVideoTrackInfo read getVideoTrackInfo end implementation usesĪndroidAPI. YRes : int32 end /// /// This class provides array-style access to the video track information /// discovered in the target media file. collections type /// /// This record is used to store information about the video tracks /// discovered in the target file. This is the source for a class which extracts the required information from a media file… unit uMediaMeta interface uses This can be seen in the ExtractMeta() method of my source below… The solution to this problem is to open the file manually using the ‘File’ android API class, connect an input stream to it using the ‘FileInputStream’ API class, and then get a descriptor for the file using the ‘FileDescriptor’ class, finally pass the file descriptor to the setDataSource() method. Unfortunately, the android API appears to have a bug which means that the overload of setDataSource() which takes simply a filename does not work, and raises an exception. There’s a bug to watch for in the Android API, in my first attempt I created an instance of MediaExtractor like this… varĮxtractor : = TJMediaExtractor. So we need to create an instance of this class and extract the data from it. So what we need to do is get the resolution and frame rate information of a video track within an mp4 file.Īndroid offers a class named “MediaExtractor” to extract data from a media file within it’s API. (As an aside, NTSC is actually 29.9 frames per second due to a technical restriction in broadcast frequencies, but I digress…) NTSC has a frame rate of 30 per second, and a vertical resolution of 512 scan lines.PAL has a frame rate of 25 per second, and a vertical resolution of 625 scan lines.Ultimately, what determines if an image or video conforms to PAL or NTSC is a combination of the frame rate and the image resolution. This seemed like a fun challenge, so I thought I’d write a helper class to solve it. mp4 file, and determine if it’s PAL or NTSC.” “I need to be able to peek into a video file, specifically a. One of my customers emailed me with an interesting problem this morning. ![]()
0 Comments
Leave a Reply. |