aboutsummaryrefslogtreecommitdiff
path: root/ffmpeg-rm-video
blob: f49d1d418716d04e8d68a6259c90e4b36cdba663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

SELF="$( basename "$0" )"
help() {
	cat <<EOF
Usage: $0 file [file ...]

Remove video from combined video/audio files.

Each file will be replaced with an audio-only copy, with the original
filename. The original file will be renamed to end in .bak.

$0 foo.mp4 bar.mp4

...will create audio-only foo.mp4 and bar.mp4 files, and the original
files will be kept as foo.mp4.bak and bar.mp4.bak

Note that the output file will be of the same type as the input file. This
script does NOT convert the audio to a .wav or whatever, so you end up
with e.g. an .avi file with only audio (no video).

This is most useful for .flac files, which include a single frame of video
(a still image).
EOF
}

if [ "$1" = "" -o "$1" = "--help" ]; then
	help
	exit 0
fi

for file in "$@"; do
	ext="$( echo "$file" | sed 's,.*\.,,' )"
	tmp="$$.$ext"
	ffmpeg -i "$file" -acodec copy -vn "$tmp"
	mv "$file" "$file.bak"
	mv "$tmp" "$file"
done