slitaz-tools view tinyutils/decode @ rev 797

Regenerate tazdrop.pot
author Claudinei Pereira <claudinei@slitaz.org>
date Sat Jan 26 15:53:49 2013 -0200 (2013-01-26)
parents 6e62d41a70d2
children e232f0e1413a
line source
1 #!/bin/sh
2 #
3 # Decode is a cmdline tool to decode all kinds of files such as audio or video.
4 # Lets you decode a single file, many files on cmdline or a full directory.
5 #
6 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
7 #
8 # Author: Christophe Lincoln <pankso@slitaz.org>
9 #
10 . /lib/libtaz.sh
12 # NOTES:
13 # Do we need a --out=/output/path options ?
14 # Use convert for [.png|.jpg] --> .raw ?
15 # Use separators and give decoded file size ?
16 # Use mencoder for flash video files (and other format) ?
18 # Internationalization
19 . /usr/bin/gettext.sh
20 TEXTDOMAIN='slitaz-tools'
21 export TEXTDOMAIN
23 #
24 # Functions
25 #
27 # Small help and usage.
28 usage() {
29 cat << EOT
31 $(gettext "Usage:") $(basename $0) [option] [file|url] [file2 url2 ... fileN urlN]
33 $(gettext "Decode audio and video files")
35 $(gettext "Examples:")
36 $(basename $0) audio.mp3 audio.ogg
37 $(basename $0) /path/files/*
38 $(basename $0) http://www.myurl/file.avi
40 EOT
41 }
43 # Check if a tool is installed. Don't force users and auto install package
44 # Decode is a cmdline line tool, let's have auto install option in GUI.
45 check_tool() {
46 name="$(basename "$file")"
47 if [ ! -x /usr/bin/$1 ]; then
48 echo ""
49 gettext "Missing decoder :"; echo " $1"
50 gettext "Skipping file :"; echo " $name"
51 continue
52 else
53 echo ""
54 gettext "Decoding:"; echo " $name"
55 #separator
56 fi
57 }
59 # Decode a file.
60 decoder() {
61 case "$file" in
62 *.mp3|*.MP3)
63 check_tool "mpg123"
64 mpg123 --rate 44100 --stereo --buffer 3072 --resync \
65 -w "${file%.*3}.wav" "$file" ;;
66 *.ogg)
67 check_tool "oggdec"
68 oggdec "$file" ;;
69 *.avi|*.wmv|*.mov|*.flv)
70 check_tool "ffmpeg"
71 ext=${file##*.}
72 # *.flv --> mencoder file.flv -ovc lavc -oac mp3lame -o file.avi
73 ffmpeg -y -i "$file" "${file%.$ext}.mpg"
74 du -sh "${file%.$ext}.mpg" ;;
75 *.wav|*.mpg|--*)
76 # Skip decoded files and --options.
77 continue ;;
78 *) echo ""; gettext "Unsupported file:"; echo " $file" ;;
79 esac
80 }
82 #
83 # Commands
84 #
86 case "$1" in
87 "") usage ;;
88 *)
89 for file in "$@"
90 do
91 case "$file" in
92 http://*)
93 busybox wget "$file"
94 file="$(basename "$file")"
95 decoder && rm "$file" ;;
96 *.*)
97 [ ! -f "$file" ] && \
98 (gettext "No file:"; echo " $file") && continue
99 decoder ;;
100 esac
101 done && echo "" ;;
102 esac
104 exit 0