Note that there are some explanatory texts on larger screens.

plurals
  1. POwrite x264_encoder_encode output nals to h264 file
    primarykey
    data
    text
    <p>I'm trying to do a life stream software. What I'm trying is to use x264's lib to encode to h264 on server side and ffmpeg to decode on client side. After some failed attemps of doing it directly I decided to simplify, and the first thing I am trying to do is simply to encode frames with x264_encoder_encode and writing the resulting NALs to a file. Now I want to test if that file es correct.</p> <p>To initialize the encoder I do:</p> <pre><code>x264_param_t param; x264_param_default_preset(&amp;param, "veryfast", "zerolatency"); param.i_threads = 1; param.i_width = a_iWidth; param.i_height = a_iHeight; param.i_fps_num = a_iFPS; param.i_fps_den = 1; param.i_keyint_max = a_iFPS; param.b_intra_refresh = 1; param.rc.i_rc_method = X264_RC_CRF; param.rc.i_vbv_buffer_size = 1000000; param.rc.i_vbv_max_bitrate =500; //For streaming: param.b_repeat_headers = 1; param.b_annexb = 1; x264_param_apply_profile(&amp;param, "baseline"); encoder = x264_encoder_open(&amp;param); </code></pre> <p>Then when I have an image ( RGBA image ) I convert it to YUV420P and then I call x264_encoder_encode :</p> <pre><code>int frame_size = x264_encoder_encode(encoder, &amp;nals, &amp;num_nals, picture, &amp;pic_out); if (frame_size &gt; 0) { m_vNALs.push_back( (char*)nals[0].p_payload ); m_vSizes.push_back( frame_size ); return frame_size; } </code></pre> <p>Everything appears to be valid, frame_size returns non-zero positive value and all the others parameters appears to be ok. Every NAL starts with correct code.</p> <p>So I'm writing all the nals to a file:</p> <pre><code>FILE* pFile; pFile = fopen("file.h264", "wb"); for( int nIndex = 0; nIndex &lt; m_vNALs.size(); nIndex++ ) { fwrite( m_vNALs[ nIndex ], m_vSizes[ nIndex ], 1, pFile ); } </code></pre> <p>Now I have file.h264 file. So to test this file I use ffmpeg.exe ( I'm on windows ), and I get this output:</p> <pre><code>[h264 @ 00000000021c5a60] non-existing PPS referenced [h264 @ 00000000021c5a60] non-existing PPS 0 referenced [h264 @ 00000000021c5a60] decode_slice_header error [h264 @ 00000000021c5a60] no frame! [h264 @ 00000000021c5a60] non-existing PPS referenced [h264 @ 00000000021b74a0] max_analyze_duration 5000000 reached at 5000000 [h264 @ 00000000021b74a0] decoding for stream 0 failed [h264 @ 00000000021b74a0] Could not find codec parameters for stream 0 (Video: h 264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options [h264 @ 00000000021b74a0] Estimating duration from bitrate, this may be inaccura te file.h264: could not find codec parameters </code></pre> <p>vlc also can't play the file.</p> <p>ffplay tells: </p> <pre><code>file.h264: Invalid data found when processing input </code></pre> <p>What is wrong?????</p> <p>Thanks in advance, Zetlb</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload