1 尝试了下CCamera ,打开之后,调用PrepareVideoCaptureL,然后StartVideoCapture。
得到的数据时yuv格式的
/** 4:2:0 format, 8 bits per sample, Y00Y01Y10Y11UV. */
EFormatYUV420Interleaved = 0x0400,
/** 4:2:0 format, 8 bits per sample, Y00Y01Y02Y03...U0...V0... */
EFormatYUV420Planar = 0x0800,
/** 4:2:2 format, 8 bits per sample, UY0VY1. */
EFormatYUV422 = 0x1000,
/** 4:2:2 format, 8 bits per sample, Y1VY0U. */
EFormatYUV422Reversed = 0x2000,
/** 4:4:4 format, 8 bits per sample, Y00U00V00 Y01U01V01... */
EFormatYUV444 = 0x4000,
/** 4:2:0 format, 8 bits per sample, Y00Y01Y02Y03...U0V0... */
EFormatYUV420SemiPlanar = 0x8000,
用YUV Player 是可以播放的,但是是没有音频的。文件也特别的大。
但是可以采集图像。
RGB与YUV的转换
从S60第三版FP2开始,MDF DevVideoRecord API作为SDK API Plug-in的一部分出现了。DevVideoRecord允许对视频解码和预处理进行直接和底层的访问。
传输到解码器的必须是特殊的颜色格式,YUV422或更常见的YUV420(planar),YUV420每个像素有8位luminance (Y),和减少数量的chrominance(U,V)采样,每个都覆盖一个2x2像素区域。在plane模式下,Y,U和V值在内存中被分组为[Y0Y1Y2Y3Y4Y5Y6Y7....U0U1....V0V1],这样增强了图片的压缩率.
下列代码演示了如何将一帧原始RGB(8 bits/channel)转化为YUV420格式。
// Definitions that help access each colour component in source bitmap
#define sR ((TInt32)(s[2]))
#define sG ((TInt32)(s[1]))
#define sB ((TInt32)(s[0]))
#define KImageWidth 176 // QCIF resolution
#define KImageHeigth 144
const TInt KImageNumPixels = KImageWidth * KImageHeigth;
// Lock source bitmap (CFbsBitmap)
iSourceBitmap->LockHeap(EFalse);
TUint8* s = (TUint8*)iSourceBitmap->DataAddress();
TInt i = 0;
TInt ui = KImageNumPixels;
TInt vi = KImageNumPixels + KImageNumPixels/4;
// iYuv is an array of TUint8 values, length (KImageNumPixels*3/2)
for(TInt j=0; j < KImageHeigth; j++)
for(TInt k=0; k < KImageWidth; k++)
{
// Y value is generated for each pixel
iYuv[i] = (TUint8)( ( 66*sR + 129*sG + 25*sB + 128) >> 8 ) + 16;
// U, V values are generated for every other pixel on every other scanline
if(0 == j%2 && 0 == k%2)
{
iYuv[ui++] = (TUint8)( (-38*sR - 74*sG + 112*sB + 128) >> 8 ) + 128;
iYuv[vi++] = (TUint8)( (112*sR - 94*sG - 18*sB + 128) >> 8 ) + 128;
}
i++;
s+=iBytesPerPixel; // Number of bytes representing one pixel in source
// bitmap e.g. if bitmap display mode == EColor16M
// (24bits/pixel), then iBytesPerPixel == 3
}
iSourceBitmap->UnlockHeap(EFalse);
// iYuv now contains the source frame converted to YUV420p format
注意:最新S60设备有多个DevVideoRecord解码用来区分H263和MPEG-4(VSP)编码能力,是硬件加速还是基于软件的编码。一些编码也支持直接从相机捕捉。编码器及能力以及支持的输入格式可以通过编程列出,并选择一个适当的编码器。
http://local.wasp.uwa.edu.au/~pbourke/dataformats/yuv/
2 后来用CVideoRecorderUtility。在诺基亚有例子。
但是还有一个问题:OpenFileL(), OpenFileL()
, OpenUrlL()
, 这三个函数只有OpenFileL()能用,也就是录制的视频数据只能存储在文件中。而想实时传送还有待解决。
用例
|
Symbian C++
|
使用S60媒体播放器和RealPlayer引擎播放本地文件和RTSP流。
|
使用AppArc API(RApaLsSession)启动S60媒体播放器应用。
|
使用定制的用户界面和RealPlayer引擎播放本地文件和RTSP流。
|
创建自己的用户界面并使用CVideoPlayerUtility API播放和控制文件或URL。
|
使用自己的播放器播放本地文件。
|
创建自己的播放器。使用CMdaAudioOutputStream进行音频渲染(1),使用CDirectScreenAccess API 进行视频渲染。
|
使用自己的播放器实施流视频内容。
|
使用network APIs( RSocketServ、RConnection、RSocket) 连接到网络(2)。 然后使用CMdaAudioOutputStream进行音频渲染,使用CDirectScreenAccess API 进行视频渲染。
|