public void process(RandomAccessFile file, String filename) throws Exception {
file.seek(0);
// Let the audio library read the ASF file.
AsfHeader header = AsfHeaderReader.readHeader(file);
VideoStreamChunk video = null;
for (Chunk chunk : header.getChunks()) {
if (chunk instanceof VideoStreamChunk)
video = (VideoStreamChunk) chunk;
}
this.videoStreamPresent = video != null;
if (this.videoStreamPresent) {
setVideoResolution(video.getPictureWidth() + "x" + video.getPictureHeight());
setVideoCodec(video.getCodecIdAsString());
setDuration(header.getFileHeader().getDurationInSeconds());
// The average bit rate of the video is as hard to gather as the FPS.
// However in this case there is a recommended chunk in ASF files
// which contains this information.
StreamBitratePropertiesChunk propertiesChunk = header.getStreamBitratePropertiesChunk();
if (propertiesChunk != null)
setVideoBitRate((int) propertiesChunk.getAvgBitrate(video.getStreamNumber()));
// The audio part of the video. (optional)
if (header.getAudioStreamChunk() != null) {
setAudioCodec(header.getAudioStreamChunk().getCodecDescription());
setAudioRate((int) header.getAudioStreamChunk().getSamplingRate());