Hi dear community,<br> I have a problem with the encoding using x264. After I call x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out) function I have nal= NULL, i_nal=0 and the function return 0. I'm sure that pic contain the correct image. The x264_t h is open using the default parameters, i only change width and length of the video. The function don't give me any error, it seems that it not encode any data. I include the code of encoding function that I implement watching x264.c.<br>
<br>void MyFunction()<br>{<br> x264_param_t param;<br> x264_t *h;<br> x264_picture_t pic;<br><br> //Set the default parameters<br> x264_param_default( &param );<br><br> //Video settings<br> param->i_width = WIDTH;<br>
param->i_height = HEIGHT;<br><br> //Open the encoder<br> if( ( h = x264_encoder_open( &param ) ) == NULL )<br> {<br> fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" );<br>
return -1;<br> }<br><br> /* Create a new pic */<br> x264_picture_alloc( &pic, X264_CSP_I420, param.i_width, param.i_height );<br><br> //Launch the encode routine <br> Encode_frame( h , &pic );<br>
<br> //Release resoirce<br> x264_picture_clean( &pic );<br> x264_encoder_close(h);<br>}<br><br>int Encode_frame( x264_t *h , x264_picture_t *pic)<br>{<br> x264_nal_t *nal;<br> int i_nal, i;<br> x264_picture_t pic_out;<br>
static int mux_buffer_size = 0;<br> uint8_t *mux_buffer = NULL;<br> int size;<br><br> //Set YUV420<br> pic->img.i_csp = X264_CSP_I420;<br> pic->img.i_plane = 3;<br><br> //I take the YUV image from a decoded image decode with ffmpeg<br>
if (picture) {<br> for(i = 0; i < 3; i++){<br> pic->img.plane[i] = picture->data[i];<br> pic->img.i_stride[i] = picture->linesize[i];<br> }<br><br>
pic->i_pts = picture->pts;<br> pic->i_type = X264_TYPE_AUTO;<br> }<br> <br> //pic contains the correct image. <br> if( (i = x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out)) <0)<br>
return -1; <br><br> /*<br> * In this point nal is null, i_nal is 0. There isn't any error message in the routine.<br> * As consequence the next loop don't execute any step.<br>
*/ <br> <br><br> //packetize the encoded information in nal unit<br> for( i = 0; i < i_nal; i++ )<br> {<br> int i_size;<br><br> printf("\nNal unit n° %d",i);<br>
<br> if( mux_buffer_size < nal[i].i_payload * 3/2 + 4 )<br> {<br> mux_buffer_size = nal[i].i_payload * 2 + 4;<br> free( (void*) mux_buffer );<br> mux_buffer = (uint8_t*) malloc( mux_buffer_size );<br>
}<br><br> size = size + mux_buffer_size;<br> i_size = mux_buffer_size;<br> x264_nal_encode( mux_buffer, &i_size, 1, &nal[i] );<br> write_nal_unit( mux_buffer , i_size ,"outframe.mpeg4" );<br>
}<br><br> return size;<br>}<br><br>I'm excuse in advance. I'm not sure that is the correct mailing list (if not is very appreciated if suggest me what mailing list is the right).<br>Many thanks.