Skip to content

Commit a27759f

Browse files
committed
feat: add CLI options to control XMP metadata clearing
- Add --clear-xmp/--keep-xmp options to control whether to clear previous XMP metadata - Default behavior remains to clear XMP metadata to avoid conflicts (preserves current behavior) - Users can now use --keep-xmp to preserve previous XMP metadata if needed - Available in both specific mode (live-photo-make) and generic mode (live-photo-conv --make) Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
1 parent 5381517 commit a27759f

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/livemaker.vala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public abstract class LivePhotoConv.LiveMaker : Object {
4545
set;
4646
default = true;
4747
}
48+
public bool clear_xmp_metadata {
49+
get;
50+
set;
51+
default = true;
52+
}
4853

4954
/**
5055
* Creates a new LiveMaker instance.
@@ -175,7 +180,9 @@ public abstract class LivePhotoConv.LiveMaker : Object {
175180
}
176181

177182
// Clear previous XMP metadata to avoid conflicts
178-
this.metadata.clear_xmp ();
183+
if (this.clear_xmp_metadata) {
184+
this.metadata.clear_xmp ();
185+
}
179186

180187
// Create the live photo file from the main image and then append the video
181188
var live_file = this.export_main_image ();

src/livemakerffmpeg.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public class LivePhotoConv.LiveMakerFFmpeg : LivePhotoConv.LiveMaker {
5656
}
5757

5858
// Clear previous XMP metadata to avoid conflicts
59-
this.metadata.clear_xmp ();
59+
if (this.clear_xmp_metadata) {
60+
this.metadata.clear_xmp ();
61+
}
6062

6163
var live_file = File.new_for_commandline_arg (this.dest);
6264
var video_file = File.new_for_commandline_arg (this.video_path);

src/livemakergst.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public class LivePhotoConv.LiveMakerGst : LivePhotoConv.LiveMaker {
4646
}
4747

4848
// Clear previous XMP metadata to avoid conflicts
49-
this.metadata.clear_xmp ();
49+
if (this.clear_xmp_metadata) {
50+
this.metadata.clear_xmp ();
51+
}
5052

5153
var live_file = File.new_for_commandline_arg (this.dest);
5254
var video_file = File.new_for_commandline_arg (this.video_path);

src/main.vala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class LivePhotoConv.Main {
3737
static bool export_metadata = true;
3838
static bool frame_to_photo = false;
3939
static bool minimal_export = false;
40+
static bool clear_xmp_metadata = true;
4041
static int threads = 0;
4142
#if ENABLE_GST
4243
static bool use_ffmpeg = false;
@@ -51,6 +52,8 @@ class LivePhotoConv.Main {
5152
{ "output", 'o', OptionFlags.NONE, OptionArg.FILENAME, ref live_photo_path, "The output live photo file path", "PATH" },
5253
{ "export-metadata", '\0', OptionFlags.NONE, OptionArg.NONE, ref export_metadata, "Export metadata (default)", null },
5354
{ "drop-metadata", '\0', OptionFlags.REVERSE, OptionArg.NONE, ref export_metadata, "Do not export metadata", null },
55+
{ "clear-xmp", '\0', OptionFlags.NONE, OptionArg.NONE, ref clear_xmp_metadata, "Clear previous XMP metadata to avoid conflicts (default)", null },
56+
{ "keep-xmp", '\0', OptionFlags.REVERSE, OptionArg.NONE, ref clear_xmp_metadata, "Keep previous XMP metadata", null },
5457
#if ENABLE_GST
5558
{ "use-ffmpeg", '\0', OptionFlags.NONE, OptionArg.NONE, ref use_ffmpeg, "Use FFmpeg to extract instead of GStreamer", null },
5659
{ "use-gst", '\0', OptionFlags.REVERSE, OptionArg.NONE, ref use_ffmpeg, "Use GStreamer to extract instead of FFmpeg (default)", null },
@@ -103,6 +106,8 @@ class LivePhotoConv.Main {
103106
{ "dest-dir", 'd', OptionFlags.NONE, OptionArg.FILENAME, ref dest_dir, "The destination directory to export", "PATH" },
104107
{ "export-metadata", '\0', OptionFlags.NONE, OptionArg.NONE, ref export_metadata, "Export metadata (default)", null },
105108
{ "drop-metadata", '\0', OptionFlags.REVERSE, OptionArg.NONE, ref export_metadata, "Do not export metadata", null },
109+
{ "clear-xmp", '\0', OptionFlags.NONE, OptionArg.NONE, ref clear_xmp_metadata, "Clear previous XMP metadata to avoid conflicts (default)", null },
110+
{ "keep-xmp", '\0', OptionFlags.REVERSE, OptionArg.NONE, ref clear_xmp_metadata, "Keep previous XMP metadata", null },
106111
{ "frame-to-photos", '\0', OptionFlags.NONE, OptionArg.NONE, ref frame_to_photo, "Export every frame of a live photo's video as a photo", null },
107112
{ "img-format", 'f', OptionFlags.NONE, OptionArg.STRING, ref img_format, "The format of the image exported from video", "FORMAT" },
108113
{ "minimal", '\0', OptionFlags.NONE, OptionArg.NONE, ref minimal_export, "Minimal metadata export, ignore unspecified exports", null },
@@ -253,15 +258,18 @@ class LivePhotoConv.Main {
253258
if (use_ffmpeg) {
254259
live_maker = new LiveMakerFFmpeg (video_path, main_image_path, live_photo_path) {
255260
export_original_metadata = export_metadata,
261+
clear_xmp_metadata = clear_xmp_metadata,
256262
};
257263
} else {
258264
live_maker = new LiveMakerGst (video_path, main_image_path, live_photo_path) {
259265
export_original_metadata = export_metadata,
266+
clear_xmp_metadata = clear_xmp_metadata,
260267
};
261268
}
262269
#else
263270
LiveMaker live_maker = new LiveMakerFFmpeg (video_path, main_image_path, live_photo_path) {
264271
export_original_metadata = export_metadata,
272+
clear_xmp_metadata = clear_xmp_metadata,
265273
};
266274
#endif
267275
live_maker.export ();

0 commit comments

Comments
 (0)