Need : - zenity - ffmpeg
1 #!/bin/bash
2 ###############################################################################
3 #
4 # convert2flv :
5 # Convert avi to flv.
6 # Need :
7 # - zenity
8 # - ffmpeg
9 #
10 # by Guillaume Kulakowski a.k.a LLaumgui <guillaume at llaumgui dot com>
11 # Version 1.0^M
12 #
13 ###############################################################################
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not,
26 # - write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 # - See http://www.gnu.org/licenses/gpl.html^M
29 ###############################################################################
30
31
32 ###############################################################################
33 # Variables :
34 #
35 OPT_AR=22050
36 OPT_AB=32
37 OPT_S="320X240"
38 OPT_NAME="video.flv"
39 OPT_LOG=true
40
41
42
43
44 ###############################################################################
45 # Fonctions :
46 #
47 ##
48 # Définir le taux d’échantillonnage du son :
49 #
50 function setAr () {
51
52 OPT_AR=`zenity --entry --text="Taux d’échantillonnage" --entry-text=$OPT_AR`
53 }
54
55
56
57 ##
58 # Définir le audio bitrate en kbit / seconde :
59 #
60 function setAb () {
61
62 OPT_AB=`zenity --entry --text="Audio bitrate en kbit / seconde" --entry-text=$OPT_AB`
63 }
64
65
66
67 ##
68 # Définir les dimensions après conversion :
69 #
70 function setS () {
71
72 OPT_S=`zenity --entry --text="Dimensions après conversion" --entry-text=$OPT_S`
73 }
74
75
76
77 ##
78 # Définir les nom de la vidéo de sortie :
79 #
80 function setName () {
81
82 OPT_NAME=`zenity --entry --text="Non du fichier flv de sortie" --entry-text=$OPT_NAME`
83 }
84
85
86
87 ##
88 # Test l'appel du script :
89 #
90 function testArg () {
91 if [ $1 -lt 2 ]; then
92 zenity --info \
93 --width=600 \
94 --title="Usage incorrect de convert2flv !" \
95 --text="L'usage correct est :
96 convert2flv <Chemin vers le fichier> <Nom du fichier>";
97 exit
98 fi
99 }
100
101
102
103 ##
104 # Lancement
105 #
106 function convert () {
107
108 #Debug zenity --error --text="ffmpeg -i '$1/$2' -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S '$1/$OPT_NAME'"
109 #echo "ffmpeg -i '$1/$2' -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S '$1/$OPT_NAME'" > "$1/$OPT_NAME.log"
110 if [ $OPT_LOG = true ]; then
111 ffmpeg -y -i "$1/$2" -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S "$1/$OPT_NAME" 2> "$1/$OPT_NAME.log"
112 zenity --text-info --filename="$1/$OPT_NAME.log"
113 else
114 ffmpeg -y -i "$1/$2" -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S "$1/$OPT_NAME"
115 fi
116 }
117
118
119
120
121
122 ###############################################################################
123 # Code brut :
124 #
125 testArg $#
126 setAr
127 setAb
128 setS
129 setName
130 convert "$1" "$2"
Juste un script qui se charge de faire un screenshot, le place dans un répertoire donné, et affiche une miniature de ce qui à été capturé. La capture se fait en utilisant scrot (par défaut) ou import (si scrot n'est pas présent) Testé on Linux and Solaris
1 #!/usr/bin/env bash
2 #
3 #printscreen.sh written by : nali <phobos@goupilfr.org>
4 # enhanced by : slubman <slubman@ifrance.com>
5 # this script is free software according to the
6 # GNU General Public License (see http://www.gnu.org/licenses/gpl.html)
7 #
8 #
9 # This script make a screenshot and save it to a default location
10 # You can customize some component by editing variables:
11 # * REP_SAVE
12 # * IMG_PREF
13 # * IMG_UNIQ
14 # * IMG_VIEW
15 # * IMG_SIZE
16 #
17 # The script first try to use the scrot program, if not found it default on import
18 #
19 ###########################################################
20
21
22 # Modify the following variables to fetch what you want:
23 #repertoire des sauvegardes
24 REP_SAVE=~/Documents/Captures
25
26 # Prefixe du nom des images
27 IMG_PREF=capture
28
29 # Estampille (unique) des images
30 IMG_UNIQ=`date +%Y-%m-%d-%H%M%S`
31
32 # View Image (0=no , 1=yes : this feature depend on the display program) ?
33 IMG_VIEW=1
34
35 # Display image resize
36 IMG_SIZE="840x625"
37
38
39
40 ###########################################################
41 # You really don't need to edit anything bellow this line #
42 ###########################################################
43
44 #Delai en sec. avant la capture . Peut etre interessant a mettre par exemple a
45 #5 ou 10 secondes pour capturer des screen savers.
46
47 [ "$1" ] && DELAY=$1
48
49 ###########################################################
50
51 #repertoire des captures non datees
52 REP_TEMP=$REP_SAVE/tmp
53
54 #creation du repertoire des sauvegardes si il n existe pas
55 [ ! -d $REP_SAVE ] && mkdir $REP_SAVE
56
57 #creation du repertoire des sauvegardes avant "datage", si il n existe pas
58 [ ! -d $REP_TEMP ] && mkdir $REP_TEMP
59
60 ###########################################################
61
62 # Verification de l'exitence de import
63 CAPTURE_CMDS=(scrot import)
64 for CAPTURE_CMD in ${CAPTURE_CMDS[@]};
65 do
66 which $CAPTURE_CMD
67 if [ $? -eq 0 ]; then
68 echo "Using $CAPTURE_CMD for the capture !!"
69 break
70 fi
71 done
72
73 # Verification de l'exitence de display
74 if [ IMG_VIEW == "1" -a ! $(which display) ]; then
75 echo "display program not found, please install ImageMagick (http://www.imagemagick.org)"
76 exit
77 fi
78
79 #nom de l'image avant datage
80 NOM_TEMP=$IMG_PREF.png
81
82 #nettoyage du temp
83 cd $REP_TEMP
84 rm -f $NOM_TEMP
85
86 #capture de l'image
87 [ $DELAY ] && sleep $DELAY
88 case $CAPTURE_CMD in
89 scrot)
90 scrot -m $NOM_TEMP
91 ;;
92 import)
93 import -window root $NOM_TEMP
94 ;;
95 *)
96 echo "Unknown capture command"
97 exit
98 ;;
99 esac
100
101
102 #ajout de la date et heure au nom de la capture
103 #c'est pas beau mais ca marche :)
104 SEPARATEUR=-
105 NOM_DATE=`basename $NOM_TEMP .png`$SEPARATEUR$IMG_UNIQ.png
106
107 cp $NOM_TEMP $NOM_DATE
108
109 mv $NOM_DATE $REP_SAVE
110
111 #affichage en mode reduit
112 [ $IMG_VIEW == "1" ] && display -resize $IMG_SIZE "$REP_SAVE/$NOM_DATE" &
113
114 #nettoyage du temp , pour laisser propre en partant ...
115 cd $REP_TEMP
116 rm -f $NOM_TEMP
Pages : 1