Movie creation problem
Subject : Movie creation problem
From: Roozbeh Zabihollahi <email@hidden >
Date: Thu, 29 Mar 2007 02:18:04 -0700 (PDT)
Delivered-to: email@hidden
Delivered-to: email@hidden
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=rZlcbkhiaWDFhlkve/HZa+6iZlV1Dmx0FBzdtW+ezDzGO5WXuo32M2ojxvOLiW0h0NS3wA6fEbVwdbn5XGmx635bJ7SsgGbXp7BTdVgY8CpFX3BZKU8PjVJ6lgO9Wa5pdcEFlS99aJVi0R117Tgq+mSRNiFOtDRm+kHjp+lfLaw=;
Dear Professionals,
I just start working with Quicktime SDK few days ago.
I am going to write an application to create MOV(s)
and hint them for streaming. I downloaded several
samples from apple website and build them in windows.
However, all of samples I downloaded, create zero size
movies. I attached one simple application which I
wrote it based on quicktime online documentation. I
have not any other idea how I could make it work. It
would be very much appreciated if you help me.
For your information, I am using Quicktime 7.1.5 and
SDK71. I am writing this application in MS-Windows.
Thanks in advance,
* Roozbeh
Roozbeh Zabihollahi
CTO - iPronto Systems
Mobile: +98 912 323 3970
http://www.ipronto.net
____________________________________________________________________________________
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL #if !defined(_MSC_VER) && _WIN32
#include <Win32Headers.mch>
#define TARGET_OS_WIN32 1
#else
#include <ConditionalMacros.h>
#endif
#if TARGET_OS_WIN32
#include <QTML.h>
#define STRICT
#include <windows.h>
#endif
#include "MacTypes.h"
#include "MacMemory.h"
#include "MacErrors.h"
#include "Fonts.h"
#include "QuickDraw.h"
#include "Resources.h"
#include "Gestalt.h"
#include "FixMath.h"
#include "Sound.h"
#include "string.h"
#include "Movies.h"
#include "ImageCompression.h"
#include "Script.h"
#include "TextUtils.h"
#include "Processes.h"
#include <stdio.h>
////#include <Types.h>
//#include <Traps.h>
//#include <Menus.h>
//#include <Memory.h>
////#include <Errors.h>
//#include <Fonts.h>
//#include <QuickDraw.h>
//#include <Resources.h>
////#include <GestaltEqu.h>
//#include <FixMath.h>
//#include <Sound.h>
//#include <string.h>
#include "Movies.h"
#include "ImageCompression.h"
void CheckError(OSErr error, Str255 displayString)
{
if (error == noErr) return;
if (displayString[0] > 0) {
printf("%s Error: %d\n", displayString, error);
}
exit(0);
}
void InitMovieToolbox (void)
{
OSErr err;
err = InitializeQTML(0L);
CheckError (err, "InitializeQTML error" );
err = EnterMovies ();
CheckError (err, "EnterMovies" );
}
#define kMyCreatorType 'TVOD' /* Sample Player's creator type, the
movie player of choice. You can
also use your own creator type. */
#define kPrompt "Enter movie file name"
#define kVideoTimeScale 600
#define kTrackStart 0
#define kMediaStart 0
#define kFix1 0x00010000
#define kSampleDuration 240
/* video frames last 240 * 1/600th of a second */
#define kNumVideoFrames 29
#define kNoOffset 0
#define kMgrChoose 0
#define kSyncSample 0
#define kAddOneVideoSample 1
#define kPixelDepth 16
#define SAMPLE_FILE_NAME ".test.mov"
void DrawFrame (const Rect *trackFrame, long curSample)
{
Str255 numStr;
ForeColor( redColor );
PaintRect( trackFrame );
ForeColor( blueColor );
NumToString (curSample, numStr);
MoveTo ( trackFrame->right / 2, trackFrame->bottom / 2);
TextSize ( trackFrame->bottom / 3);
DrawString (numStr);
}
void AddVideoSamplesToMedia (Media theMedia,
const Rect *trackFrame)
{
long maxCompressedSize;
GWorldPtr theGWorld = nil;
long curSample;
Handle compressedData = nil;
Ptr compressedDataPtr;
ImageDescriptionHandle imageDesc = nil;
CGrafPtr oldPort;
GDHandle oldGDeviceH;
OSErr err = noErr;
err = NewGWorld (&theGWorld,
16, /* pixel depth */
trackFrame,
nil,
nil,
(GWorldFlags) 0 );
CheckError (err, "NewGWorld");
LockPixels (theGWorld->portPixMap);
err = GetMaxCompressionSize (theGWorld->portPixMap,
trackFrame,
0, /* let ICM choose depth */
codecNormalQuality,
kJPEG2000CodecType,
(CompressorComponent) anyCodec,
&maxCompressedSize);
CheckError (err, "GetMaxCompressionSize" );
compressedData = NewHandle(maxCompressedSize);
CheckError( MemError(), "NewHandle" );
MoveHHi( compressedData );
HLock( compressedData );
compressedDataPtr = StripAddress( *compressedData );
imageDesc = (ImageDescriptionHandle)NewHandle(4);
CheckError( MemError(), "NewHandle" );
GetGWorld (&oldPort, &oldGDeviceH);
SetGWorld (theGWorld, nil);
for (curSample = 1; curSample < 30; curSample++)
{
EraseRect (trackFrame);
DrawFrame(trackFrame, curSample);
err = CompressImage (theGWorld->portPixMap,
trackFrame,
codecNormalQuality,
kJPEG2000CodecType,
imageDesc,
compressedDataPtr );
CheckError( err, "CompressImage" );
err = AddMediaSample(theMedia,
compressedData,
0, /* no offset in data */
(**imageDesc).dataSize,
60, /* frame duration = 1/10 sec */
(SampleDescriptionHandle)imageDesc,
1, /* one sample */
0, /* self-contained samples */
nil);
CheckError( err, "AddMediaSample" );
}
SetGWorld (oldPort, oldGDeviceH);
if (imageDesc) DisposeHandle ((Handle)imageDesc);
if (compressedData) DisposeHandle (compressedData);
if (theGWorld) DisposeGWorld (theGWorld);
}
void CreateMyVideoTrack (Movie theMovie)
{
Track theTrack;
Media theMedia;
OSErr err = noErr;
Rect trackFrame = {0,0,100,320};
theTrack = NewMovieTrack (theMovie,
FixRatio(trackFrame.right,1),
FixRatio(trackFrame.bottom,1),
kNoVolume);
CheckError( GetMoviesError(), "NewMovieTrack" );
{
OSType dataRefType;
Handle dataRef = nil;
Handle hMovieData = NewHandle(100);
// Construct the Handle data reference
err = PtrToHand( &hMovieData, &dataRef, sizeof(Handle));
CheckError( err, "PtrToHand" );
theMedia = NewTrackMedia (theTrack, VideoMediaType,
600, // Video Time Scale
dataRef, HandleDataHandlerSubType);
CheckError( GetMoviesError(), "NewTrackMedia" );
}
err = BeginMediaEdits (theMedia);
CheckError( err, "BeginMediaEdits" );
AddVideoSamplesToMedia (theMedia, &trackFrame);
err = EndMediaEdits (theMedia);
CheckError( err, "EndMediaEdits" );
err = InsertMediaIntoTrack (theTrack, 0, /* track start time */
GetMediaDuration (theMedia), /* media start time */
GetMediaDuration (theMedia),
kFix1);
CheckError( err, "InsertMediaIntoTrack" );
}
void CreateMyCoolMovie (void)
{
Point where = {100,100};
//SFReply theSFReply;
Movie theMovie = nil;
FSSpec mySpec;
short resRefNum = 0;
short resId = 0;
OSErr err = noErr;
//SFPutFile (where, "Enter movie file name",
// "Movie File", nil, &theSFReply);
//if (!theSFReply.good) return;
//FSMakeFSSpec(2, 0,
// SAMPLE_FILE_NAME, &mySpec);
mySpec.vRefNum = 1;
mySpec.parID = 1;
strcpy(mySpec.name, SAMPLE_FILE_NAME); /* a Str63 on MacOS*/
err = CreateMovieFile (&mySpec,
FOUR_CHAR_CODE('TVOD'),
smCurrentScript,
createMovieFileDeleteCurFile,
&resRefNum,
&theMovie );
CheckError(err, "CreateMovieFile");
CreateMyVideoTrack (theMovie);
//CreateMySoundTrack (theMovie);
err = AddMovieResource (theMovie, resRefNum, &resId,
SAMPLE_FILE_NAME);
CheckError(err, "AddMovieResource");
if (resRefNum) CloseMovieFile (resRefNum);
DisposeMovie (theMovie);
}
#if 0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
#endif
int main(int agrv, char **argc)
{
printf("%s:%d\n" , __FILE__, __LINE__);
InitMovieToolbox ();
printf("%s:%d\n" , __FILE__, __LINE__);
CreateMyCoolMovie ();
printf("%s:%d\n" , __FILE__, __LINE__);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.