Skip to content

Commit f42b9f6

Browse files
committed
packages/vid-strip-meta: add package
Make it easier to just strip all metadata
1 parent 4429e46 commit f42b9f6

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
ffmpeg,
3+
writeShellApplication,
4+
...
5+
}:
6+
writeShellApplication {
7+
name = "vid-strip-meta";
8+
9+
meta.mainProgram = "vid-strip-meta";
10+
checkPhase = "";
11+
12+
runtimeInputs = [
13+
ffmpeg
14+
];
15+
16+
text = # bash
17+
''
18+
if [ -z "''${1-}" ]; then
19+
echo "Usage: vid-strip-meta <media_file>"
20+
exit 1
21+
fi
22+
23+
if [ ! -f "$1" ]; then
24+
echo "Error: File not found: '$1'"
25+
exit 1
26+
fi
27+
28+
input_file="$1"
29+
output_file="''${input_file%.*}_clean.''${input_file##*.}"
30+
31+
echo "Stripping metadata from '$input_file'..."
32+
echo "Output will be: '$output_file'"
33+
34+
# -map_metadata -1: Removes global metadata (title, comments, etc.)
35+
# -map_chapters -1: Removes chapter markers
36+
# -c copy: Copies video/audio streams without re-encoding
37+
if ffmpeg -i "$input_file" -map_metadata -1 -map_chapters -1 -c copy -y "$output_file"; then
38+
echo "✅ Metadata successfully stripped. Clean file created at '$output_file'"
39+
else
40+
echo "❌ FFmpeg failed to process the file."
41+
rm -f "$output_file" # Clean up incomplete file
42+
exit 1
43+
fi
44+
'';
45+
}

0 commit comments

Comments
 (0)