Skip to content

Instantly share code, notes, and snippets.

@figgis
Last active May 21, 2024 13:40
Show Gist options
  • Save figgis/d3cff69be815491eff1ac9338aa78add to your computer and use it in GitHub Desktop.
Save figgis/d3cff69be815491eff1ac9338aa78add to your computer and use it in GitHub Desktop.
H264 extract SEI using FFMPEG
// It's actually quite simple to extract unregistered sei data using ffmpeg, but I couln't find any documentation about how it's done
AVFrameSideData *sd;
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_SEI_UNREGISTERED);
if (sd) {
// First 15 bytes is the uuid, unregistered payload start at index 16 and the
// total size is given by sd->size
printf("side-data size %ld first-byte %u\n", sd->size, sd->data[16]);
@tvercaut
Copy link

That was very helpful. It took me a fair bit of time to get it up and running though and I realised that a frame could hold multiple AV_FRAME_DATA_SEI_UNREGISTERED items. This required additional care and looping over the frame->side_data rather than calling av_frame_get_side_data. The result of my exploration incorporating this in two ffmpeg examples is here: https://gist.github.com/tvercaut/94c68e46d0d0321a2c83b88024d9cd69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment