Problem in creating mov file from MPEG4 data
Problem in creating mov file from MPEG4 data
- Subject: Problem in creating mov file from MPEG4 data
- From: "Rajani Bhandari" <email@hidden>
- Date: Sat, 18 Feb 2006 12:34:29 +0530
- Importance: Normal
Hello All,
I am trying to create a movie from the MPEG4 compressed data. My code is
creating two files by name "ExportedFi.#res" and "ExportedFi" instead of
actual name "test.mov". Below is the code snippet. Please let me know
where, I am going wrong in creating movie file from MPEG-4 data.
CreateMovie()
{
OSErr err = 0;
StandardFileReply sfr;
memset((void*)&sfr, 0, sizeof(StandardFileReply));
err = NativePathNameToFSSpec("C:\\TestDir\\Test.mov",
&sfr.sfFile, 0);
if (err != noErr)
{
// print log and return;
return false;
}
err = CreateMovieFile (&sfr.sfFile,
FOUR_CHAR_CODE('mp4v'),
smCurrentScript,
createMovieFileDeleteCurFile|createMovieFileDontCreateResFile,
&m_nFileRefNum,
&m_cMovie);
if (err != noErr)
{
// print log and return;
return ;
}
Rect trackFrame = {0,0,720, 416};
m_cTrack = NewMovieTrack (m_cMovie,
FixRatio(trackFrame.right,1),
FixRatio(trackFrame.bottom,1),
kNoVolume);
err = GetMoviesError();
if(err != noErr)
{
// display message and log it
}
m_cMedia = NewTrackMedia (m_cTrack, MPEGMediaType,
900, // Video Time Scale
NULL, 0);
err = BeginMediaEdits (m_cMedia);
AddVideoSampleToMedia ();
err = EndMediaEdits (m_cMedia);
err = InsertMediaIntoTrack (m_cTrack, 0,/* track start time */
0,
GetMediaDuration (m_cMedia),
0x00010000);
short resId = 0;
err = AddMovieResource(m_cMovie,
m_nFileRefNum,
&resId,
NULL);
if (m_nFileRefNum !=0)
CloseMovieFile(m_nFileRefNum);
return true;
}
bool AddVideoSampleToMedia()
{
CodecNameSpecList *ls = new CodecNameSpecList;;
OSErr err = GetCodecNameList (&ls,0);
unsigned char* buf;
buf = GetEncodedMPEGData();
Handle Data = NULL;
Data = NewHandle(9555801);
Ptr DataPtr;
DataPtr = *Data;
memcpy(DataPtr, buf, 9555801);
ImageDescriptionHandle imageDesc = NULL;
long mySize = sizeof(ImageDescription);
imageDesc =(ImageDescriptionHandle)NewHandle(mySize);
(**imageDesc).idSize = mySize;
(**imageDesc).cType = kMPEG4VisualCodecType;
(**imageDesc).resvd1 = 0;
(**imageDesc).resvd2 = 0;
(**imageDesc).dataRefIndex = 0;
(**imageDesc).version = 2;
(**imageDesc).revisionLevel = 0;
(**imageDesc).vendor = 0;
(**imageDesc).temporalQuality = codecNormalQuality;
(**imageDesc).spatialQuality = codecNormalQuality;
(**imageDesc).width = 720;
(**imageDesc).height = 416;
(**imageDesc).hRes = 1;
(**imageDesc).vRes = 1;
(**imageDesc).dataSize = 0;
(**imageDesc).frameCount = 744;
strcpy((char*)(**imageDesc).name, (const
char*)ls->list[15].typeName);
(**imageDesc).depth = 31;
(**imageDesc).clutID = -1;;
err = AddMediaSample(m_cMedia,
Data,
0, // offset in data
9555801,
90, // duration of each sample
(SampleDescriptionHandle)imageDesc,
744,
0, // self-contained samples
NULL);
err = GetMoviesError();
if (imageDesc) DisposeHandle ((Handle)imageDesc);
return true;
}
Thanks
Rajani
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden