[Libav-user] MP4/AAC and rewriting pic_parameter_set_id in slice header

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Libav-user] MP4/AAC and rewriting pic_parameter_set_id in slice header

Stefan Hellkvist
Hi, 

I am trying to write an MP4 from a received H264 stream using libav. The first SPS and PPS NALS I receive I copy and set as the extradata for the codec. All the other SPS and PPS NALS I drop. 

This method seems to work with streams coming from for instance Google Chrome which always seem to have NALS that use pic_parameter_set_id = 0, but it does not work with streams where the pic_parameter_set_id is growing incrementally (the encoder sends new SPS and PPS packets which I ignore at the moment). When I play the resulting MP4 in ffplay it play the first IDR and the following P frames but it will stop and complain for all other frames, like the example below: 

[h264 @ 0x7fe831814600] non-existing PPS 5 referenced
[h264 @ 0x7fe831814600] decode_slice_header error
[h264 @ 0x7fe831814600] no frame!

for all frames that has pic_parameter_set_id larger than 0. 

I am relatively new to MP4 and H264 but I guess this is because I simply do not have the referenced PPS/SPS info in the extradata (only the first one at index 0). 

So my question is - how would you get around this problem? Is it possible to make libav rewrite the pic_parameter_set_id for each frame that I send it, so that all frames reference the first SPS/PPS (because it only seems like new copies of the initial SPS/PPS but with new ids)? Or does anyone have code that does this currently outside of libav? Because I should not have to gather all SPS/PPS packets and store them in the extradata, or should I? Or, yet another or, am I totally clueless as to what I am talking about and is the problem something else? 

Kindest regards,
Stefan


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Loading...