strip_metadata: Strip identifying metadata from a media file

View source: R/ffmpeg.R

strip_metadataR Documentation

Strip identifying metadata from a media file

Description

Remove a media file's container and global metadata tags, together with any chapters, and write a de-identified copy. The tags include creation time, GPS or other location, device make and model, title and comment. Use it to de-identify research recordings, for example for an IRB (a research ethics board). The audio and video streams are stream-copied, not re-encoded. So the operation is lossless and fast, and the picture and sound are bit-for-bit unchanged. That includes any rotation display matrix, which is stream side data and not a metadata tag. The glossary in vignette("tidymedia") explains media terms such as container, stream and stream copy.

Usage

strip_metadata(infile, outfile, run = TRUE)

Arguments

infile

A string containing the path to a media file.

outfile

A string containing the path of the de-identified file to write. Use the same container extension as infile so the copied streams remux cleanly.

run

A logical: run the command through FFmpeg (TRUE, default) or return the compiled command without running it (FALSE).

Details

The output is written bit-exactly (-fflags +bitexact). So FFmpeg does not stamp the container again with a fresh creation_time, or with an encoder tag that names its own version. Either tag would defeat de-identification and reproducibility.

Because the streams are copied and not re-encoded, some data is not removed. Those are identifiers inside the encoded bitstream, and per-stream metadata such as handler_name or language. Removing them would require one of two things. One is re-encoding, which is out of scope for this function, so use the direct command ffmpeg for it. The other is per-stream metadata mapping that must probe the file first.

Value

The compiled FFmpeg command (invisibly when run = TRUE).

See Also

anonymize_video() removes faces or regions from the picture, for visual de-identification. probe_container() and mediainfo_query() inspect a file's metadata before and after. This function wraps the pipeline functions ffm_copy() and ffm_output_options(). strip_metadata_batch() is the many-file form.

Other task functions: anonymize_video(), anonymize_video_batch(), compare_videos(), compare_videos_batch(), concatenate_videos(), concatenate_videos_batch(), convert_audio(), convert_audio_batch(), crop_video(), crop_video_batch(), extract_audio(), extract_audio_batch(), extract_frame(), extract_frame_batch(), format_for_web(), format_for_web_batch(), normalize_audio(), normalize_audio_batch(), picture_in_picture(), picture_in_picture_batch(), sample_frames(), sample_frames_batch(), segment_video(), segment_video_batch(), separate_audio_video(), separate_audio_video_batch(), standardize_video(), standardize_video_batch(), strip_metadata_batch()

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
strip_metadata(video, "clean.mp4", run = FALSE)

tidymedia documentation built on Oct. 11, 2026, 5:08 p.m.