如何取得AVI文件的画面尺寸、比特率、编码器、时间长度等信息?

amfer 2005-12-22 04:21:34
如题!

有个小工具叫FourCC Code Changer是用来改编码格式的,xvid可以改成divx或者Div4等,很简单的几句,这些信息就写在avi文件的某个地方。
...全文
604 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
amfer 2005-12-23
  • 打赏
  • 举报
回复
真的只有幾句,可能Divx和Xvid本來相差就不多吧,都可以相互解碼:
這是打開文件的代碼(Delphi)
If OpenDialog.Execute = True then
Begin
SetLength(S,4);
AssignFile(F,OpenDialog.FileName);
{$I-}
Reset(F,1);
{$I+}
If IOResult = 0 then
Begin
Seek(F,$70);
BlockRead(F,S[1],4);
FourCCDesc.Text := S;
Seek(F,$BC);
BlockRead(F,S[1],4);
FourCCCodec.Text := S;
AVIName.Text := ExtractFileName(OpenDialog.FileName);
AVIName.Hint := OpenDialog.FileName;
ApplyButton.Enabled := True;
CloseFile(F);
End
else
Begin
MessageDLG('Unable to open file, might be read-only.',mtError,[mbok],0);
End;
End;
這是更改Codec的代碼
If (Length(FourCCDesc.Text) = 4) and (Length(FourCCCodec.Text) = 4) then
Begin
AssignFile(F,OpenDialog.FileName);
Reset(F,1);
Seek(F,$70);
S := FourCCDesc.Text;
BlockWrite(F,S[1],4);
Seek(F,$BC);
S := FourCCCodec.Text;
BlockWrite(F,S[1],4);
CloseFile(F);
MessageDLG('FourCC code for ['+OpenDialog.Filename+'] has been set.',mtInformation,[mbok],0);
End
else
Begin
MessageDLG('FourCC code must be 4-Characters long, duh!',mtError,[mbok],0);
End;

這裡有完整的程序:http://files.divx-digest.com/software/edit/avic100.zip
constantine 2005-12-22
  • 打赏
  • 举报
回复
STDAPI AVIFileInfo(

PAVIFILE pfile,
AVIFILEINFO * pfi,
LONG lSize
);

The AVIFILEINFO structure contains global information for an entire AVI file.

typedef struct {
DWORD dwMaxBytesPerSec;
DWORD dwFlags;
DWORD dwCaps;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwLength;
DWORD dwEditCount;
char szFileType[64];
} AVIFILEINFO;


Members

dwMaxBytesPerSec

Approximate maximum data rate of the AVI file.

dwFlags

Applicable flags. The following flags are defined:

AVIFILEINFO_HASINDEX

The AVI file has an index at the end of the file. For good performance, all AVI files should contain an index.

AVIFILEINFO_MUSTUSEINDEX

The file index contains the playback order for the chunks in the file. Use the index rather than the physical ordering of the chunks when playing back the data. This could be used for creating a list of frames for editing.

AVIFILEINFO_ISINTERLEAVED

The AVI file is interleaved.

AVIFILEINFO_WASCAPTUREFILE

The AVI file is a specially allocated file used for capturing real-time video. Applications should warn the user before writing over a file with this flag set because the user probably defragmented this file.

AVIFILEINFO_COPYRIGHTED

The AVI file contains copyrighted data and software. When this flag is used, software should not permit the data to be duplicated.

dwCaps

Capability flags. The following flags are defined:

AVIFILECAPS_CANREAD

An application can open the AVI file with with the read privilege.

AVIFILECAPS_CANWRITE

An application can open the AVI file with the write privilege.

AVIFILECAPS_ALLKEYFRAMES

Every frame in the AVI file is a key frame.

AVIFILECAPS_NOCOMPRESSION

The AVI file does not use a compression method.

dwStreams

Number of streams in the file. For example, a file with audio and video has at least two streams.

dwSuggestedBufferSize

Suggested buffer size, in bytes, for reading the file. Generally, this size should be large enough to contain the largest chunk in the file. For an interleaved file, this size should be large enough to read an entire record, not just a chunk.
If the buffer size is too small or is set to zero, the playback software will have to reallocate memory during playback, reducing performance.

dwWidth

Width, in pixels, of the AVI file.

dwHeight

Height, in pixels, of the AVI file.

dwScale

Time scale applicable for the entire file. Dividing dwRate by dwScale gives the number of samples per second.
Any stream can define its own time scale to supersede the file time scale.

dwLength

Length of the AVI file. The units are defined by dwRate and dwScale.

dwEditCount

Number of streams that have been added to or deleted from the AVI file.

szFileType

Null-terminated string containing descriptive information for the file type.


简单几句我倒很怀疑啊,avi只是一个容器,实际上格式很多种,采用不同压缩说法差别有可能比较大,你说的几句是多少句,简单修改一下rate之类的倒是比较简单
ccrun.com 2005-12-22
  • 打赏
  • 举报
回复
搜索AVIFileInfo

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧