-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcencodhelper.cpp
More file actions
42 lines (35 loc) · 823 Bytes
/
cencodhelper.cpp
File metadata and controls
42 lines (35 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "cencodhelper.h"
#include <iostream>
CEncodeHelper::CEncodeHelper(AVCodecContext *pAVCodecCtx) : m_pAVCodecCtx(pAVCodecCtx)
{
Init();
}
bool CEncodeHelper::Encode(AVFrame* pFrame, AVPacket* pAVPacket)
{
bool bRet = false;
if ( 0 != avcodec_send_frame(m_pAVCodecCtx, pFrame) )
{
std::cerr<<"avcodec_send_frame failed. "<<std::endl;
bRet = false;
}
//获取编码结果保存到输出流
int iRet = 0;
iRet = avcodec_receive_packet(m_pAVCodecCtx, pAVPacket);
switch(iRet)
{
case 0:
bRet = true;
break;
case AVERROR(EAGAIN):
bRet = false;
break;
default:
std::cout << "avcodec_receive_packet error."<< std::endl;
bRet = false;
break;
}
return bRet;
}
void CEncodeHelper::Init()
{
}