[Libav-user] Decoding SEI NAL units

Andrey Zhuchkov zhuchkovas at gmail.com
Fri Mar 5 10:58:18 EET 2021


I have an RTSP video stream encoded by h264 that carries camera's
timestamps inside SEI NAL units.
I'm not sure where those units are exactly located, but I have an example
of how to output them using a patch for ffmpeg:

libavcodec/h2645_parse.c:

...

+ #include <inttypes.h>

...

static int h264_parse_nal_header(H2645NAL *nal, void *logctx)

     nal->ref_idc = get_bits(gb, 2);

     nal->type    = get_bits(gb, 5);


+    if( nal->type == 6 ) {

+        uint64_t* ts = (uint64_t*)(nal->data+3);

+        av_log(logctx, AV_LOG_DEBUG,

+               "nal_unit_type: %d(%s), nal_ref_idc: %d, ts: %"PRId64"\n",

+               nal->type, h264_nal_unit_name(nal->type), nal->ref_idc, *ts
);

+        return 1;
+    }

After applying this patch ffmpeg starts showing timestamps that I need.

Is it possible to decode those timestamps alongside with video frames using
libav* libraries? Since I'm not a video or C programming expert, ideally
I'd like to do it using Python (OpenCV or PyAV), but any help is
appreciated.

-- 
Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210305/b43e24cf/attachment.html>


More information about the Libav-user mailing list