This should be added even if the first access unit does not contain
parameter sets.
---
E.g. this is helpful for the "-bsf:v 
'h264_metadata=sei_user_data=dc45e9bde6d948b7962cd820d923eeef+x264 - core 150'" 
hack workaround for old files with stripped metadata.


 libavcodec/h264_metadata_bsf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index ce85781c6..88e1a7750 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -62,6 +62,7 @@ typedef struct H264MetadataContext {
     int crop_bottom;
 
     const char *sei_user_data;
+    int sei_first_au;
 } H264MetadataContext;
 
 
@@ -288,14 +289,17 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
         }
     }
 
-    // Only insert the SEI in access units containing SPSs.
-    if (has_sps && ctx->sei_user_data) {
+    // Only insert the SEI in access units containing SPSs, and also
+    // unconditionally in the first access unit we ever see.
+    if (ctx->sei_user_data && (has_sps || !ctx->sei_first_au)) {
         H264RawSEIPayload payload = {
             .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
         };
         H264RawSEIUserDataUnregistered *udu =
             &payload.payload.user_data_unregistered;
 
+        ctx->sei_first_au = 1;
+
         for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) {
             int c, v;
             c = ctx->sei_user_data[i];
-- 
2.15.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to