264解码的时候 ,无法知道视频过来的信息,比如视频的尺寸,我该如何处理
264解码的时候 ,无法知道视频过来的信息,比如视频的尺寸,我该如何处理。
已x264为基础,初始化时,似乎必须传视频的尺寸信息的。
[解决办法]
264的标准码流通过264的码流分析库是可以分析出宽高的,帧率是没办法的,一般码流里面是没有这个信息的。
[解决办法]
推荐你用MediaInfo的DLL,可以得到所有的文件信息,包括视频的高和宽等等,具体函数是MediaInfo_Get,Google一下就知道了:)希望有用
[解决办法]
代码是这样子的:你只需要网上下载个MdeiaInfo.dll
#include "stdafx.h"
#include <windows.h>
typedef enum MediaInfo_stream_t
{
MediaInfo_Stream_General,
MediaInfo_Stream_Video,
MediaInfo_Stream_Audio,
MediaInfo_Stream_Text,
MediaInfo_Stream_Chapters,
MediaInfo_Stream_Image,
MediaInfo_Stream_Menu,
MediaInfo_Stream_Max
} MediaInfo_stream_C;
/** @brief Kinds of Info */
typedef enum MediaInfo_info_t
{
MediaInfo_Info_Name,
MediaInfo_Info_Text,
MediaInfo_Info_Measure,
MediaInfo_Info_Options,
MediaInfo_Info_Name_Text,
MediaInfo_Info_Measure_Text,
MediaInfo_Info_Info,
MediaInfo_Info_HowTo,
MediaInfo_Info_Max
} MediaInfo_info_C;
/** @brief Option if InfoKind = Info_Options */
typedef enum MediaInfo_infooptions_t
{
MediaInfo_InfoOption_ShowInInform,
MediaInfo_InfoOption_Reserved,
MediaInfo_InfoOption_ShowInSupported,
MediaInfo_InfoOption_TypeOfValue,
MediaInfo_InfoOption_Max
} MediaInfo_infooptions_C;
/** @brief File opening options */
typedef enum MediaInfo_fileoptions_t
{
MediaInfo_FileOption_Nothing =0x00,
MediaInfo_FileOption_NoRecursive =0x01,
MediaInfo_FileOption_CloseAll =0x02,
MediaInfo_FileOption_Max =0x04
} MediaInfo_fileoptions_C;
int _tmain(int argc, _TCHAR* argv[])
{
HINSTANCE hInstance = LoadLibrary(_T("MediaInfo.dll"));
if (hInstance == NULL)
printf("Failed at LoadLibrary\n");
typedef void* (WINAPI *FUNC_NEW)(void);
FUNC_NEW MediaInfo_New;
MediaInfo_New = (FUNC_NEW)GetProcAddress(hInstance, "MediaInfo_New");
if (MediaInfo_New == NULL)
printf ("Failed at MediaInfo_New\n");
HANDLE handle = (*MediaInfo_New)();
typedef size_t (WINAPI *FUNC_OPEN)(void*, const wchar_t*);
FUNC_OPEN MediaInfo_Open = (FUNC_OPEN)GetProcAddress(hInstance, "MediaInfo_Open");
if (MediaInfo_Open == NULL)
printf ("Failed at MediaInfo_Open\n");
(*MediaInfo_Open)(handle, _T("C:\\Documents and Settings\\gxu18\\My Documents\\My Videos\\Hot.Summer.Days.2010.CN.DVDRip.Xvid-XTM\\xtm-hsd.avi"));
typedef wchar_t* (WINAPI *FUNC_INFORM)(void*, size_t);
FUNC_INFORM MediaInfo_Inform = (FUNC_INFORM)GetProcAddress(hInstance, "MediaInfo_Inform");
if (MediaInfo_Inform == NULL)
printf ("Failed at MediaInfo_Inform\n");
wprintf(_T("%s\n"), (*MediaInfo_Inform)(handle, 0));
typedef wchar_t* (WINAPI *FUNC_GET)(void*, MediaInfo_stream_t, size_t, const wchar_t*, MediaInfo_info_C, MediaInfo_info_C);
FUNC_GET MediaInfo_Get = (FUNC_GET)GetProcAddress(hInstance, "MediaInfo_Get");
if (MediaInfo_Get == NULL)
printf ("Failed at MediaInfo_Open\n");
wprintf(_T("%s\n"), (*MediaInfo_Get)(handle, MediaInfo_Stream_Video, 0, _T("Width"), MediaInfo_Info_Text, MediaInfo_Info_Name));
wprintf(_T("%s\n"), (*MediaInfo_Get)(handle, MediaInfo_Stream_Video, 0, _T("Height"), MediaInfo_Info_Text, MediaInfo_Info_Name));
typedef void (WINAPI *FUNC_CLOSE)(void*);
FUNC_CLOSE MediaInfo_Close = (FUNC_CLOSE)GetProcAddress(hInstance, "MediaInfo_Close");
if (MediaInfo_Close == NULL)
printf ("Failed at MediaInfo_Close\n");
(*MediaInfo_Close)(handle);
typedef void (WINAPI *FUNC_DELETE)(void*);
FUNC_DELETE MediaInfo_Delete = (FUNC_DELETE)GetProcAddress(hInstance, "MediaInfo_Delete");
if (MediaInfo_Delete == NULL)
printf ("Failed at MediaInfo_Delete\n");
(*MediaInfo_Delete)(handle);
system("pause");
return 0;
}
[解决办法]
看SPS, PPS