# HG changeset patch # User Christophe Lincoln # Date 1335774944 -7200 # Node ID 6c810b5973a7129ef689514c7be433e357347371 # Parent cc27e2f275567ac9105cf066e0649dba11e93195 Add: decode (new cmdline tool to decode audio/video files) diff -r cc27e2f27556 -r 6c810b5973a7 Makefile --- a/Makefile Sun Apr 29 23:07:19 2012 +0200 +++ b/Makefile Mon Apr 30 10:35:44 2012 +0200 @@ -22,7 +22,7 @@ @xgettext -o po/slitaz-tools/slitaz-tools.pot -L Shell \ --package-name="SliTaz Tools" \ ./tinyutils/tazlocale ./tinyutils/tazkeymap ./tinyutils/setmixer \ - ./tinyutils/tazx + ./tinyutils/tazx ./tinyutils/decode @echo "done" boxes-pot: diff -r cc27e2f27556 -r 6c810b5973a7 po/slitaz-boxes/slitaz-boxes.pot --- a/po/slitaz-boxes/slitaz-boxes.pot Sun Apr 29 23:07:19 2012 +0200 +++ b/po/slitaz-boxes/slitaz-boxes.pot Mon Apr 30 10:35:44 2012 +0200 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: SliTaz Boxes\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-29 23:05+0200\n" +"POT-Creation-Date: 2012-04-30 10:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff -r cc27e2f27556 -r 6c810b5973a7 po/slitaz-tools/slitaz-tools.pot --- a/po/slitaz-tools/slitaz-tools.pot Sun Apr 29 23:07:19 2012 +0200 +++ b/po/slitaz-tools/slitaz-tools.pot Mon Apr 30 10:35:44 2012 +0200 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: SliTaz Tools\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-29 23:05+0200\n" +"POT-Creation-Date: 2012-04-30 10:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -86,3 +86,35 @@ #: tinyutils/tazx:168 msgid "Quit Tazx utility" msgstr "" + +#: tinyutils/decode:31 +msgid "Usage:" +msgstr "" + +#: tinyutils/decode:33 +msgid "Decode audio and video files" +msgstr "" + +#: tinyutils/decode:35 +msgid "Examples:" +msgstr "" + +#: tinyutils/decode:49 +msgid "Missing decoder :" +msgstr "" + +#: tinyutils/decode:50 +msgid "Skipping file :" +msgstr "" + +#: tinyutils/decode:54 +msgid "Decoding:" +msgstr "" + +#: tinyutils/decode:78 +msgid "Unsupported file:" +msgstr "" + +#: tinyutils/decode:98 +msgid "No file:" +msgstr "" diff -r cc27e2f27556 -r 6c810b5973a7 po/tazbox/tazbox.pot --- a/po/tazbox/tazbox.pot Sun Apr 29 23:07:19 2012 +0200 +++ b/po/tazbox/tazbox.pot Mon Apr 30 10:35:44 2012 +0200 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: TazBox\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-29 23:05+0200\n" +"POT-Creation-Date: 2012-04-30 10:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff -r cc27e2f27556 -r 6c810b5973a7 po/tazdrop/tazdrop.pot --- a/po/tazdrop/tazdrop.pot Sun Apr 29 23:07:19 2012 +0200 +++ b/po/tazdrop/tazdrop.pot Mon Apr 30 10:35:44 2012 +0200 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: TazDrop\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-29 23:05+0200\n" +"POT-Creation-Date: 2012-04-30 10:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff -r cc27e2f27556 -r 6c810b5973a7 po/tazinst/tazinst.pot --- a/po/tazinst/tazinst.pot Sun Apr 29 23:07:19 2012 +0200 +++ b/po/tazinst/tazinst.pot Mon Apr 30 10:35:44 2012 +0200 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: Tazinst\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-29 23:05+0200\n" +"POT-Creation-Date: 2012-04-30 10:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff -r cc27e2f27556 -r 6c810b5973a7 tinyutils/decode --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tinyutils/decode Mon Apr 30 10:35:44 2012 +0200 @@ -0,0 +1,104 @@ +#!/bin/sh +# +# Decode is a cmdline tool to decode all kind of files such as audio or video. +# Let decode a single file, many file on cmdline or a full directory. +# +# Copyright (C) 2012 SliTaz GNU/Linux - BSD License +# +# Author: Christophe Lincoln +# +. /lib/libtaz.sh + +# NOTES: +# Do we need a --out=/output/path options ? +# Use convert for [.png|.jpg] --> .raw ? +# Use separators and give decoded file size ? +# Use mencoder for flash video files (and other format) ? + +# Internationalization +. /usr/bin/gettext.sh +TEXTDOMAIN='slitaz-tools' +export TEXTDOMAIN + +# +# Functions +# + +# Small help and usage. +usage() { + cat << EOT + +$(gettext "Usage:") $(basename $0) [option] [file|url] [file2 url2 ... fileN urlN] + +$(gettext "Decode audio and video files") + +$(gettext "Examples:") + $(basename $0) audio.mp3 audio.ogg + $(basename $0) /path/files/* + $(basename $0) http://www.myurl/file.avi + +EOT +} + +# Check if a tool is installed. Dont force users and auto install package +# Decode is a cmdline line tool, let have auto install option in GUI. +check_tool() { + name="$(basename "$file")" + if [ ! -x /usr/bin/$1 ]; then + echo "" + gettext "Missing decoder :"; echo " $1" + gettext "Skipping file :"; echo " $name" + continue + else + echo "" + gettext "Decoding:"; echo " $name" + #separator + fi +} + +# Decode a file. +decoder() { + case "$file" in + *.mp3|*.MP3) + check_tool "mpg123" + mpg123 --rate 44100 --stereo --buffer 3072 --resync \ + -w "${file%.*3}.wav" "$file" ;; + *.ogg) + check_tool "oggdec" + oggdec "$file" ;; + *.avi|*.wmv|*.mov|*.flv) + check_tool "ffmpeg" + ext=${file##*.} + # *.flv --> mencoder file.flv -ovc lavc -oac mp3lame -o file.avi + ffmpeg -y -i "$file" "${file%.$ext}.mpg" + du -sh "${file%.$ext}.mpg" ;; + *.wav|*.mpg|--*) + # Skip decoded files and --options. + continue ;; + *) echo ""; gettext "Unsupported file:"; echo " $file" ;; + esac +} + +# +# Commands +# + +case "$1" in + "") usage ;; + *) + for file in "$@" + do + case "$file" in + http://*) + busybox wget "$file" + file="$(basename "$file")" + decoder && rm "$file" ;; + *) + [ ! -f "$file" ] && \ + (gettext "No file:"; echo " $file") && continue + decoder ;; + esac + done && echo "" ;; +esac + +exit 0