The Stage Fright

Tom was sick with disappointment. The piano recital was successful except his solo. He didn't know how it was going. In fact, He had practised for several weeks seeming like several mouths. He has given up the sports until the recital was over. His teacher said that he was gifted, and indeed he had accepted the piano as another language to express himself. All his families----his grandparents, uncle, aunt, parents, had come to watch his performance. The sat in the audience and smiled back at him. He wanted to make them proud of him.

Just as he went up to the stage. He began to feel anxious. He mouth was dry. His finger began to tremble and the trembling became uncontrollable shake.His legs felt so weak. Just as he sat down at the piano. He took a deep breathe. After playing the first five bars of the piano, he found he had forgotten the rest.He began to recall,but it didn't help. Then he walked down the stage in a slow motion. The demon stage fright had left a brilliant music career in ruins.

------------------------------------------------------------

Everyday a little story to practise English.

以下是使用android av中的kKeyIsSyncFrame在编码时的完整代码示例: ``` #include <media/stagefright/MediaCodec.h> #include <media/stagefright/MediaCodecList.h> #include <media/stagefright/MediaFormat.h> #include <media/stagefright/Utils.h> ... const char *mime = "video/avc"; int32_t width = 1280; int32_t height = 720; int32_t bitrate = 2000000; int32_t frameRate = 30; int32_t iFrameInterval = 1; // Find a suitable encoder. sp<MediaCodecList> list = MediaCodecList::getInstance(); sp<MediaCodecInfo> info = list->findEncoderByType(mime); if (info == NULL) { // No suitable encoder found. return; } // Create a MediaFormat with the desired settings. sp<MediaFormat> format = MediaFormat::Create(); format->setCString(kKeyMIMEType, mime); format->setInt32(kKeyWidth, width); format->setInt32(kKeyHeight, height); format->setInt32(kKeyBitRate, bitrate); format->setInt32(kKeyFrameRate, frameRate); format->setInt32(kKeyIFramesInterval, iFrameInterval); // Create a MediaCodec for encoding. sp<MediaCodec> encoder = MediaCodec::CreateByInfo( env, info, false /* encoder */, NULL /* crypto */); encoder->configure(format.get(), NULL /* surface */, NULL /* crypto */, MediaCodec::CONFIGURE_FLAG_ENCODE); encoder->start(); // Start encoding. bool sawInputEOS = false; bool sawOutputEOS = false; while (!sawOutputEOS) { if (!sawInputEOS) { ssize_t inputBufIndex = encoder->dequeueInputBuffer(kTimeoutUs); if (inputBufIndex >= 0) { sp<MediaCodecBuffer> inputBuf = encoder->getInputBuffer(inputBufIndex); // Read input data into the buffer. ... // Set kKeyIsSyncFrame metadata if this is a key frame. bool isKeyFrame = ...; if (isKeyFrame) { inputBuf->meta_data()->setInt32(kKeyIsSyncFrame, 1); } else { inputBuf->meta_data()->setInt32(kKeyIsSyncFrame, 0); } encoder->queueInputBuffer( inputBufIndex, 0 /* offset */, sampleSize, presentationTimeUs, flags); } } MediaCodecBuffer *outBuf = NULL; MediaCodec::BufferInfo outInfo; ssize_t outBufIndex = encoder->dequeueOutputBuffer(&outBuf, &outInfo, kTimeoutUs); if (outBufIndex >= 0) { if (outInfo.flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) { sawOutputEOS = true; } // Handle the output data. ... encoder->releaseOutputBuffer(outBufIndex, outInfo.size != 0); } else if (outBufIndex == MediaCodec::INFO_OUTPUT_BUFFERS_CHANGED) { // The output buffers have changed, we need to get a new set. } else if (outBufIndex == MediaCodec::INFO_OUTPUT_FORMAT_CHANGED) { // The output format has changed, we need to use the new format. sp<MetaData> newFormat = encoder->getOutputFormat(); format = MediaFormat::FromMetaData(newFormat.get()); } } // Stop and release the encoder. encoder->stop(); encoder->release(); ``` 在上述代码中,当编码视频帧时,如果该帧是关键帧,则会将`kKeyIsSyncFrame`元数据设置为1,否则设置为0,以便在解码后进行使用。注意,具体判断是否为关键帧的逻辑需要根据具体的编码器实现进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值