Author Topic: Regarding x264_encoder_headers() in libx264  (Read 1702 times)

Offline GEFORCEXTREME

  • Member
  • Posts: 23
    • View Profile
Regarding x264_encoder_headers() in libx264
« on: March 21, 2011, 11:12:14 PM »
What does this do? According to x264.h,

/* x264_encoder_headers:
 *      return the SPS and PPS that will be used for the whole stream.
 *      *pi_nal is the number of NAL units outputted in pp_nal.
 *      returns negative on error.
 *      the payloads of all output NALs are guaranteed to be sequential in memory. */
int     x264_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );

The function is very much of the same structure as x264_encoder_encode() which encodes a single frame. The function return some amount of NALUs. How do I sent this over using RTP transport protocol? These NALUs, do I send them once for the whole video session?

If I want to send these (SPS, PPS) NALUs and VCL NALUs, is there a certain way I do this? Or do I just pack them into and set appropriate UDP/RTP headers and then send them over? I've read RFC3984: RTP Payload Format for H.264 Video, but I still can't understand how x264 video data are transferred. Someone please help.

Offline Dark Shikari

  • x264 developer
  • Administrator
  • Member
  • *****
  • Posts: 650
    • View Profile
Re: Regarding x264_encoder_headers() in libx264
« Reply #1 on: March 21, 2011, 11:40:52 PM »
x264_encoder_headers is to be used when you are encoding for a container format or protocol in which the PPS and SPS are sent once at the start.  Examples include Matroska and MP4 (ISO Media).

Offline GEFORCEXTREME

  • Member
  • Posts: 23
    • View Profile
Re: Regarding x264_encoder_headers() in libx264
« Reply #2 on: March 22, 2011, 08:39:13 PM »
Thanks for the swift reply, Dark Shikari.

But how do I know which protocol/container sends once at the start, and which sends it another way which I do not know.

I'm using RTP, do I send them once at the start? Or do I ignore them? Or is it another way? Please help, thanks!  :)

Offline Dark Shikari

  • x264 developer
  • Administrator
  • Member
  • *****
  • Posts: 650
    • View Profile
Re: Regarding x264_encoder_headers() in libx264
« Reply #3 on: March 23, 2011, 05:15:03 PM »
Read the spec for that protocol, or the code of an existing muxer.

Offline GEFORCEXTREME

  • Member
  • Posts: 23
    • View Profile
Re: Regarding x264_encoder_headers() in libx264
« Reply #4 on: March 24, 2011, 08:32:30 PM »
Thanks Dark Shikari!  :)