- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since an avi file can contain almost any video compression method, and mp4 files can be a couple of different compression methods, as can mpg files, how do I tell what the video compression method is in a file?
Thanks for any help you can provide.
dabbler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First step is to identify what kind of file you're dealing with [it's cheating to rely exclusively on the file extension]. That will help you choose your splitter. Then determine what kind of compression is used, and that will help you choose your decoder.
To identify what kind of stream you're dealing with, model your code on the following:
UMC::FIOReader reader;
...
UMC::Splitter *splitter;
UMC::SystemStreamType streamType = UMC::Splitter::GetStreamType();
switch (streamType)
{
case UMC::MP4_ATOM_STREAM :
splitter = (UMC::Splitter*)(new UMC::MP4Splitter());
break;
case UMC::MPEGx_SYSTEM_STREAM :
splitter = (UMC::Splitter*)(new UMC::ThreadedDemuxer());
break;
default :
printf("Unknown stream type 0x%X\n", streamType);
break;
}
...
// search tracks for supported video data
for (videoTrack = 0; videoTrack < splitterInfo->m_nOfTracks; videoTrack++)
if (splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_MPEG4V ||
splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_H264 ||
splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_MPEG2V)
break;
// if no track with supported video data found
if (videoTrack >= splitterInfo->m_nOfTracks)
{
str.Format("VideoThread %s file does not contain video TRACK_MPEG4V or TRACK_H264 or TRACK_MPEG2V", (LPCTSTR)m_strStreamDisplayPath);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
...
UMC::VideoDecoder *decoder;
switch (videoTrackInfo->stream_type)
{
case UMC::MPEG4_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::MPEG4VideoDecoder());
break;
case UMC::H264_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::H264VideoDecoder());
break;
case UMC::MPEG2_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::MPEG2VideoDecoder());
break;
default :
str.Format("VideoThread %s unknown video stream_type 0x%X", (LPCTSTR)m_strStreamDisplayPath, videoTrackInfo->stream_type);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
Or for audio:
// search tracks for supported audio data
Ipp32u audioTrack;
for (audioTrack = 0; audioTrack < splitterInfo->m_nOfTracks; audioTrack++)
if (splitterInfo->m_ppTrackInfo[audioTrack]->m_Type == UMC::TRACK_AAC ||
splitterInfo->m_ppTrackInfo[audioTrack]->m_Type == UMC::TRACK_MPEGA)
break;
// if no track with supported audio data found
if (audioTrack >= splitterInfo->m_nOfTracks)
{
str.Format("AudioThread %s file does not contain audio TRACK_AAC or TRACK_MPEGA", (LPCTSTR)m_strStreamDisplayPath);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
UMC::AudioStreamInfo *audioTrackInfo = (UMC::AudioStreamInfo *)splitterInfo->m_ppTrackInfo[audioTrack]->m_pStreamInfo;
...
UMC::AudioCodec *audio;
UMC::MediaBuffer *media;
switch (audioTrackInfo->stream_type)
{
case UMC::AAC_AUDIO :
case UMC::AAC_MPEG4_STREAM :
audio = (UMC::AudioCodec*)(new UMC::AACDecoder());
media = (UMC::MediaBuffer*)(new UMC::SampleBuffer());
break;
case UMC::MP1L1_AUDIO :
case UMC::MP1L2_AUDIO :
case UMC::MP1L3_AUDIO :
case UMC::MP2L1_AUDIO :
case UMC::MP2L2_AUDIO :
case UMC::MP2L3_AUDIO :
audio = (UMC::AudioCodec*)(new UMC::MP3Decoder);
media = (UMC::MediaBuffer*)(new UMC::LinearBuffer());
break;
default :
str.Format("AudioThread %s unknown audio stream_type 0x%X", (LPCTSTR)m_strStreamDisplayPath, audioTrackInfo->stream_type);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First step is to identify what kind of file you're dealing with [it's cheating to rely exclusively on the file extension]. That will help you choose your splitter. Then determine what kind of compression is used, and that will help you choose your decoder.
To identify what kind of stream you're dealing with, model your code on the following:
UMC::FIOReader reader;
...
UMC::Splitter *splitter;
UMC::SystemStreamType streamType = UMC::Splitter::GetStreamType();
switch (streamType)
{
case UMC::MP4_ATOM_STREAM :
splitter = (UMC::Splitter*)(new UMC::MP4Splitter());
break;
case UMC::MPEGx_SYSTEM_STREAM :
splitter = (UMC::Splitter*)(new UMC::ThreadedDemuxer());
break;
default :
printf("Unknown stream type 0x%X\n", streamType);
break;
}
...
// search tracks for supported video data
for (videoTrack = 0; videoTrack < splitterInfo->m_nOfTracks; videoTrack++)
if (splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_MPEG4V ||
splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_H264 ||
splitterInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_MPEG2V)
break;
// if no track with supported video data found
if (videoTrack >= splitterInfo->m_nOfTracks)
{
str.Format("VideoThread %s file does not contain video TRACK_MPEG4V or TRACK_H264 or TRACK_MPEG2V", (LPCTSTR)m_strStreamDisplayPath);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
...
UMC::VideoDecoder *decoder;
switch (videoTrackInfo->stream_type)
{
case UMC::MPEG4_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::MPEG4VideoDecoder());
break;
case UMC::H264_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::H264VideoDecoder());
break;
case UMC::MPEG2_VIDEO :
decoder = (UMC::VideoDecoder*)(new UMC::MPEG2VideoDecoder());
break;
default :
str.Format("VideoThread %s unknown video stream_type 0x%X", (LPCTSTR)m_strStreamDisplayPath, videoTrackInfo->stream_type);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
Or for audio:
// search tracks for supported audio data
Ipp32u audioTrack;
for (audioTrack = 0; audioTrack < splitterInfo->m_nOfTracks; audioTrack++)
if (splitterInfo->m_ppTrackInfo[audioTrack]->m_Type == UMC::TRACK_AAC ||
splitterInfo->m_ppTrackInfo[audioTrack]->m_Type == UMC::TRACK_MPEGA)
break;
// if no track with supported audio data found
if (audioTrack >= splitterInfo->m_nOfTracks)
{
str.Format("AudioThread %s file does not contain audio TRACK_AAC or TRACK_MPEGA", (LPCTSTR)m_strStreamDisplayPath);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
UMC::AudioStreamInfo *audioTrackInfo = (UMC::AudioStreamInfo *)splitterInfo->m_ppTrackInfo[audioTrack]->m_pStreamInfo;
...
UMC::AudioCodec *audio;
UMC::MediaBuffer *media;
switch (audioTrackInfo->stream_type)
{
case UMC::AAC_AUDIO :
case UMC::AAC_MPEG4_STREAM :
audio = (UMC::AudioCodec*)(new UMC::AACDecoder());
media = (UMC::MediaBuffer*)(new UMC::SampleBuffer());
break;
case UMC::MP1L1_AUDIO :
case UMC::MP1L2_AUDIO :
case UMC::MP1L3_AUDIO :
case UMC::MP2L1_AUDIO :
case UMC::MP2L2_AUDIO :
case UMC::MP2L3_AUDIO :
audio = (UMC::AudioCodec*)(new UMC::MP3Decoder);
media = (UMC::MediaBuffer*)(new UMC::LinearBuffer());
break;
default :
str.Format("AudioThread %s unknown audio stream_type 0x%X", (LPCTSTR)m_strStreamDisplayPath, audioTrackInfo->stream_type);
AfxMessageBox(str);
splitter->Stop();
splitter->Close();
reader.Close();
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Frank,
Thanks for the quick repsonse. I have been trying to figure this out for several days. We are all stuck at home (Virginia) in the snow today, so I will try to get the code running at work tomorrow.
Thanks again,
dabbler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page