Skip to content

Preserving Video Metadata When Watermarking #57

Open
@tim-janik

Description

@tim-janik

Hi.
When using videowmark to watermark an MP4 file, it successfully reads the MP4 and adds the watermark, but seems to loose some of the metadata, according to mediainfo.

$ videowmark add BigBuckBunny_320x180.mp4 BigBuckBunny_WM.mp4 0000111100002222
$ mediainfo BigBuckBunny_320x180.mp4 >x1
$ mediainfo BigBuckBunny_WM.mp4 >x2
$ diff -u x1 x2

The differences are as follows:

--- x1	2024-04-19 12:05:44.013193748 +0200
+++ x2	2024-04-19 12:05:49.757202964 +0200
@@ -1,19 +1,16 @@
 General
-Complete name                            : BigBuckBunny_320x180.mp4
+Complete name                            : BigBuckBunny_WM.mp4
 Format                                   : MPEG-4
 Format profile                           : Base Media
-Codec ID                                 : isom (mp41)
+Codec ID                                 : isom (isom/iso2/avc1/mp41)
 File size                                : 61.7 MiB
 Duration                                 : 9 min 56 s
-Overall bit rate mode                    : Variable
 Overall bit rate                         : 867 kb/s
 Movie name                               : Big Buck Bunny
 Performer                                : Blender Foundation
 Composer                                 : Blender Foundation
 Recorded date                            : 2008
-Encoded date                             : UTC 1970-01-01 00:00:00
-Tagged date                              : UTC 1970-01-01 00:00:00
-Writing application                      : Lavf52.14.0
+Writing application                      : Lavf58.76.100
 
 Video
 ID                                       : 1
@@ -39,8 +36,6 @@
 Scan type                                : Progressive
 Bits/(Pixel*Frame)                       : 0.508
 Stream size                              : 50.0 MiB (81%)
-Encoded date                             : UTC 1970-01-01 00:00:00
-Tagged date                              : UTC 1970-01-01 00:00:00
 Codec configuration box                  : avcC
 
 Audio
@@ -49,15 +44,18 @@
 Format/Info                              : Advanced Audio Codec Low Complexity
 Codec ID                                 : mp4a-40-2
 Duration                                 : 9 min 56 s
-Bit rate mode                            : Variable
-Bit rate                                 : 160 kb/s
+Source duration                          : 9 min 56 s
+Bit rate mode                            : Constant
+Bit rate                                 : 161 kb/s
 Channel(s)                               : 2 channels
 Channel layout                           : L R
 Sampling rate                            : 48.0 kHz
 Frame rate                               : 46.875 FPS (1024 SPF)
 Compression mode                         : Lossy
-Stream size                              : 11.4 MiB (18%)
-Encoded date                             : UTC 1970-01-01 00:00:00
-Tagged date                              : UTC 1970-01-01 00:00:00
+Stream size                              : 11.4 MiB (19%)
+Source stream size                       : 11.4 MiB (19%)
+Default                                  : Yes
+Alternate group                          : 1
+mdhd_Duration                            : 596224

I.e. "Encoded date" and "Tagged date" are lost for both streams, Video and Audio.
Also, is it expected that the audio stream turns from "Bit rate mode: Variable" before watermarking into "Bit rate mode: Constant" after watermarking?

For the record, I've tried to adjust videowmark to preserve the metadata by adding -movflags +faststart+use_metadata_tags -map_metadata 0 to the audio+video merging step. But that tends to also rename matadata tags (e.g. "Movie name"->"title" or "Performer"->"artist) without preserving any dates, so it is not really an improvement.

As for the above metadata loss, is that purely due to the different codecs used during re-encoding, or can metadata loss go beyond that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions