Click here to Skip to main content
11,480,701 members (49,025 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Video
is this right to use the new x264 api ,i want to get a frame ,and encode it with x264,then save it to a .264 file?
but i do not know is this is right ?
        
picIn.img.plane[0] = pInBuffer ;
picIn.img.plane[1] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight ;
picIn.img.plane[2] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight*5/4 ;
 
picIn.img.i_stride[0] = m_VideoEncParam.nWidth ;
picIn.img.i_stride[1] = m_VideoEncParam.nWidth /2 ;
picIn.img.i_stride[2] = m_VideoEncParam.nWidth /2 ;
 
nRet = x264_encoder_encode(
    m_pX264Handle,
    &pNal,
    &nNalCount,
    &picIn,
    &picOut);
if (nRet<0)
{
    return -1 ;
}
	
for (int i = 0 ;i<nNalCount;i++);	
{
    
    x264_nal_encode(m_pX264Handle,pOutBuffer+nLenOut,&pNal[i]);
    nLenOut += pNal[i].i_payload ;
}
int nSize = 0 ;
FILE *pFile = fopen(pchFileName,"w") ;
if (!pFile)
{
    return -1 ;
}
nSize = fwrite(pOutBuffer,1,nLenOut,pFile) ;
fclose(pFile) ;

[EDIT: Added pre tags to format code and reduced indentation]
Posted 21-Apr-13 22:59pm
Edited 21-Apr-13 23:14pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i have solve this problem thank you everyone
  Permalink  
Comments
Maximilien at 22-Apr-13 10:33am
   
What was the problem and what did you do to fix it ?
chinahyin at 22-Apr-13 10:35am
   
the lastes x264 have maken the x264_nal_encode private so i do not have to use it
merano at 22-Apr-13 11:41am
   
Google says: You don't need to call x264_nal_encode because x264_encoder_encode return already encoded nals.
chinahyin at 2-May-13 5:35am
   
thank you very much that is the reasons

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 294
1 OriginalGriff 145
2 CHill60 130
3 CPallini 125
4 Richard MacCutchan 75
0 Sergey Alexandrovich Kryukov 8,184
1 OriginalGriff 7,586
2 Sascha Lefèvre 3,114
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100