Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 22/09/2018, à 09:30

Sophie2

Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bonjour,

J'ai un grand nombre de petites vidéos en format .MTS, je voudrais toutes les assembler et obtenir un seul fichier en format plus fluide du type .mp4 ou équivalent qui ne saccade pas. Que me conseillez-vous de faire ?

Je n'y connais pas grand chose en traitement vidéo et je ne comprends pas les échanges trouvés à ce propos sur le forum ou ailleurs.

Hors ligne

#2 Le 22/09/2018, à 09:53

Nasman

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Tu as la notion de conteneur et de codecs.
Le conteneur contient différents flux, audio, vidéo, sous-titrage... et est compatible avec plusieurs types de codecs.
Les codecs sont les façons de coder un flux audio ou vidéo - leur but est de pouvoir stocker les données de la façon la plus compact en limitant la perte sensible de résolution (audio ou vidéo).

.avi, .mkv, .mp4 sont des formats de conteneurs
h264, mpeg2video sont des codecs vidéo
aac, ac3... sont des codecs audio

Si les flux audio ou vidéo ne sont pas modifiés, il est possible d'inclure ces flux dans un autre conteneur - et dans ce cas c'est assez rapide.
En cas de modification de flux audio ou vidéo, il y a donc transcodage des flux, par exemple conversion de aac en ac3 ou de mpeg2video en h264 et cette opération est longue. Les flux modifiés seront inclus dans le conteneur souhaité.

Attention, tous les conteneurs n'acceptent pas tous les codecs.


PC fixe sous Bionic 64 bits et portable avec Focal 64 bits

Hors ligne

#3 Le 22/09/2018, à 10:19

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bonjour
Peut etre avec Openshot en les mettant bout a bout , tu peux même mettre des transitions entre les vidéos

Edit: apres essai ça fonctionne bien  mais fait des fichiers lourds
2 vidéos de 25 Mo font un fichier de 200 Mo

Dernière modification par bluc (Le 22/09/2018, à 12:51)


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#4 Le 22/09/2018, à 10:31

berserk

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bonjour
Teste cette commande ffmpeg : https://stackoverflow.com/questions/261 … s-on-linux
Ça joint les fichiers mais ça ne les convertit pas. Tu pourras faire la conversion après je suppose.

Hors ligne

#5 Le 22/09/2018, à 19:36

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Merci à vous.
Nasman, donc mes fichiers .MTS sont des conteneurs mais je ne sais pas quels codecs audios et vidéos ils contiennent (je vais découvrir ça petit à petit).

bluc, dommage qu'Openshot fasse de trop lourds fichiers. Il y a peut être un autre logiciel qui assemblerait des .MTS en une vidéo finale globale plus légère, on va voir si quelqu'un passant par-là en connaît un.

bersek, tu me parles de cette commande là ? :
ffmpeg -i "concat:00000.MTS|00001.MTS|00002.MTS" -c copy output.m2ts
Je ne maîtrise pas assez le langage du terminal pour adapter ça à mon cas particulier car j'imagine qu'il doit falloir lui dire où sont les .MTS sur mon disque dur.

Le traitement audio/vidéo semble être un monde complexe.

Hors ligne

#6 Le 22/09/2018, à 19:52

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

j'ai utilisé a cette période ce nautilus script , je viens de faire quelques essais , mais ça ne fonctionne pas toujours

Dernière modification par bluc (Le 22/09/2018, à 19:57)


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#7 Le 23/09/2018, à 10:51

cris22

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

J'utilise avidemux pour intervenir sur mes fichiers vidéo


Ubuntu 24.04 LTS - 64 bits
Mémoire : 32GiB - Carte : NVIDIA GeForce RTX™ 2060 SUPER
Processeur : Intel(R) Core(TM) i7-14700KF
carte mère : ASRock Z790 Pro RS/D4

Hors ligne

#8 Le 23/09/2018, à 11:54

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bluc : Je ne tente pas le scipt pour le moment, je ne maîtrise pas assez ce domaine.

cris22 : Dans les logiciels possibles à installer dans mon Ubuntu 18.04, je n'ai pas Avidemux. J'ai donc fait un test avec Pitivi que j'ai trouvé, et voici la réponse du logiciel dès que je mets une vidéo .MTS dedans :
The following file can not be use with Pitivi - Problème : gst-resource-error-quark

Si ça continue, je vais craquer et aller sur l'ordi avec Windows pour faire mon assemblage avec Movie maker qui veut bien le faire et qui me les transforme en mp4 pour le même prix :-)
J'aurais pourtant bien aimé le faire sur Ubuntu.

Hors ligne

#9 Le 23/09/2018, à 13:46

grigouille

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

+1 ffmpeg
https://trac.ffmpeg.org/wiki/Concatenate

L'avantage énorme de ffmpeg, c'est que tu peux le faire sur un serveur.
Par exemple, vdr produit des fichiers 0001.ts, 0002.ts, 0003.ts, etc.
Je les concatène d'abord directement sur le NAS :

ffmpeg -f concat -safe 0 -i <(for f in 0*.ts; do echo "file '$PWD/$f'"; done) -c copy out.ts

Puis, je visualise les temps de coupures que je veux faire (genre les pubs).
Je me reconnecte au NAS, je fais mes coupures, toujours avec ffmpeg. Je concatène les morceaux sans les pubs et c'est prêt.
J'ai essayé plein de logiciel (handbrake, pitivi, avidemux, etc.). Seul ffmpeg est capable de faire le travail sans planter.

Dernière modification par grigouille (Le 23/09/2018, à 13:55)


Debian (xfce) 12
HP LaserJet M1132 MFP

Hors ligne

#10 Le 23/09/2018, à 18:13

cris22

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Sophie2 a écrit :

Bluc : Je ne tente pas le scipt pour le moment, je ne maîtrise pas assez ce domaine.

cris22 : Dans les logiciels possibles à installer dans mon Ubuntu 18.04, je n'ai pas Avidemux. J'ai donc fait un test avec Pitivi que j'ai trouvé, et voici la réponse du logiciel dès que je mets une vidéo .MTS dedans :
The following file can not be use with Pitivi - Problème : gst-resource-error-quark

Si ça continue, je vais craquer et aller sur l'ordi avec Windows pour faire mon assemblage avec Movie maker qui veut bien le faire et qui me les transforme en mp4 pour le même prix :-)
J'aurais pourtant bien aimé le faire sur Ubuntu.


Ne pas oublier de penser à la doc, 1er réflexe
https://doc.ubuntu-fr.org/avidemux

un lien trouvé en bas de page de la doc
http://www.hdfever.fr/2010/04/22/encode … -h264-mkv/

Dernière modification par cris22 (Le 23/09/2018, à 18:17)


Ubuntu 24.04 LTS - 64 bits
Mémoire : 32GiB - Carte : NVIDIA GeForce RTX™ 2060 SUPER
Processeur : Intel(R) Core(TM) i7-14700KF
carte mère : ASRock Z790 Pro RS/D4

Hors ligne

#11 Le 23/09/2018, à 21:06

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Un script nautilus est très simple a installer et a utiliser
J'en ai un qui peut te convenir

Tu copies ceci dans Gedit et tu l'enregistres avec le nom , par exemple, Collage video  ou tu le télécharges

Il est necessaire d'installer les paquets mencoder et zenity

#!/bin/sh

# Join video files (Nautilus)
# Copyright (C) Richard H. Tingstad
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/>.

# File names used to determine order
# f2.mpg, f1.mpg, ... => f1-joined.mpg

# Version 0.1.0
# Depends on zenity and mencoder (and mplayer)

title="Join"
if [ $# -lt 2 ]
then
	zenity --title="$title" --error --text="You must select at least two files."
	exit 1
fi
files=`echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | egrep -v '^$' | sort`
echo "$files" | while read f
do
	if [ ! -f "$f" ]
	then
		zenity --title="$title" --error --text="'$f' is not a file."
		exit 1
	fi
done
firstfile=`echo "$files" | head -n 1`
extension=`echo "$firstfile" | egrep -oi '\.[a-z0-9]+$'`
basename=`basename "$firstfile" $extension`
outfile="$basename-joined$extension"
if [ -e "$outfile" ]
then
	if ! zenity --title="$title" --question --text="File '$outfile' exists, will overwrite. Continue?"
	then
		exit 1
	fi
fi
info=`mplayer -identify -frames 0 -vc null -vo null -ao null "$firstfile"`
demux=`echo "$info" |egrep 'ID_DEMUXER'|cut -d '=' -f2`
video=`echo "$info" |egrep 'ID_VIDEO_FORMAT'|cut -d '=' -f2`
audio=`echo "$info" |egrep 'ID_AUDIO_FORMAT'|cut -d '=' -f2`
for f in "$@"
do
	if ! mplayer -identify -frames 0 -vc null -vo null -ao null "$f"|egrep -q "ID_VIDEO_FORMAT=$video"
	then
		if zenity --title="$title" --question --text="Files may have different video encodings. Try anyway?"
		then
			break
		else
			exit 1
		fi
	fi
done
params=""
case "$demux" in
"mpegps")
	format="mpeg"
	params="$params -noskip -mc 0"
;;
"lavfpref" | "asf")
	format="lavf"
;;
*)
	format="avi"
;;
esac
case "$video" in
"0x10000001"|"mpg1")
	params="$params -mpegopts format=mpeg1"
;;
esac
case "$audio" in #http://www.mplayerhq.hu/DOCS/codecs-status.html
"MP4A"|"mp4a"|"AAC"|"AACP"|"racp"|"raac"|"VLB")
	params="$params -fafmttag 0x00ff"
;;
esac
arg=`echo "$files" | awk '{ printf "\"%s\" ", $0 }'`
ok=false
eval "mencoder -forceidx -of $format$params -oac copy -ovc copy -o \"$outfile\" $arg && ok=true"
if $ok
then
	zenity --title="$title" --info --text="All done."
else
	zenity --title="$title" --error --text="An error occurred."
fi

Tu le places dans .local/share/nautilus/scripts

Pour y acceder

nautilus $HOME/.local/share/nautilus/scripts

tu cliques droit sur ce fichier >> Propriété >> Permission et coche la case "Autoriser l’exécution du ....."
après tu n'as plus qu'a sélectionner les videos et dans le clic droit sur cette selection >> Scripts >>  Collage video

Dernière modification par bluc (Le 23/09/2018, à 21:31)


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#12 Le 03/10/2018, à 18:25

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Merci bluc pour tes explications claires et complètes. J'ai tout bien fait (je pense) et j'obtiens un fichier .MTS mais je n'ai que le son et pas l'image. J'ai ce message : "Ce codec n'est pas supporté. VLC ne peut pas décoder le format "No description for this codec""

De plus, normalement le film devrait faire 30 mn et là il en fait 50. (avec Movie maker il fait 30 mn).

Une idée sur ce qui a pu se passer ?

Hors ligne

#13 Le 03/10/2018, à 18:49

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Chez moi avec des MPG  ça fonctionne bien image et son


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#14 Le 05/10/2018, à 07:00

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Mince alors, moi avec les .MTS il ne peux pas mettre l'image. C'est moche car je voudrais bien y arriver sur Ubuntu. Mon ordinateur avec Windows est en fin de vie et je n'ai pas trop envie d'en acheter un nouveau avec Windows.

Hors ligne

#15 Le 05/10/2018, à 07:43

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

J'ai essayé avec des mts , j'ai du les convertir en avi ou autre avec aussi un nautilus script

#!/bin/sh
# AUTHOR:    P4 aka PRQT83 ( ubuntu fr )
# DATE:         14/08/2008
# VERSION:    0.3
# LICENSE:    GPL
# REQUIRES:     mencoder, zenity    
# NAME:         Avi converter 2passHQ
# DESCRIPTION:  utilitaire pour convertir les videos en .avi
# Tester si un fichier a ete selectionne
if [ $# -eq 0 ]; then
    zenity --error --title="Erreur" --text="Vous devez choisir au moins un fichier pour lancer la conversion"
    exit 1
fi

(while [ $# -gt 0 ]; do
    movie=$1
    avi_file=`echo "$movie" | sed 's/\.\w*$/ _converted.avi/'`
     mencoder "$movie" -oac mp3lame -lameopts cbr=192 -ovc xvid -xvidencopts bitrate=1100:pass=1 -o "/dev/null" && mencoder "$movie" -oac mp3lame -lameopts cbr=192 -ovc xvid -xvidencopts bitrate=1100:pass=2 -o "$avi_file"
# supprimer le fichier divx2pass.log    
rm "divx2pass.log"
shift
done

) | 
       zenity --progress --pulsate --auto-close --text="Conversion en cours ..."  --percentage=0 



    zenity --info --title "$title" --text="Conversion complete"
##############################################################################
## 25 mars 2008 ajout -version 0.2: suppression du fichier divx2pass.log
##############################################################################
## 14 aout 2008 ajout -version 0.3: amelioration de la qualite audio-video
##############################################################################

Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#16 Le 06/10/2018, à 09:47

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Impec pour la transformation des .MTS en .AVI, en une heure c'était fait pour les 60 petites vidéos.

Par contre, lorsque j'ai lancé le script pour l'assemblage, j'ai obtenu le son mais pas l'image. On voit super vite l'image au tout début et plus ensuite c'est tout noir. Le son disparaît même au milieu de la vidéo.

Pas de chance que cela ne fonctionne pas pour moi.

Hors ligne

#17 Le 07/10/2018, à 14:59

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Je viens de me rendre compte que le script nautilus de conversion des .MTS en .AVI a mal fonctionné. Les vidéos en .AVI ne sont pas nettes et tournent au ralenti. Etrange.

Ce qui pourrait expliquer pourquoi le script nautilus d'assemblage des vidéos ne fonctionne pas.

Dis-moi bluc, tes .AVI sont parfaits après conversion par le script ?

Hors ligne

#18 Le 07/10/2018, à 15:33

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Je ne peux plus te dire ,je ne les ai plus, je n'ai jamais eu de .MTS ,  j'en avait téléchargé 3 pour l'essai et je me souviens que la reconversion était réussie mais pas très fluide , je pensais plutôt a un défaut des fichiers d'origine
j'ai bien d'autres scripts de reconversion mais il fonctionne tous pareil je pense

essayes peut etre celui-ci en choisissant un autre format de sortie mp4 par exemple

#!/bin/bash

# marc brumlik, tailored software inc, Mon Sep  8 22:50:20 CDT 2008
version="0.80 Thu Dec 17 17:23:30 CST 2009 --\nCorrected parsing when there are\nmultiple options in ffmpeg custom line"
# tsi-inc@comcast.net
# posted to:  http://www.gnome-look.org/content/show.php/Audio%2BVideo%2BImage%2BText%2BISO+Convert?content=92533
# your vote would be appreciated (as would a $1 donation :-)

# convert various image, audio, and video files into other likely formats

# set -x

#####
# Watcher
#####
avwatcher() {
### this function produces the "progress window" during the conversion.
### there are two phases...

# set -x
# doing frames??
frames=n
echo "$1" | grep "frame-%04d" >/dev/null && frames=y
mult="100"
[ "$frames" = "y" ] && mult="1000" 


# phase 1 begins.  sleep for one second while the conversion gets started.
# sleep 1
# using the process NAME and the PPID given, find the PID of the conversion
pid=`ps -ef | grep " $4 " | grep "$2" | awk '{print $2}'`
z="0"
# every second, test for the appearance of the output file

wtext1=`mytranslate "Waiting for"`
wtext1="$wtext1 $2\n"
wtext1="$wtext1 "`mytranslate "to begin writing"`
wtext1="$wtext1 $1"
wtext2=`mytranslate "Program Cancelled!"`

while true
do
# if this is a "frame job", skip watcher phase 1
	[ "$frames" = "y" ] && break
# if the file appears before progress window even comes up, go to phase 2
	if test -s "$1"
		then	break
	fi
        for a in 10 20 30 40 50 60 70 80 90 80 70 60 50 40 30 20 10 00
        do
# when file appears, go to phase 2
                test -s "$1" && break 2
# otherwise, increment counter in zenity window for next display
                echo $a; sleep 1
		z=`expr $z + 1`
# but if no file is seen for 20 seconds, something's not right.  exit.
		if [ "$z" = "20" ]
			then	exit 0
		fi
        done
done | zenity --progress --auto-close --text="$wtext1" || ( kill -9 $pid >/dev/null 2>&1; zenity --info --text="$wtext2" )

# phase 2

wtext1=`mytranslate "Writing to"`
wtext1="$wtext1 $1\n"
wtext1="$wtext1 "`mytranslate "Estimate to completion..."`

while true
do
# is it still there?  some conversions manipulate the name
	if [ "$frames" = "y" ]
		then	cksize=`echo "$1" | sed 's/frame-.*/frame-/'`
			ckext=`echo "$1" | sed 's/^.*\././'`
		else	if test -s "$1"
				then	cksize="$1"
				else	break
			fi
	fi

# find the size of the target output file
	if [ "$frames" = "y" ]
		then
        newsize=`du -a -b -c "$cksize"????$ckext | tail -1 | awk '{print $1}'`
		else
	newsize=`du -a -b "$1" | awk '{print $1}'`
	fi
# calculate this as a percentage of target file size
        progress="0"`echo "scale=10; $newsize / $3 * $mult" | bc`
	if [ "$progress" = "$oldprogress" ]
# if we are at 100% zenity will exit on its own
# but if the output file stops growing BEFORE 100%, exit out
		then	break
	fi
	oldprogress="$progress"
	showprogress=`echo "$progress" | sed 's/\..*//'`
	sleep 2
	if [ "$showprogress" -ge "99" ]
		then	showprogress=99
	fi
	echo $showprogress
done | zenity --progress --percentage=01 --auto-close --text="$wtext1" || ( kill -9 $pid >/dev/null 2>&1; zenity --info --text="$wtext2" )
}
# end of watcher


#####
# Translate text to other languages
#####
mytranslate() {
#
# use online translation service on text

case $online in
	n)	echo "$*"; exit 0 ;;
esac

case $service in
google)	serviceline="-d langpair=en|$lang http://translate.google.com/translate_t" ;;
babel)	serviceline="-d lp=en_$lang http://babelfish.yahoo.com/translate_txt" ;;
esac

transline=`curl --connect-timeout 1 -m 1 --retry 1 -s -A "Mozilla/5.0" \
	-d "hl=en" -d "ie=UTF8" -d text="$*" $serviceline`

case $service in
	google) echo "$transline" | grep "gtrans" | \
		gawk -F"gtrans value" '{print $2}' | \
		cut -d'"' -f2 | $links -dump | $links -dump | sed 's/^ *//'
		;;
	babel)  echo "$transline" | grep "result" | grep "div" | \
		tr '<>' '~~' | awk -F~ '{print $5}'
		;;
esac
}

#####
# Convert
#####
myavconvert() {
#
# processing images or performing text-to-image conversion

# set -x

# this is for looping after the first item, using the env for settings
looping=n
if test -s /tmp/avconvert.env
	then	. /tmp/avconvert.env
		looping=y
fi

# the output types allowed for

case $it in
	image)  out=" gif jpg ico pdf png tif OTHER"
		height=460 ;;
	text)   out=" gif jpg ico pdf png tif OTHER"
		height=370 ;;
esac

# set default checkbox: all false except the original ext (except txt)
case $imageext in
	none)	out=`echo "$out" | sed -e 's/ / FALSE /g'` ;;
	same)	out=`echo "$out" | sed -e 's/ / FALSE /g' -e "s/FALSE \$ext/TRUE $ext/"` ;;
	*)	out=`echo "$out" | sed -e 's/ / FALSE /g' -e "s/FALSE \$imageext/TRUE $imageext/"` ;;
esac

# show output choices to user and loop until selection is made
while true
do
if [ "$looping" = "n" ]
	then
case $prog$it in
        convertimage)   ident=`identify "$target"`
			ident="$ident\n$imident"
			title=`mytranslate "Converting file"`
			c1=`mytranslate "Convert to format"`
			text=`mytranslate "Source file format"`
			text="$text $show,
$ident

"
			text="$text"`mytranslate "You can select multiple formats - avconvert will loop to create them all.

OUTPUT NAMING: names of the files created will include the proper extension,
and if the resolution differs from the original then a \"-XXX\" before the extension.

Choose OTHER for an output type not listed"`
			choice=`zenity --list --height=$height --title="$title $target" --text="$text" --checklist --column "$s1" --column "$c1" $out` || exit 0
			;;
        converttext)    title=`mytranslate "Convert"`
			text=`mytranslate "Source file format"`
			text="$text $show

"
			text="$text"`mytranslate "Default action is to convert TEXT to IMAGE

Choose OTHER for an output type not listed"`
			c1=`mytranslate "Convert to format"`
			choice=`zenity --list --height=$height --title="$title $target" --text="$text" --checklist --column "$s1" --column "$c1" $out` || exit 0
			;;
esac
fi

if [ -n "$choice" ]
	then	break
fi
done

# was it OTHER?
case $choice in
        OTHER_non-image)  exec myavtext ;;
        OTHER)  title=`mytranslate "Output type"`
		text=`mytranslate "Supply an appropriate file extension"`
		choice=`zenity --entry --title="$title" --text="$text"` || exit 0 ;;
esac

# clean up any _audio reference and any leading . in ext
choice=`echo $choice | sed -e 's/_.*//' -e 's/^\..*//'`

#       loop over (possibly multiple) choice(s)
# (THE OUTER LOOP)
for each in `echo $choice | sed 's/|/ /g'`
do

#       what will the destination filename be?
new=`echo $target | sed -e "s/.$ext$//" -e "s/$/.$each/"`

if [ "$looping" = "n" ]
	then
# set resolution here
# results into $dim, will look like "jpg|gif|pdf"
origrez=`echo "$ident" | sed "s/$target//"`
case $it in
	text)	title=`mytranslate "Dimensions"`
		text=`mytranslate "Output dimensions for"`
		text="$text \"$new\"\n\n"
		text="$text"`mytranslate "This will be the dimension along the longer edge
(depending on portrait or landscape mode)

Choose one or more.
(\"Original\" cannot be combined with other sizes)"`
		c1=`mytranslate "Choose dimensions"`
		dim=`zenity --list --height=520 --title="$title" --text="$text" --checklist --column "$s1" --column "$c1" FALSE 1280 FALSE 1024 FALSE 800 FALSE 640 FALSE 480 FALSE 320 FALSE 250 FALSE 200 FALSE 150 FALSE 100 FALSE "Something else"` || exit 0
		;;
	image)	title=`mytranslate "Dimensions"`
		text=`mytranslate "Output dimensions for"`
		text="$text \"$new\"\n\n"
		text="$text"`mytranslate "This will be the dimension along the longer edge
(depending on portrait or landscape mode)

Choose one or more.
(\"Original\" cannot be combined with other sizes)"`
		c1=`mytranslate "Choose dimensions"`
		dim=`zenity --list --height=580 --title="$title" --text="$text" --checklist --column "$s1" --column "$c1" FALSE "Original dimensions" FALSE 1280 FALSE 1024 FALSE 800 FALSE 640 FALSE 480 FALSE 320 FALSE 250 FALSE 200 FALSE 150 FALSE 100 FALSE "Something else"` || exit 0
		;;
esac
fi

case "$dim" in
	Original*)	dim="" ;;
	Something*)	while true
			do
				text=`mytranslate "New size (along longer edge)"`
				dim=`zenity --entry --text="$text"` || exit 0
				case $dim in
					[0-9]*[0-9])	break ;;
					*)		;;
				esac
			done ;;
esac

# if $safedims is set and $dim is empty
# then set it to what we used last time
if [ -z "$dim" -a -n "$safedims" ]
	then	dims="$safedims"
fi
# parse $dim into $dims
case $dim in
	'')	dims=" " ;;
	*)	dims=`echo $dim | sed 's/|/ /g'` ;;
esac

# and save these $dims for next time
safedims="$dims"
textdims=`mytranslate "Previously selected resolutions:"`
textdims="$textdims: $safedims"

if [ "$looping" = "n" ]
	then
# if this is a jpeg, ask for quality
case "$new" in
	*jpg)	title=`mytranslate "Quality"`
		title="JPG $title"
		text=`mytranslate "Choose quality for"`
		text="$text \"$new\""
		qual=`zenity --list --height=290 --title="$title" --text="$text" --radiolist --column "$s1" --column "$title" FALSE 100 FALSE 90 FALSE 80 TRUE 70 FALSE 60 FALSE 50` || exit 0 ;;
esac

# normalize and equalize
case $it in
	image*)	ntxt=`mytranslate "Adjust for full range of colors"`
		etxt=`mytranslate "Adjust for full range of brightness"`
		normeq=`zenity --list --height=190 --title="Normalize / Equalize" --text="Normalize: $ntxt\nEqualize: $etxt" --checklist --column "$s1" --column "$s2" FALSE normalize FALSE equalize` || exit 0
		case $normeq in
			'')	;;
			*)	normeq=`echo "$normeq" | \
					sed 's/^/-/' | sed 's/|/ -/'`
				case $normeq in
					-normalize*)	normeq=`echo "$normeq" | sed 's/-normalize/-separate -normalize -combine/'`
							;;
				esac
				;;
		esac
		;;
esac
fi

# create arg to convert for quality
case "$new" in
	*jpg)	case $qual in
			'')	quality="-quality 70" ;;
			*)	quality="-quality $qual" ;;
		esac ;;
esac

# echo "$dir"
# echo "$outdir"

case "$dims" in
	*x*x*)	;;
	*)	case "$dir$overwrite" in
			"$outdir")	title=`mytranslate "Overwrite?"`
					text=`mytranslate "Read carefully:

MANY places in this program are designed to prevent accidentally overwriting
your original file(s).  However, since you have chosen the source directory as
your destination AND chosen only one conversion, you have another option.
You can choose (with caution) to REPLACE ORIGINALS with the converted files.
In this case, the converted files will have the original name as well (instead
of inserting the resolution) but with the correct extension.

Choose wisely..."`
					c1=`mytranslate "Overwrite the original files in place?"`
					overwrite=`zenity --list --title="$title" --height=340 --text="$text" --radiolist --column "$s1" --column "$c1" TRUE NO FALSE YES` || exit 0
					;;
		esac
		;;
esac

# loop through all the $dims.
for rez in " "$dims
do
# THE INNER LOOP

case "$rez" in
	" ")	geom="" ;;
	*)	rez=`echo $rez`; geom="-geometry $rez"x"$rez"
		new=`echo $target | sed -e "s/.$ext$//" -e "s/$/.$rez.$each/"` ;;
esac
if test -s "$outdir/$new"
	then	title=`mytranslate "Choose a new Destination Name"`
		text=`mytranslate "exists - Overwrite?"`
		zenity --question --title="$text" --text="$new $text" || newout=`zenity --file-selection --filename="$outdir/$new" --save --confirm-overwrite --title="$title"` || exit 0
		if [ ! -z "$newout" ]
			then	outdir=`dirname "$newout"`
				new=`basename "$newout"`
		fi
fi

case $it in
text)	# EXTRA stuff for TEXT to IMAGE
	colorlist=`convert -list color | sed -n '/,/s/  .*//p' | sort -u`
	colorlist=`echo " "$colorlist | sed 's/ / FALSE /g'`
	if whereis kcolorchooser | grep / >/dev/null
		then	colorlist="FALSE GUI-\"kcolorchooser\" $colorlist"
		else	colortext=`mytranslate "

Install the package \"kdegraphics\" to choose colors with a GUI"`
	fi
	colorlist="FALSE Key-in_RGB-value $colorlist"
	# for OLD version of convert
	# fontlist=`convert -list font | sed -n '/0$/s/ .*//p' | sort -u`
	# for NEW version of convert
	fontlist=`convert -list font | grep Font | sed 's/^.*://' | \
		sed -e 's/^ //g' -e 's/ $//' | sort -u`
	fontlist=`echo " "$fontlist | sed 's/ / FALSE /g'`
	sizelist=" 8 10 12 15 20 25 30 35 40 50 60 80 100 120 150 200 250 300"
	sizelist=`echo "$sizelist" | sed 's/ / FALSE /g'`

	bg=`mytranslate "Background"`
	title="$bg"
	text=`mytranslate "Choose Background Color

NOTE: If you use GUI chooser, the RGB values
will be shown in subsequent windows
for your reference."`
	text="$text $colortext\n\n"
	text=`mytranslate "ALSO NOTE: for some unknown reason
there is a long delay when GUI closes."`
	c1=`mytranslate "Choose color"`
	back=`zenity --list --height=500 --title="$title" --text="$text" --radiolist --column "$s1" --column "$c1" $colorlist` || exit 0
	case $back in
		GUI-*)	back=`kcolorchooser --print` ;;
		_GUI*)	text=`mytranslate "To choose colors using a GUI
interface, install the"`
			text="$text \"kdegraphics\""
			text="$text "`mytranslate "package"`
			zenity --info --title="kcolorchooser" --text="$text"
			exit 0
			;;
		Key-*)	title=`mytranslate "Key in color"`
			text=`mytranslate "Enter the RGB color as"`
			back=`zenity --entry --title="$title" --text="$text  #RGB  #RRGGBB  #RRRGGGBBB  #RRRRGGGGBBBB  rgb(rrr,ggg,bbb)"` || exit 0
			;;
	esac
	fg=`mytranslate "Foreground"`
	title="$fg"
	text=`mytranslate "Choose Foreground Color"`
	fill=`zenity --list --height=500 --title="$title" --text="[$bg = $back]\n\n$text" --radiolist --column "$s1" --column "$c1" $colorlist` || exit 0
	case $fill in
		GUI-*)	fill=`kcolorchooser --print` ;;
		_GUI*)	kdeg=`mytranslate "To choose colors with a GUI
interface, install the \"kdegraphics\" package"`
			zenity --info --title="kcolorchooser" --text="$kdeg"; exit 0 ;;
		Key-*)	title=`mytranslate "Key in color"`
                        text=`mytranslate "Enter the RGB color as"`
			fill=`zenity --entry --title="$title" --text="$text:  #RGB  #RRGGBB  #RRRGGGBBB  #RRRRGGGGBBBB  rgb(rrr,ggg,bbb)"` || exit 0 ;;
	esac
	title=`mytranslate "Border Width"`
	text=`mytranslate "Choose Border Width"`
	borw=`zenity --list --height=340 --title="$title" --text="[$bg = $back]\n[$fg = $fill]\n\n$text" --radiolist --column "$s1" --column "$text" FALSE 0 FALSE 5 FALSE 10 FALSE 20 FALSE 30 FALSE 50` || exit 0
	case $borw in
		0)	borc=`mytranslate "transparent"` ;;
		*)	title=`mytranslate "Border Color"`
			text=`mytranslate "Border Width"`
			borc=`zenity --list --height=500 --title="$title" --text="[$bg = $back]\n[$fg = $fill]\n[$text = $borw]\n\n$title" --radiolist --column "$s1" --column "$title" $colorlist` || exit 0 ;;
	esac
	case $borc in
		GUI-*)	borc=`kcolorchooser --print` ;;
		_GUI*)	zenity --info --title="kcolorchooser" --text="$kdeg"; exit 0 ;;
		Key-*)	title=`mytranslate "Key in color"`
                        text=`mytranslate "Enter the RGB color as"`
			borc=`zenity --entry --title="$title" --text="$text:  #RGB  #RRGGBB  #RRRGGGBBB  #RRRRGGGGBBBB  rgb(rrr,ggg,bbb)"` || exit 0 ;;
	esac
	title=`mytranslate "Font"`
	text=`mytranslate "Choose text font and style"`
	font=`zenity --list --height=500 --title="$title" --text="[$bg = $back]\n[$fg = $fill]\n[Border width is $borw]\n[Border color is $borc]\n\n$text" --radiolist --column "$s1" --column "$title" $fontlist` || exit 0
	title=`mytranslate "Font Size"`
	text=`mytranslate "Choose text font size"`
	size=`zenity --list --height=500 --title="$title" --text="[$bg = $back]\n[$fg = $fill]\n[Border width is $borw]\n[Border color is $borc]\n[Font style is $font]\n\n$text" --radiolist --column "$s1" --column "$title" $sizelist` || exit 0
	textoptions="-background $back -fill $fill -border $borw -bordercolor $borc -font $font -pointsize $size label:@"
	longestline=`cat "$target" | awk 'BEGIN {max[i]=0}
                        (length >= max[i]) {max[i] = length}
                        END {printf "%s\n", max[i]}'`
	# horizrez=`echo -e "scale=0\n$rez * 8 / 11\nquit\n" | bc`
	horizrez=$rez
	maxpossible=`echo -e "scale=0\n$horizrez / $size\nquit\n" | bc`
	# splitpieces=`echo -e "scale=0\n$longestline / $maxpossible\nquit\n" | bc`
	newlength=`echo -e "scale=2\n$maxpossible * .9\nquit\n" | bc`
	newlength=`echo "$newlength" | sed 's/\..*//'`
	if [ "$longestline" -ge "$maxpossible" ]
		then	newtarget=`echo "$target" | sed "s/$ext$/wrap$newlength/"`
			title=`mytranslate "Adjusting input file"`
			text=`mytranslate "The source file \"1\" contains long lines.

The longest line is 2 but the max possible with an
image width of 3 and a font size of 4 is 5.

Creating an intermediate text file with a word wrap at
the first space after character position 6.

This will get you APPROXIMATELY the
character size you asked for.
The intermediate file will contain the full text of 7.

Intermediate file name is: 8"`
			text=`echo "$text" | \
			sed -e "s/1/$target/" -e "s/2/$longestline/" \
			-e "s/3/$horizrez/" -e "s/4/$size/" \
			-e "s/5/$maxpossible/" -e "s/6/$newlength/" \
			-e "s/7/$target/" -e "s/8/$newtarget/"`
			
			zenity --info --title="$title" --text="$text"
		sed "s/.\{$newlength\} /&\n/g" < "$target" > "$newtarget"
			target="$newtarget"
	fi

	linecount=`wc $target | awk '{print $1}'`
	maxpossible=`echo -e "scale=2\n$rez / $size\nquit\n" | bc`
	maxpossible=`echo -e "scale=2\n$maxpossible * 2 / 3\nquit\n" | bc`
	maxpossible=`echo "$maxpossible" | sed 's/\..*//'`

	if [ "$linecount" -gt "$maxpossible" ]
		then	shorttarget=`echo $target | sed 's/$ext$//'`
			title=`mytranslate "Adjusting input file"`
			text=`mytranslate "The source file \"1\" contains too many lines.
Adjusting for a more normal aspect ratio.

There are 2 lines, but the max possible
with a length of 3 and a size of 4 is 5.

Splitting 6 into a set of files with 7
lines in each.  The resulting files will be processed.

This will get you APPROXIMATELY the
character size you asked for.

Intermediate files will be named 8"aa.txt", 8"ab.txt", 8"ac.txt", and so on."`
			text=`echo "$text" | \
			sed -e "s/1/$target.txt/" -e "s/2/$lincount/" \
			-e "s/3/$rez/" -e "s/4/$size/" \
			-e "s/5/$maxpossible/" -e "s/6/$target.txt/" \
			-e "s/7/$maxpossible/" -e "s/8/$shorttarget/g"`
			zenity --info --title="$title" --text="$text"
			cat "$target" | split -$maxpossible - "$shorttarget"
			targets=`ls $shorttarget??`
			multiple=y
			for each in `ls $shorttarget??`
			do
				mv "$each" "$each.txt"
			done
	fi
	;;
esac
#End of extra stuff for text to image

# Now, do the actual conversion

# usually just one target
targets="$target"

# in a text->image that needed splitting will be multiple $targets
case $multiple in
	y)	count=1
		targets=`ls $shorttarget??*`
		basenew="$new" ;;
esac

echo "$targets" | \
while read target
do
case $multiple in
	y)	case $count in
			?)	count="00"$count ;;
			??)	count="0"$count ;;
		esac
		new=`echo "$basenew" | sed "s/\....$/.$count&/"`
		;;
esac
text=`mytranslate "Working on"`
oldsize=`du -a -b "$target" | awk '{print $1}'`
avwatcher "$outdir/$new" "$prog" "$oldsize" $$ &
#convert -verbose $geom $quality $normeq $textoptions"$target" "$outdir/$new" 2>/tmp/convert.$$.$count | zenity --progress --text="$text $new" --auto-close --auto-kill --pulsate
convert -verbose $geom $quality $normeq $textoptions"$target" "$outdir/$new" >/tmp/convert.$$.$count 2>&1
case $overwrite in
	YES)	rename=`echo "$target" | sed "s/$ext$/$each/"`
		mv "$outdir/$new" "$rename"
		rm "$target" ;;
esac
# ImagMagick/convert may call ufraw for camera raw images
# there is a new version of ufraw with slightly different options
# convert is using old options, causing a "deprecated" complaint
# but the results are good as old options are still accepted.
cleanup=`egrep -v "deprecated|ppm16" /tmp/convert.$$.$count` >/tmp/$$
mv /tmp/$$ /tmp/convert.$$.$count
if test -s /tmp/convert.$$.$count
	then	message=`cat /tmp/convert.$$.$count`
		text=`mytranslate "An error occured during the conversion

The message was: "`
		zenity --info --text="$text $message" &
	else	rm -f /tmp/convert.$$.$count
fi

case $multiple in
	y)	count=`expr $count + 1` ;;
esac
# end of multiple $targets loop
done

# end of inside loop for $rez
done
# end of outside loop for $dims
done 

# convert -verbose $geom $quality $textoptions"$target" "$outdir/$new" 2>/tmp/convert.$$.$count | zenity --progress --text="Working on $new" --auto-close --auto-kill --pulsate

case $autoloop in
	y)	echo "
			choice=\"$choice\"
			dim=\"$dim\"
			dims=\"$dims\"
			geom=\"$geom\"
			qual=\"$qual\"
			textoptions=\"$textoptions\"
			normeq=\"$normeq\"
				" > /tmp/avconvert.env ;;
esac
}
# end of avconvert



#####
# ffmpeg
#####
myavffmpeg() {
#
# processing audio and video

# set -x
# this is for looping after the first item, using the env for settings
looping=n
if test -s /tmp/avffmpeg.env
	then	. /tmp/avffmpeg.env
		looping=y
fi

# set up output extensions
case $av in
	video)  out=" 3gp asf avi flv mp4 mov mpg rm wmv m4a_audio_only mp3_audio_only wav_audio_only wma_audio_only jpeg_frames OTHER"
		height=650 ;;
	audio)  out=" m4a mp3 wav wma OTHER"
		height=360 ;;
esac

out=`echo "$out" | sed -e 's/ $ext //' -e "s/ / FALSE /g"`

# loop for output conversion type
if [ "$looping" = "n" ]
	then
while true
do
title=`mytranslate "Convert"`
text1=`mytranslate "Source file information"`
text2=`mytranslate "Choose OTHER for an output type not listed"`
choice=`zenity --list --height=$height --title="$title $target" --text="$text1 $show\n$ffident\n\n$text2" --radiolist --column "$s1" --column "$title" $out` || exit 0

if [ -n "$choice" ]
        then      break
fi
done
fi

# was it OTHER?
case $choice in
        OTHER)  title=`mytranslate "Output type"`
		text=`mytranslate "Supply a valid file extension, example "`
		choice=`zenity --entry --title="$title" --text="$text ogg / vob"` || exit 0 ;;
esac


case $choice in
	*_audio*)	av=audio; choice=`echo $choice | sed 's/_.*//'` ;;
	*_frames)	av=frame; choice=`echo $choice | sed 's/_.*//'`
			outf=`echo $choice | awk -F_ '{print $1}'`
			title=`mytranslate "Frame capture"`
			text=`mytranslate "Seconds between frame captures
\"0\" means capture every frame

Do not exceed about 2/3 of the frame
rate displayed above"`
			step=`zenity --scale --title="$title" --text="$ffident\n\n$text" --value=1 --min-value=0 --max-value=60 --step=1` || exit 0
			step="1/$step"
			;;
esac

# we now have the output type

# ffmpeg options from options files
## SEED THE FILES IF NOT PRESENT
# recreate the audio and video files, create custom if not present

cat <<!audio > ~/.config/avconvert/avconvert.ffopts.audio
# ~/.config/avconvert/avconvert.ffopts.audio
#
# This file will NOT be overwritten by updates, but if you remove it then
# a new one will be created with all new options from the latest release
#
# An option must not contain spaces!
# The format MUST be "acodec-XXX" where XXX is supported by ffmpeg
#
# There MUST be only two "words" per line, separated by a space
# TRUE or FALSE followed by an option.  The option has the "-" moved
#   so that "-option parameter" becomes "option-paramater".
# These can be combined by separating them with "~", as in
#   option1-parameter~option2-paramater
# A comment may be added by following options with "#comment" as in 
#   option1-parameter~option2-parameter#My-Comment-here
# But there must be ONLY ONE space in each line
TRUE AUDIO-CODEC-UNCHANGED
FALSE acodec-ac3
FALSE acodec-mp2
FALSE acodec-libmp3lame
TRUE AUDIO-SAMPLE-RATE-UNCHANGED
FALSE ar-44100
FALSE ar-22050
TRUE AUDIO-BITRATE-UNCHANGED_default=64k
FALSE ab-128k
TRUE VOLUME-UNCHANGED_default=256
FALSE vol-512
!audio

cat <<!video > ~/.config/avconvert/avconvert.ffopts.video
# ~/.config/avconvert/avconvert.ffopts.video
#
# This file will NOT be overwritten by updates, but if you remove it then
# a new one will be created with all new options from the latest release
#
# There MUST be only two "words" per line, separated by a space
# TRUE or FALSE followed by an option.  The option has the "-" moved
#   so that "-option parameter" becomes "option-paramater".
# These can be combined by separating them with "~", as in
#   option1-parameter~option2-paramater
# A comment may be added by following options with "#comment" as in 
#   option1-parameter~option2-parameter#My-Comment-here
# But there must be ONLY ONE space in each line
#
# The SIZE option here (-w) is NOT actually an ffmpeg option.  The real
# size option is "-s WWWxHHH" where WWW and HHH are width and height and
# would be written in an ffopts file as "s-WWWxHHH".  However, both here
# and in ffopts.custom and ffopts.submissions, this script will use the
# "-w WWW" (w-WWW) to trigger automatic resizing of the height to preserve
# the original aspect ratio.  The supplied and calculated values will also
# be rounded down to the nearst multiple of 2 pixels
#
# The DISPLAY option (-d) is ALSO not a true ffmpeg option.  It will be
# used to determine if the video needs to be letterboxed so that aspect
# ration is preserved when played on your device.  So regardless of SIZE,
# if the original aspect does not match your specified DISPLAY, the math
# will be done for you and black bands added to make the video fit.
# Again, this form may also be used in .custom and .submissions files.
TRUE VIDEO-SIZE-UNCHANGED#you_choose_width/height_will_be_calculated/aspect_retained
FALSE w-128
FALSE w-320
FALSE w-640
TRUE DO-NOT-LETTERBOX#choose_aspect_of_your_player_to_avoid_stretching
FALSE d-1.3333#4:3
FALSE d-1.5#Apple_iPhone
FALSE d-1.7778#16:9
TRUE VIDEO-CODEC-UNCHANGED
FALSE vcodec-libx264
FALSE vcodec-mjpeg
FALSE vcodec-mpeg2video
!video

[ ! -f ~/.config/avconvert/avconvert.ffopts.custom ] && \
cat <<!custom > ~/.config/avconvert/avconvert.ffopts.custom
# ~/.config/avconvert/avconvert.ffopts.custom
#
# The purpose of THIS file is that you can create option-sets that
# you use often, and apply them with a single click in avconvert
#
# This file will NOT be overwritten by updates, but if you remove it then
# a new one will be created with all new options from the latest release
# 	
# There MUST be only two "words" per line, separated by a space
# TRUE or FALSE followed by an option.  The option has the "-" moved
#   so that "-option parameter" becomes "option-paramater".
# These can be combined by separating them with "~", as in
#   option1-parameter~option2-paramater
# A comment may be added by following options with "#comment" as in 
#   option1-parameter~option2-parameter#My-Comment-here
#   s-640x480~vcodec-mpeg2video#my_custom_options
# But there must be ONLY ONE space in each line
#
# An option for SIZING (-w) is NOT actually an ffmpeg option.  The real
# size option is "-s WWWxHHH" where WWW and HHH are width and height and
# would be written in an ffopts file as "s-WWWxHHH".  However, both here
# and in ffopts.custom and ffopts.submissions, this script will use the
# "-w WWW" (w-WWW) to trigger automatic resizing of the height to preserve
# the original aspect ratio.  The supplied and calculated values will also
# be rounded down to the nearst multiple of 2 pixels
#
# The DISPLAY option (-d) is ALSO not a true ffmpeg option.  It will be
# used to determine if the video needs to be letterboxed so that aspect
# ration is preserved when played on your device.  So regardless of SIZE,
# if the original aspect does not match your specified DISPLAY, the math
# will be done for you and black bands added to make the video fit.
# Again, this form may also be used in .custom and .submissions files.

TRUE NO-CUSTOM-OPTIONS_these.are.created.using.KEY-IN
FALSE s-640x480~vcodec-mpeg2video~acodec-mp2#Sample_custom_command
!custom

grep tsi-inc ~/.config/avconvert/avconvert.ffopts.custom >/dev/null || cat <<!message >> ~/.config/avconvert/avconvert.ffopts.custom
#
# One more thing:  if you come up with some handy (or necessary) option
# sets for specific conversions and submit them to me, I will start
# maintaining a ~/.config/avconvert/avconvert.ffopts.submissions file and
# regularly post it for download.
# Just email me your option line in the format below.
# Include a comment section, and describe the circumstances that require
# it.  For example "when the input file is *.xxx and the output file is
# *.yyy and ffmpeg identifies the audio stream as zzz.
# Send submissions to:  tsi-inc@comcast.net
# and include "avconvert submission" in the subject line.
!message
cat <<!ffmpeghelp > ~/.config/avconvert/avconvert.ffmpeg-help
NOTE: an option like "-ss 60 -t 30" (seek in 60 seconds and record 30 seconds)
would be written in ~/.config/avconvert/avconvert.ffopts* as:
	ss-60~t-30#seek-60_record-30
but here, use standard command-line syntax, like this:
	-ss 60 -t 30

-t time		"time" is in seconds OR HH:MM:SS.xxx			stop recording after "time"
-fs NNN		"filesize" in bytes							stop recording at this "size"
-f FFF		format as in "rawvideo" "oss"
-ss time		"time is in seconds OR HH:MM:SS				start recording at "time"
-target		eg. "vcd" "dvd" "ntsc" sets all appropriate options for this type
-b rate		video bitrate in bit/s						default "200 kb/s" (200000)
-r fps		video frames per second in HZ					default "25" fps
-s size		frame size HHHxVVV (default is retain original)	HORIZONTALxVERTICAL size
-aspect		4:3  16:9  1.3333  1.7777
-croptop		NN crop NN pixels from the top				produces a band
-cropbottom	-cropleft   -cropright						(see croptop)
-padtop		NN  pad NNN pixels on the top				produces a band
-padbottom	-padleft   -padright							(see padtop)
-padcolor		H 6-digit HEX value (eg 000000) for padded bands
-vcodec		CC  CC is codec name as in "libxvid" "mpeg4"
-pass N		N = 1 or 2                             					1-pass or 2-pass vid encoding
-ilme		(MPEG-2/4) if input interlaced, retain it for higher quality
-ar			NNN     audio sample frequency 44100/22050/11025 default 44100
-ab			NNN     audio birate in bit/s                		 	 default 64k
-ac			N       number of audio channels             		 	 default 1
-an			disable audio recording
-acodec CCC	audio codec name as in "ac3" "mp2"
-tvstdc SSS	set TV standard to NTSC PAL SECAM
-shortest		finish recording when shortest input stream ends

Not OFFICIALLY ffmpeg options, but handled by avconvert:

-w			WWW	specify a new video width, height is calculated for you
-d			A.AAAA	specify the HxW ratio of a display device for letterboxing to preserve aspect ratio
!ffmpeghelp

## END OF SEEDING THE FILES
# THE WORK STARTS HERE...

# If we are NOT in a loop, ask for options...
if [ "$looping" = "n" ]
	then
case $av in
	audio)	storedopts=`cat ~/.config/avconvert/avconvert.ffopts.audio ~/.config/avconvert/avconvert.ffopts.custom ~/.config/avconvert/avconvert.ffopts.submissions 2>/dev/null` ;;
	video)	storedopts=`cat ~/.config/avconvert/avconvert.ffopts.audio ~/.config/avconvert/avconvert.ffopts.video ~/.config/avconvert/avconvert.ffopts.custom ~/.config/avconvert/avconvert.ffopts.submissions 2>/dev/null` ;;
esac
storedopts=`echo "$storedopts" | sed 's/^#.*//'`

title=`mytranslate "More options"`
text1=`mytranslate "Source file:"`
text2=`mytranslate "Select a combination of options, or leave any UNCHANGED.
You may choose options here AND click KEY-IN-OPTIONS.  The selected and keyed options will both be used.
There is a help page for key-in options.

These options are stored in ~/.config/avconvert/avconvert.ffopts* and you can modify them!
Use your favorite text editor and follow instructions in those files."`
c1=`mytranslate "Choose ONLY ONE from each category"`

ffopts=`zenity --list --height=600 --title="$title" --text="$text1 $target\n$ffident\n\n$text2" --checklist --column "$s1" --column "$c1" $storedopts FALSE KEY-IN-OPTIONS` || exit 0

if echo "$ffopts" | grep KEY-IN-OPTIONS >/dev/null
	then	title=`mytranslate "Quick list of ffmpeg options"`
		zenity --info --no-wrap --title="FFMPEG:  $title" --text="`cat ~/.config/avconvert/avconvert.ffmpeg-help`" 2>/dev/null &
		sleep .5
		zpid=`ps -ef | grep -v grep | grep -e "--title=FFMPEG:" | \
			awk '{print $2}'`
		title=`mytranslate "Key in your options"`
		text=`mytranslate "Examples (leave blank for none)
"`
		text2=`mytranslate "

If you add a comment, then your options will be saved for future use
in ~/.config/avconvert.ffopts.custom.  Example:   "`
		text3=`mytranslate "My favorite"`
dopts=`echo "$ffopts" | tr '|' '\012' | sed 's/^[A-Z].*//' | grep -v '^$'`
dopts=`echo "$dopts" | sed -e 's/^/ /' -e 's/#.*//'`
dopts=`echo "$dopts" | sed -e 's/~/ /g' -e 's/-/~/g' -e 's/ / -/g' -e 's/~/ /g'`
case "$dopts" in
	" -")	dopts="" ;;
esac
		keyin=`zenity --entry --title="$title" --text="$text     -acodec mpeg3 -vcodec libx264 -ab 320k$text2 -acodec mpeg2 -vcodec libx264 # $text3

Current ffmpeg options:  $dopts"`
		kill -15 $zpid >/dev/null 2>&1
		if echo "$keyin" | grep "#" >/dev/null
			then
			opt=`echo "$keyin" | sed -e 's/  */ /g' -e 's/^ //'`
			com=`echo "$opt" | sed -e 's/^.*#//' \
				-e 's/^ //' -e 's/ $//' -e 's/ /_/g'`
			opt=`echo "$opt" | sed 's/#.*//'`
			for word in $opt
			do
				case $word in
				-*)	line=$line`echo $word | sed 's/-//'` ;;
				*)	line=$line-$word~ ;;
				esac
			done
			line=`echo "$line#$com" | sed 's/~#/#/'`
			echo "FALSE $line" >> ~/.config/avconvert/avconvert.ffopts.custom
			keyin=`echo "$keyin" | sed 's/#.*//'`
		fi
fi

# manage the SPECIAL options for resizing and letterboxing
size=`echo "$ffident" | grep Video | awk '{print $6}'`	#current size per ffmpeg
size=`echo $size | sed 's/,//'`
curw=`echo $size | sed 's/x.*$//'`			#current width
oldw=$curw
curh=`echo $size | sed 's/^.*x//'`			#current height
cura=`echo -e "scale=2\n$curw / $curh\nquit" | bc`	#current aspect
wopt=`echo "$ffopts" | grep "w-" | sed 's/^.*w-//' | \
	sed -e 's/|.*//' -e 's/#.*//'` 			#new width
neww=$wopt
disp=`echo "$ffopts" | grep "d-" | sed 's/^.*d-//' | \
	sed -e 's/|.*//' -e 's/#.*//'`			 #disp asp
if [ ! -z "$neww" ]
	then	neww=`expr $neww / 2 \* 2`		#round down
		scale=`echo -e "scale=5\n$curw / $neww\nquit" | bc` #height chg
		newh=`echo -e "scale=5\n$curh / $scale\nquit" | bc` # new HHH
		newh=`echo $newh | sed 's/\..*//'`	#integer
		newh=`expr $newh / 2 \* 2`		#round down
		curh=$newh				#new HHH
		oldw=$curw
		curw=$neww
		nopt="$neww"x"$newh"			#WWWxHHH string
		ffopts=`echo "$ffopts" | sed "s/w-$wopt/s-$nopt/"` #substitute
fi

if [ ! -z "$disp" ]
then	# *10000 and remove decimal, so "test" can treat as integer
	# which aspect is wider? to calculate padding
	curam=`echo -e "scale=5\n$cura * 10000\nquit" | bc`
	dispm=`echo -e "scale=5\n$disp * 10000\nquit" | bc`
	curam=`echo $curam | sed 's/\..*//'`
	dispm=`echo $dispm | sed 's/\..*//'`
	if [ "$cura" != "$disp" ]
	then	if [ "$curam" -ge "$dispm" ]
			then	# current aspect is wider than target aspect
				# pad top and bottom
		xtra=`echo -e "scale=5\n$cura / $disp * $curh\nquit" | bc` #dots
			pad=tb
			else	# target aspect is wider than current aspect
				# pad left and right
		xtra=`echo -e "scale=5\n$disp / $cura * $curw\nquit" | bc` #dots
			pad=lr
		fi
		# $xtra is the total dots HHH or WWW in display aspect
		xtra=`echo $xtra | sed 's/\..*//'`	#integer
		# ACTUAL pad is $xtra - soze-of-image
		case $pad in
			tb)	xtra=`expr $xtra - $curh + 1` ;;  #subtract HHH
			lr)	xtra=`expr $xtra - $curw + 1` ;;  #subtract WWW
		esac
		# the padding should be half/half either L/R or T/B
		xtra=`expr $xtra / 2`			#top/bottom
		xtra=`expr $xtra / 2 \* 2`		#round down
		# create command option
		case $pad in
			tb)	padding="padtop-$xtra|padbottom-$xtra" ;;
			lr)	padding="padleft-$xtra|padright-$xtra" ;;
		esac
		ffopts=`echo "$ffopts" | \
			sed "s/d-$disp/$padding|aspect-$disp/"`
	fi
fi
## end of aspect and padding section

ffopts=`echo "$ffopts" | tr '|' '\012' | sed 's/^[A-Z].*//' | grep -v '^$'`
ffopts=`echo "$ffopts" | sed -e 's/^/ /' -e 's/#.*//'`
ffopts=`echo "$ffopts" | sed -e 's/~/ /g' -e 's/-/~/g' -e 's/ / -/g' -e 's/~/ /g'`
case "$ffopts" in
	" -")	ffopts="" ;;
esac

ffopts="$ffopts $keyin"
# echo -e "\n\nThe final ffmpeg options look like this:\n"
# echo $ffopts

# END OF OPTION-SETTING
fi

new=`echo $target | sed "s/$ext$/$dot$choice/"`

case $av in
	frame)	new="$target.frame-%04d.$outf"
		specialopts="-r $step -f image2" ;;
esac

case $new in
	*3gp)	x264=`ls /usr/lib/*x264* | sed 's/\..*//' | head -1`
		x264=`basename $x264`
		specialopts="-vcodec $x264 -acodec libfaac" ;;
	*flv)	case "$ffopts" in
			*-ar*)	;;
			*)	ar=`echo "$ffident" | grep Audio | \
				awk -F, '{print $2}' | 
				sed -e 's/Hz//' -e 's/ //g'`
				if [ "$ar" -gt "11025" ]
					then	nr=11025
				fi
				if [ "$ar" -gt "22050" ]
					then	nr=22050
				fi
				if [ "$ar" -gt "44100" ]
					then	nr=44100
				fi
				ffopts="$ffopts -ar $nr"
				;;
		esac
esac

case "$outdir/$new" in
	"$dir/$target")	title=`mytranslate "Destination file has the same name as source!!  Choose a new name"`
			newout=`zenity --file-selection --filename="$outdir/$new" --save --confirm-overwrite --title="$title"` || exit 0
			outdir=`dirname "$newout"`
			new=`basename "$newout"`
			;;
esac

if test -s "$outdir/$new"
	then    text=`mytranslate "exists - Overwrite?

(OK to overwrite, Cancel to supply a new name)"` 
		zenity --question --text="$outdir/$new $text" || newout=`zenity --file-selection --filename="$outdir/$new" --save --confirm-overwrite --title="Choose a new file/folder"` || exit 0
		if [ ! -z "$newout" ]
			then	outdir=`dirname "$newout"`
				new=`basename "$newout"`
		fi
fi

oldsize=`du -a -b "$target" | awk '{print $1}'`
avwatcher "$outdir/$new" "$prog" "$oldsize" $$ &

echo -e "ffident:\n$ffident\n" >/tmp/ffmpeg.$$
echo "ffmpeg command as executed:" >>/tmp/ffmpeg.$$
echo ffmpeg -y -i "$target" $specialopts $ffopts "$outdir/$new" >>/tmp/ffmpeg.$$
echo >>/tmp/ffmpeg.$$
# set -x
ffmpeg -y -i "$target" $vol $specialopts $ffopts "$outdir/$new" 2>&1 | tr '=' '\012' >> /tmp/ffmpeg.$$

result=`tail -5 /tmp/$prog.$$`
result="$result

The full text output from this conversion is in /tmp/$prog.$$
"

grep "lame: output buffer too small" /tmp/ffmpeg.$$ && note=`mytranslate "
The message about libmp3lame buffer is meaningless.
If that is the only complaint message, the conversion did work."`

grep "bitrate tolerance too small" /tmp/ffmpeg.$$ && note=`mytranslate "
The message about bitrate tolerance too small is due
to the way ffmpeg works.  Seconds between frames can not be
larger than about 2/3 of the frames per second in the video.

POSSIBLE SOLUTION:  Specify a smaller seconds between frames"`

grep "does not support" /tmp/ffmpeg.$$ && note=`mytranslate "
ffmpeg requires more/different options for this conversion
	OR
your source file is unusual and requires special options

POSSIBLE SOLUTIONS:
	specify a video or audio codec
	specify a sample rate
	specify a different output size"`

newsize=`du -a -b "$new" | sed 's/   .*//'`
# show results summary
case $quiet in
	y)	notify="--notification --window-icon=/usr/share/zenity/zenity-progress.png"
		cp /usr/share/zenity/zenity.glade.progress-under /usr/share/zenity/zenity.glade 2>/dev/null ;;
	n)	notify="--info"
		cp /usr/share/zenity/zenity.glade.progress-over /usr/share/zenity/zenity.glade 2>/dev/null ;;
esac

title=`mytranslate "Conversion results"`
text=`mytranslate "Last message in"`
text2=`mytranslate "File size:"`
zenity $notify --title="$title" --text="$target --> $new
$text2 $newsize
$note

$prog $text /tmp/$prog.$$:
$result" &
sleep .25
zpid=`ps -ef | grep -v grep | grep -e "--notification" | awk '{print $2}'`
(sleep 60; kill -9 $zpid >/dev/null 2>&1)

case $autoloop in
	y)	echo -e "choice=\"$choice\"\nbits=\"$bits\"" > /tmp/avffmpeg.env ;;
esac
}
# end of ffmpeg


#####
# ISO conversions
#####
myaviso() {

case $it in
	bchunk)	
		whereis bchunk | grep / >/dev/null || exec zenity --warning --text="Must install \"bchunk\" package first!"
		tracks=`grep TRACK $base.cue | awk '{print $2}'`
		zenity --question --text="BIN/CUE to ISO conversion\nCUE shows tracks $tracks\nProgress will be idicated for first track only\nwhich will be named "$base"01.iso" || exit 0
		new="$outdir/$base"
		if test -s "$new"01.iso
			then    zenity --question --text="$new"01.iso" exists - Overwrite?" || new=`zenity --file-selection --filename="$outdir/$new" --save --confirm-overwrite --title="Choose a new file/folder"` || exit 0
		fi
		prog=bchunk
		oldsize=`du -a -b "$base.bin" | awk '{print $1}'`
		avwatcher "$new"01.iso "$prog" "$oldsize" $$ &
		bchunk "$base.bin" "$base.cue" "$new" >/tmp/bchunk.$$ 2>&1
		;;
        daa*|nrg*|b?i*|cdi*|mdf*|pdi*|ccd*|uif*)
		whereis $it | grep / >/dev/null || exec zenity --warning --text="No program \"$it\" found for processing \"$target\"!\n\nFor ISO conversions, install one or more of these packages...\n\nAcetoneISO for:  b5i cdi mdf nrg pdi\nnrg2iso for:     nrg\ndaa2iso for:     daa\nbchunk for:      bin/cue\nccd2iso for:     cdd\nuif2iso for:      uif\n\ncdd2iso is available at: sourceforge.net/projects/ccd2iso\nuif2iso is available at: aluigi.altervista.org/mytoolz.htm\n\nthe rest are in the repositories."
		base=`echo $target | sed 's/....$//'`
                zenity --question --text="Source file is $target\n$ext to ISO conversion\nwhich will be named $base.iso" || exit 0
                new="$outdir/$base".iso
                if test -s "$new".iso
                        then     zenity --question --text="$new".iso" exists - Overwrite?" || new=`zenity --file-selection --filename="$outdir/$new" --save --confirm-overwrite --title="Choose a new file/folder"` || exit 0
				new="$new".iso
                fi
		prog=$ext"2iso"
		oldsize=`du -a -b "$target" | awk '{print $1}'`
		avwatcher "$new" "$prog" "$oldsize" $$ &
		case $ext in
			b?i|pdi)	new="" ;;
		esac
		$prog "$target" "$new" >/tmp/$prog.$$ 2>&1
		;;
esac

}
# end of iso conversions
#####
# Text conversions
#####
myavtext() {
#
# processing text between formats and into other things

# set -x

case $it in
	text)	# image->avconvert sound->espeak html->txt2tags
		out=" image sound html"; height=300 ;;
	doc)	# text->antiword
		out=" text"; height=300 ;;
	rtf)	# text->unrtf html->unrtf
		out=" text html"; height=300 ;;
	odt)	# text->odt2txt xml->odt2txt
		out=" text xml"; height=300 ;;
esac

out=`echo "$out" | sed -e 's/ $ext //' -e "s/ / FALSE /g"`

# loop for output conversion type
while true
do
title=`mytranslate "Convert"`
text=`mytranslate "Source file format"`
text2=`mytranslate "Convert to format"`
choice=`zenity --list --height=$height --title="$title $target" --text="$text $show\n$ffident\n" --radiolist --column "$s1" --column "$text2" $out` || exit 0

if [ -n "$choice" ]
        then      break
fi
done

# pre-check for installed application
case $it$choice in
	textsound)	if ! whereis espeak | grep / >/dev/null
			then	zenity --warning --title=HELP --text="\"espeak\" package needs to be installed"
				exit 0
			fi ;;
	texthtml)	if ! whereis txt2tags | grep / >/dev/null
			then	zenity --warning --title=HELP --text="\"txt2tags\" package needs to be installed"
				exit 0
			fi ;;
	doctext)	if ! whereis antiword | grep / >/dev/null
			then	zenity --warning --title=HELP --text="\"antiword\" package needs to be installed"
				exit 0
			fi ;;
esac

case $it$choice in
	textimage)	prog=convert; myavconvert 2>/tmp/avconvert.debug ;;
	textsound)	title=`mytranslate "Language"`
			text=`mytranslate "Choose a language for pronunciation"`
			pronun=`zenity --list --height=500 --title="$title" --text="$text" --radiolist --column "$s1" --column "$title" FALSE af_afrikaans FALSE bs_bosnian FALSE cs_czech FALSE cy_welsh FALSE de_german FALSE el_greek TRUE en_english FALSE es_spanish FALSE fi_finnish FALSE fr_french FALSE hi_hindi FALSE hr_croatian FALSE hu_hungarian FALSE is_icelandic FALSE it_italian FALSE la_latin FALSE mk_macedonian FALSE nl_dutch FALSE no_norwegian FALSE pl_polish FALSE pt_brazil FALSE ro_romanian FALSE ru_russian FALSE sk_slovak FALSE sr_serbian FALSE sv_swedish FALSE sw_swahihi FALSE vi_vietnam FALSE zh_Mandarin` || exit 0
			pronun=`echo $pronun | sed 's/_.*//'`
			title=`mytranslate "Voice"`
			text=`mytranslate "Choose voice to use"`
			voice=`zenity --list --height=400 --title="$title" --text="$text" --radiolist --column "$s1" --column "$title" FALSE m1_male-1 FALSE m2_male-2 FALSE m3_male-3 FALSE m4_male-4 FALSE f1_female-1 TRUE f2_female-2 FALSE f3_female-3 FALSE f4_female-4 FALSE croak FALSE whisper` || exit 0
			voice=`echo $voice | sed 's/_.*//'`
			text=`mytranslate "Pitch"`
			pitch=`zenity --scale --text="$text" --min-value=0 --max-value=99 --value=50` || exit 0
			text=`mytranslate "Speed"`
			speed=`zenity --scale --text="$text" --min-value=0 --max-value=99 --value=43` || exit 0
			speed=`expr $speed \* 4`
			new=`echo "$target" | \
				sed -e 's/.txt$//' -e 's/$/.wav/'`
			oldsize=`du -a -b "$target" | awk '{print $1}'`
			avwatcher "$outdir/$new" "$prog" "$oldsize" $$ &
			cat "$target" | espeak --stdin -v$pronun+$voice -p $pitch -s $speed -w "$outdir/$new" >/tmp/espeak.$$ 2>&1
			;;
	texthtml)	new=`echo "$target" | \
				sed -e 's/.txt$//' -e 's/$/.html/'`
			oldsize=`du -a -b "$target" | awk '{print $1}'`
			avwatcher "$outdir/$new" "$prog" "$oldsize" $$ &
			txt2tags --infile="$target" --outfile="$outdir/$new" -t xhtml >> /tmp/txt2tags.$$ 2>&1
			if test -s /tmp/txt2tags.$$
			then	title=`mytranslate "program output"`
				zenity --info --title="txt2tags $title" --text=`cat /tmp/txt2tags.$$`
			fi
			rm -f /tmp/txt2tags.$$
			;;
	doctext)	new=`echo "$target" | \
				sed -e 's/.doc$//' -e 's/$/.txt/'`
			title=`mytranslate "Options"`
			text=`mytranslate "Include either of these?

r = \"revisioning text\"
s = \"hidden text\""`
			text2=`mytranslate "Embedded text"`
			incl=`zenity --list --height=300 --title="$title" --text="$text" --checklist --column "$s1" --column "$text2" FALSE r FALSE s ` || exit 0
			case $incl in
				'')	;;
				*)	opts=`echo "$incl" | sed 's/|/ /g' | \
					sed 's/^/ /' | sed 's/ / -/g'` ;;
			esac
			oldsize=`du -a -b "$target" | awk '{print $1}'`
			avwatcher "$outdir/$new" "$prog" "$oldsize" $$ &
			antiword $opts "$target" > "$outdir/$new" 2>>/tmp/antiword.$$
			if test -s /tmp/antiword.$$
			then	zenity --info --title="antiword output" --text=`cat /tmp/antiword.$$`
			fi
			rm -f /tmp/antiword.$$
			;;
	*)	text=`mytranslate "Not ready yet"`
		zenity --info --title="OOPS!" --text="$text"; exit 0 ;;

esac
}
# end of text

#####
# Initial script
#####
PATH=$PATH:.; export PATH

# check some stuff first...
# have we been renamed?
case `basename $0` in
	avconvert)	;;
	*)		exec xterm -hold -geometry 70x2 -bg red -T "Please rename the script back to 'avconvert'" -e true ;;
esac
# if zenity is not installed, use xterm to display a warning
whereis zenity | grep / >/dev/null || exec xterm -hold -geometry 50x2 -bg red -T "OOPS! Must install zenity first!" -e true
# if imagemagick is not installed, display warning
whereis convert | grep / >/dev/null || exec zenity --warning --text="Must install \"ImageMagick\" package first!"
# if ffmpeg is not installed, display warning
whereis ffmpeg | grep / >/dev/null || exec zenity --warning --text="Must install \"ffmpeg\" package first!"

# the config files are now moved....
mkdir -p ~/.config/avconvert
if test -f ~/.avconvert
	then	for each in ~/.avconvert*
		do
			new=`echo "$each" | sed 's/^.*\/.//'`
			mv $each ~/.config/avconvert/$new
		done
fi

# translation

langlist=`curl --connect-timeout 2 -m 2 --retry 2 -s -A "Mozilla/5.0" \
	-d "hl=en" -d "ie=UTF8" -d text="testing" -d "langpair=en|de" \
	http://translate.google.com/translate_t | \
	gawk -F">Detect language<" '{print $2}' | tr ' ' '\012' | \
	grep "value=\".*\">" | egrep -v "input|Contribute|Tests|^$" | \
	sed -e 's/^value="//' -e 's/<.*//' -e 's/">/=/' | grep -v "^=$" | \
	sort | uniq`

dlang=`echo "$LANG" | sed 's/_.*//'`
langlist=`echo "$langlist" | sed -e 's/^/FALSE /' -e "/ $dlang=/s/FALSE/TRUE/"`

online=n
echo "$langlist" | grep English >/dev/null && online=y

# if language preference file is out of date, remove it
if grep "lang=" ~/.config/avconvert/avconvert.lang >/dev/null 2>&1
	then	:
	else	rm -f ~/.config/avconvert/avconvert.lang
fi

# requirements for translations
if whereis curl | grep / >/dev/null
	then	curlok=y
	else	curlok=n; text="$text\n\tcurl"
fi
if whereis elinks | grep / >/dev/null
	then	linksok=y; links=elinks
	else	if whereis links | grep / >/dev/null
			then	linksok=y; links=links
			else	linksok=n; text="$text\n\telinks  -OR-  links"
		fi
fi

# if we are not online, do not ask about language
if [ "$online" = "n" ]
	then	lang=en
	else
# check language
if test -s ~/.config/avconvert/avconvert.lang
	then	. ~/.config/avconvert/avconvert.lang
		case $curlok$linksok in
			*n*)	if [ "$lang" = "en" ]
					then	: ok
					else	zenity --info --title="Required for translation" --text="Please install$text\nfor translation"
						lang="en"
				fi
				;;
		esac
		export lang service
	else	lang=`zenity --list --height=520 --title="Language" --text="Choose language for all text" --radiolist --column="Select" --column="Language" $langlist` || exit 0
		lang=`echo $lang | sed 's/=.*//'`
		echo "lang=$lang" > ~/.config/avconvert/avconvert.lang
		export lang
		if [ "$lang" = "en" ]
			then	online=n
			else	text="Please install the package(s):\n"
				case $curlok$linksok in
					*n*)	zenity --info --title="Packages needed" --text "$text\n\nfor the translation feature.\nProceeding in English until installed."
						online=n ;;
				esac

				service=`zenity --list --title="Service" --text="Which service should be used" --radiolist --column="Select" --column="Language" TRUE google FALSE babel` || exit 0
				echo "service=$service" >> ~/.config/avconvert/avconvert.lang
				export lang service
		fi
		title=`mytranslate "Language Preference"`
		text=`mytranslate "When the internet is available, this script will
send text through the translation service.

If there is no internet connection, everything will be in English.
If the internet is slow, translations may not work well.  Please
tell me if there are problems so that I can improve this.

Your language is stored in ~/.config/avconvert/avconvert.lang
Remove or edit that file to change language."`
		[ "$lang" = "en" ] && text="You have chosen to display text in English.

You can change the language by editing or removing
~/.config/avconvert/avconvert.lang"
		zenity --info --title="$title" --text="$text"
fi
fi

# if language is EN, we do not need to translate
case $lang in
	en)	online=n ;;
esac

if grep "trash=" ~/.config/avconvert/avconvert >/dev/null 2>&1
	then	: UP TO DATE
	else	rm -f ~/.config/avconvert/[Aa]vconvert
fi

if test -s ~/.config/avconvert/avconvert
	then	: defaults already set
	else	echo -e "destdir=n\nautoloop=n\nzenityfix=n\nquiet=n\ntrash=n" > ~/.config/avconvert/avconvert
		title=`mytranslate "Set Defaults"`
		text=`mytranslate "This is your first run of avconvert.

The file ~/.config/avconvert/avconvert can save some default behaviors.  You can create one now by selecting from the options below,
and you can change it at any time by editing it directly or by removing it, which will trigger this dialogue to reappear.

Read each option below and choose your prefrence followed by OK, or click Cancel to defer this until later."`
		p1=`mytranslate "Always pop up to ask for a destination into which to save converted files"`
		p2=`mytranslate "When multiple files are selected, process each one in the same way"`
		p3=`mytranslate "Check zenity defaults and offer to fix them so popups are OVER rather than UNDER"`
		p4=`mytranslate "Quiet mode - use 'notification' instead of 'info' to show some conversion results"`
		p5=`mytranslate "After conversions, offer to move originals to ~/Desktop/avconvert-Trash"`
		behavior=`zenity --list --height=350 --title="$title" --text="$text" --checklist --column="" --column="Description" TRUE "$p1 (destdir=y)" TRUE "$p2 (autoloop=y)" TRUE "$p3 (zenityfix=y)" TRUE "$p4 (quiet=y)" FALSE "$p5 (trash=n)"` || exit 0
echo "$behavior" | tr '|' '\012' | sed -e 's/^.*(//' -e 's/.$//' | grep "=" >> ~/.config/avconvert/avconvert

		title=`mytranslate "Set image default"`
		text=`mytranslate "When converting images, the system can set a default for the type of file to be converted to.

choose one of the following"`
		col=`mytranslate "Default image extension"`
		i1=`mytranslate "No default should be pre-selected"`
		i2=`mytranslate "Create an image of the same type as the source"`
		i3=`mytranslate "Default image type should be"`
		imageext=none
		imageext=`zenity --list --height=370 --title="$title" --text="$text" --radiolist --column="" --column="$col" TRUE "$i1 (imageext=none)" FALSE "$i2 (imageext=same)" FALSE "$i3 gif (imageext=gif)" FALSE "$i3 jpg (imageext=jpg)" FALSE "$i3 ico (imageext=ico)" FALSE "$i3 pdf (imageext=pdf)" FALSE "$i3 png (imageext=png)" FALSE "$i3 tif (imageext=tif)"` || exit 0

echo "$imageext" | tr '|' '\012' | sed -e 's/^.*(//' -e 's/.$//' >> ~/.config/avconvert/avconvert
. ~/.config/avconvert/avconvert

echo "# Defaults file for avconvert, created `date`
destdir=$destdir
autoloop=$autoloop
zenityfix=$zenityfix
quiet=$quiet
trash=$trash
imageext=$imageext
" > ~/.config/avconvert/avconvert
fi

# set everything to 'defaults' regardless of preferences file
# in case there's no file, or some are missing
destdir=y; autoloop=x; zenityfix=y; imageext=none; quiet=n trash=n

# now "dot" the file if it is there
# due to google translator, be sure it is linked to Avconvert as well
if test -s ~/.config/avconvert/avconvert
	then	. ~/.config/avconvert/avconvert
	if cmp ~/.config/avconvert/avconvert ~/.config/avconvert/Avconvert >/dev/null 2>&1
		then	: alldone
		else	rm -f ~/.config/avconvert/Avconvert
			ln ~/.config/avconvert/avconvert ~/.config/avconvert/Avconvert
	fi
fi

# here we go.....

# let's get some common translated phrases in advance first:
# export them all!!
s1=`mytranslate "Select"`; export s1


while true
do
	case $1 in
		--no-destdir)	destdir=n; shift ;;
		--no-loop)	autoloop=n; shift ;;
		--no-zenityfix)	zenityfix=n; shift ;;
		*)		break ;;
	esac
done

case $1 in
	'')	title=`mytranslate "Select source files, all of same type (image/video/other)"`
		files=`zenity --title="$title" --file-selection --multiple --separator="|"` || exit 0
		files=`echo "$files" | sed -e 's/^/"/' -e 's/$/"/' -e 's/|/" "/g'`
		echo "avconvert $* $files" > /tmp/avconvert.rerun
		sh /tmp/avconvert.rerun &
		rm -f /tmp/avconvert.rerun
		exit 0
		;;
esac

# if this is not a "fixable" zenity, do not try to fix it
# (at least) ubuntu 9.10 lacks the configuration file
if test -s /usr/share/zenity/zenity.glade
	then	: good
	else	zenityfix=n
fi
case $zenityfix in
	n)	;;
	*)
if test -s /usr/share/zenity/zenity.glade.orig
	then	: already done
	else	cat << ZenityFix > /tmp/zenity.fix
# zenity.fix
# written by
# marc brumlik, tailored softare inc
# distributed with
# avconvert, posted on gnome-look, to correct the behavior of zenity
# The driectory containing zenity.glade is:
DIR=/usr/share/zenity

if test -s \$DIR/zenity.glade
	then	cd \$DIR
	else	echo -e "The file /usr/share/zenity/zenity.glade\ncan not be found!\n\nPlease modify the script /tmp/zenity.fix with the correct\nlocation of the file 'zenity.glade'.\nThen execute it directly from the command line.\n\nExiting now...\n\nPress Return \c"; read fred; exit 0
fi
echo -e "\nModifying the file \$DIR/zenity.glade\n\nA safe copy of your file is being saved as zenity.glade.orig"
if test -s zenity.glade.orig
	then	echo "It appears that this has been run before."
		echo "Doing it again..."
	else	cp zenity.glade zenity.glade.orig
fi
cat zenity.glade.orig | sed '/focus_on_map/s/False/True/' > zenity.glade
cp zenity.glade zenity.glade.progress-over
progline=\`grep -n "zenity_progress_dialog" zenity.glade | sed 's/:.*//'\`
focusline=\`sed -n "\$progline,\$"p < zenity.glade | grep -n focus_on_map | \
	head -1 | sed 's/:.*//'\`
targetline=\`echo -e "\$progline + \$focusline - 1 \n quit" | bc\`
sed "\$targetline s/True/False/" < zenity.glade.progress-over > zenity.glade.progress-under
chmod 666 /usr/share/zenity/zenity.glade
echo -e "/tmp/zenity.fix now exiting\n\nPress Return \c"; read fred
ZenityFix
		chmod 755 /tmp/zenity.fix
		if whereis xterm | grep / >/dev/null
			then	message=`mytranslate "Click OK if you would like this to be run for you right now, or if you prefer, click Cancel to prevent avconvert from doing this.  If you Cancel, avconvert will create a script /tmp/zenity.fix which you can run as \'root\' manually.  This will modify your Zenity defauts so its windows appear on top of any others."`
			else	message=`mytranslate "This fix can not be auto-run for you because you do not have \'xterm\' installed.  Click Cancel and execute /tmp/zenity.fix as \'root\'. This will modify Zenity defaults so its windows appear on top of any others."`
		fi
		title=`mytranslate "Zenity defaults"`
		text1=`mytranslate "The Linux utility that avconvert uses to pop up dialogs is called Zenity.  In some releases, these dialogs pop up underneath existing windows.  This makes reading the output and responding to prompts from avconvert very inconvenient.

Your installed Zenity version is one which behaves this way.  For your convenience, a small program named 'zenity.fix' has just been written in your /tmp directory."`
		test2=`mytranslate "NOTE: this window and some others can be permanently silenced either with command line options or by creating a ~/.config/avconvert/avconvert config file.  Read the end of the avconvert script for details.
Also, this window will not reappear once the zenity defaults are changed OR as long as the /tmp/zenity.fix file exists."`
		zenity --question --title="$title" --text="$text1\n\n$message\n\n$text2" && xterm -e ' echo -e "To fix zenity requires Root \c"; su -c /tmp/zenity.fix '
fi
	;;
esac

case $quiet in
	y)	cp /usr/share/zenity/zenity.glade.progress-under /usr/share/zenity/zenity.glade 2>/dev/null ;;
	n)	cp /usr/share/zenity/zenity.glade.progress-over /usr/share/zenity/zenity.glade 2>/dev/null ;;
esac

rm -f /tmp/avconvert.env /tmp/avffmpeg.env

until [ -z "$1" ]
do

fileargs="$fileargs
$1"

echo "$1" > /tmp/files

targetpath=$1; shift
target=`basename "$targetpath"`
# had used this due to an earlier bug, but dirname is better
# dir=`echo "$targetpath" | sed "s/\/\$target//"`
dir=`dirname "$targetpath"`
case "$dir" in
	*/*)	;;
	*)	dir=`pwd` ;;
esac

test -d "$dir" && cd "$dir"
if test -f "$target"
	then	if test -s "$target"
			then	: OK
			else	text=`mytranslate "Source file is EMPTY!"`
				exec zenity --warning --text="$target\n\n$text"
		fi
	else	text=`mytranslate "Source file NOT FOUND!"`
		exec zenity --warning --text="$target\n\n$text"
fi

case $destdir in
	n)	outdir=`pwd` ;;
esac

if test -z "$outdir"
	then	cwd=`pwd`
title=`mytranslate "Destination folder (Cancel for current directory)"`
		outdir=`zenity --file-selection --filename="$cwd" --directory --title="$title"`
		if test -z "$outdir"
			then	outdir=$cwd
		fi
fi

case "$target" in
	*.*)	;;
	*)	zenity --question --title="What to do?" --text="It would be nice if \"$target\" had an extension...\nRenaming this file is recommended!\n\nTo have avconvert proceed anyway, press OK.\nTo exit now so you can rename the file, press Cancel" || exit 0 ;;
esac

type=`file "$target" | tr '[A-Z]' '[a-z]' | sed 's/^.*://'`
mtype=`file -i "$target" | tr '[A-Z]' '[a-z]' | sed 's/^.*://'`
show=`file "$target" | awk -F: '{print $2}'`
case "$target" in
	*.rm|*.rmvb|*.???|*.????)	ext=`echo "$target" | sed 's/^.*\.//'` ;;
	*)		ext="" ;;
esac
# imagemagick identify does not properly execute mencoder on *avi files
# and instead generated a png image for every frame. 
# until fixed, this like should be commented out.
## ident=`identify "$target" 2>/dev/null | sed "s/^.*$ext //"`
# ffmpeg provides lots of info anyway
ffident=`ffmpeg -i "$target" 2>&1 | tail -4 | head -3`
if echo "$ffident" | grep Unable >/dev/null
	then	ffident=""
fi
echo "$ffident" | grep audio >/dev/null && fftype=audio
echo "$ffident" | grep video >/dev/null && fftype=video
[ "$fftype" = "video" ] && echo "$ffident" | grep "bitrate: N/A" && fftype=image
[ "$fftype" = "image" ] && imident=`echo "$ffident" | grep Video | \
	awk -F, '{print $1, $2, $3, $4}' | sed 's/^.*://'`

#	based on source file, what might the destinations be?
# 	what application will we use to create them?
#	the case wildcards are things we know how to convert FROM
#	"prog" is the actual conversion program
#	"out" is a list of formats we can choose to convert TO
it=""; av=""	# for "image/text" and "audio/video"
# strings from file, and extensions, which imply input file type
case "$fftype$type$mtype$ext" in
	*bin)
		base=`echo "$target" | sed 's/.bin$//'`
		if test -s "$base".cue
			then	prog=iso; it=bchunk
		fi ;;
	*cue)
		base=`echo "$target" | sed 's/.cue$//'`
		if test -s "$base".bin
			then	prog=iso; it=bchunk
		fi ;;
	*daa)
		prog=iso; it=daa2iso ;;
	*nrg)
		prog=iso; it=nrg2iso ;;
	*b?i)
		prog=iso; it=b5i2iso ;;
	*cdi)
		prog=iso; it=csi2osi ;;
	*mdf)
		prog=iso; it=mdf2iso ;;
	*pdi)
		prog=iso; it=pdi2iso ;;
	*ccd)
		prog=iso; it=ccd2iso ;;
	*uif)
		prog=iso; it=uif2iso ;;
	*text/plain*|*ASCII*)
		# recognized plain text formats, out to other text or image
		prog="text"; it="text" ;;
	*image*|*pdf|*ico)
		# recognized image formats, output will also be an image
		prog="convert"; it="image" ;;
	*video*|*3g2|*3gp|*ogv|*mpg|*wmv|*asf|*mp4|*ogg|*rm|*rmvb)
		# recognized multimedia formats, output to multimedia or audio
		prog="ffmpeg"; av="video" ;;
	*audio*|*mp3|*wav|*m4a|*wma)
		# recognized audio-only formats, output to audio
		prog="ffmpeg"; av="audio" ;;
	*msword*)
		# Microsoft office word document, v2 / v6 or newer
		prog=text; it="doc" ;;
	text/html)
		prog=text; it="html" ;;
	*text/rtf*)
		prog=text; it="rtf" ;;
	*Unicode*)
		prog=text; it="uni" ;;
	*opendocument*|*openoffice*)
		prog=text; it="odt" ;;
	*openoffice*)
		prog=text; it="oo" ;;
	*)	prog=`zenity --list --height=520 --title="Unknown!" --text="Not sure what to do with this file!\n\nTarget file: \"$target\"\n\nInformation found:\n$type\n$mtype\n$ffident$ident\n\n\nBut, it is likely that though this file type was not\nexplicitly recognized by avconvert, it can be handled\nby convert (Images) or ffmpeg (Audio/Video).\n\nIf you would like to TRY, choose the utility you feel\nwould be appropriate and avconvert will do its best.\n\n" --radiolist --column "Select" --column "Utility to use" FALSE convert FALSE ffmpeg` || exit 0
		case $prog in
			ffmpeg)	av=`zenity --list --title="Select" --text="Tell ffmpeg whether this file is:" --radiolist --column "Select" --column "Content type" FALSE audio FALSE video` || exit 0 ;;
		esac
		;;
		
esac

# export everything we know so far and launch the appropriate function quality

case $prog in
	ffmpeg|convert)	audiovideo=y ;;
	*)		audiovideo=n ;;
esac
case "$1$audiovideo$autoloop" in
	?*yx)	autoloop=n
		zenity --question --title="Auto-Loop though Source Files??" --text="You have selected multiple source files.  Avconvert will loop through them and convert them all.\n\n*IF* you know that all source files are of the same type\n   (images, audio, etc)\nand *IF* you want them all of them converted the same way\n   (images->1024/jpg, audio->128bit/mp3, etc)\n*THEN* click OK\n\n     But...\n\n*IF* they the source files are of different types\n   (not ALL images or not ALL videos)\nor *IF* you want per-file control of how each source is handled\n*THEN* click Cancel\n\nOK will auto-loop, Cancel will treat each file separately." && autoloop=y
		;;
esac

today=`date +%Y%m%d`
if grep "$today" ~/.config/avconvert/versioncheck >/dev/null 2>&1
	then	: already checked
	else	echo "$today" > ~/.config/avconvert/versioncheck
		versioncheck=`wget -q --timeout=3 --tries=1 \
		http://www.gtk-apps.org/CONTENT/content-files/92533-avconvert.tar.gz -O - | \
		gunzip 2>/dev/null | grep -a version= | head -1 | \
		sed -e 's/"$//' -e 's/^.*"//'`
fi
case "$versioncheck" in
	[0-9].[0-9][0-9]*)	case "$versioncheck" in
					"$version")	;;
					*)	zenity --info --title="A newer version 'avconvert' is available for download" --text="You are running version\n\t$version\n\nAvailable for download\n\t$versioncheck"
						;;
				esac
esac

export dir target ext type mtype show ident ffident it av prog autoloop base
myav$prog

# this 'done' is for looping through multiple selected input files
done

case $overwrite in
	YES)	;;
	*)	case $trash in
			y)	totrash=`zenity --list --title="Send to Trash?" --height=210 --text="You can move the source file(s) to\n$HOME/Desktop/avconvert-Trash" --radiolist --column "Select" --column "Trashcan the source files?" TRUE NO FALSE YES` || exit 0
			case $totrash in
				NO)	;;
				YES)	mkdir -p ~/Desktop/avconvert-Trash/$$ 2>&1
					echo "$fileargs" | while read each
					do mv "$each" ~/Desktop/avconvert-Trash/$$; done
					;;
			esac
			;;
		esac
		;;
esac

exit 0

#####
# READ ME
#####
avconvert

marc brumlik, tailored software inc, Thu Nov 13 18:50:35 CST 2008
tsi-inc@comcast.net

#######
# IF YOU READ NO FURTHER THAN THIS, please note that when using
# "kcolorchooser" in text-to-image, there is a delay after choosing your
# color before the next window from avconvert comes up.  I have no idea why
# kcolorchooser is behaving this way.
#######

This project started out because I needed to create jpg files of numerous
resolutions from a number of source files and wanted an automatic way to
generate them more quickly.  Then my daughter asked for a way to convert
"unplugged" YouTube files into formats her friends could view.
Combining these two short scripts is where avconvert began.

Upon completion of each use of avconvert, a file for debugging purposes
is written to, with lots of output showing exactly what the script 
has done.  This can help a lot if you are getting unexpected results.
The file name is derived from the conversion, followed by "dot" PID.  In the 
case of text->image and if intermediary files were generated, there will be
another "dot" and a sequence number.  These files will be named:
	/tmp/convert.$$
	/tmp/convert.$$.$count
	/tmp/ffmpeg.$$
	/tmp/avconvert.debug
	/tmp/txt2tags.$$
	/tmp/antiword.$$
and more may be added in the future.

You can create a startup file ~/.config/avconvert/avconvert to contain preferences.
Currently there are three items that can be specified there.
A ~/.config/avconvert/avconvert which specifies the defaults for these would contain this:
	destdir=y
	autoloop=y
	zenityfix=y
The line "destdir" specifies whether or not there should be a popup prompting
for a destination directory for converted files.  The line "autoloop" determines
whether, if multiple files are selected, you will be prompted and asked if you
want to treat them all the same way.  Y means prompt, N means always treat the
files individually.  THe line "zenityfix" has to do with the prompt which offers
to fix zenity popups so they appear above (instead of below) other items on the
desktop.  Y means detect "popunder" and offer to fix it, N means ignore current
zentiy configuration.

Things you might want to customize (starting from the top of the script):

Too much verbage that gives information about source files?
	comment out the "ident=" and "ffident=" lines

Too much window activity and want to eliminate "progress" window?
	uncomment the "exit 0" at the top of "myavconvert-watch"

To add more extensions to recognized file types for image/video/audio:
	the script uses two different forms of output from the
	"file" command plus the source file extension, to decide
	what type of file it has to work with.  "file" isn not 
	always useful, which is why extensions are needed at all.
	find the comment "# strings from file".  Below that are 
	four cases.  Each contains first something that may have
	been output by "file", followed by a set of extensions.
	Just follow the example to add more extensions.

To add more extensions to the default list of output file types:
	Find the comment line beginning "Show appropriate output".
	Below that are four entries - two for "convert" and two 
	for "ffmpeg".  These are each divided into two more.
	Just add any extension you like into that space-separated
	list (do NOT remove the leading space in the list).

To prevent a "default" output type for images:
	Currently the default output for images is the same as 
	the source file type.  To prevent this, find the comment
	"This line sets default" and, on the line for "convert",
	and comment out the "out=" line below that.

To change the list of image resolutions presented:
	Find the comment "# set resolution here".  Add or 
	remove any resolutions from the list.  Also, setting
	one or more from FALSE to TRUE will cause them to be 
	checkboxed when the window appears.

To change the list of jpg quality settings:
	Find the comment "# if this is a jpeg".  Add or remove.
	You may also set the default by changing a FALSE to TRUE

To change the list of font sizes:
	Modify the line beginning "sizelist=".

To change bitrate choices for ffmpeg audio conversion:
	Find the comment line "# audio bitrate".
	To set a default bitrate, change one of the FALSE to TRUE.

To prevent the final window showing summary after completion:
	(Not recommeded, since this is ALSO where you might see 
	diagnostic output after a failure)
	Find the comment " Show results summary" and comment out the 
	"zenity" line that follows it.


COMMENTS WELCOME!

Le script collage fonctionne bien chez moi , mais pas avec des vidéos très courtes, de quelques secondes

Dernière modification par bluc (Le 07/10/2018, à 15:35)


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#19 Le 13/10/2018, à 09:49

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

bluc, tu me dis d'essayer ce nouveau script de conversion en choisissant un autre format de sortie (mp4 par ex). J'ai donc procédé comme pour les autres scipts et rien ne se passe, rien du tout, j'ai attendu 45 mn histoire de voir mais il ne donne pas le choix du format de sortie et il ne semble pas travailler du tout.

J'ai essayé à deux reprises et c'est pareil.

Hors ligne

#20 Le 13/10/2018, à 11:09

bluc

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Ben...je suis désolé, je n"ai pas la solution


Clevo :  Ubuntu 23.10   ❖  Xubuntu 22.10  ❖  Kubuntu 23.10   
         avec partition data commune       Une fraction de seconde                    Multiboot

Hors ligne

#21 Le 13/10/2018, à 13:02

Bertrand49

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bonjour,
Une solution consiste à utiliser mkvtoolnix-gui présent dans les dépôts. et d'ouvrir le fichier avec ce logiciel, il sera alors possible de rassembler tous les fichiers et d'exporter dans un format .mkv qui présente la particularité de modifier, d'ajouter ou de supprimer des pistes à volonté.

Hors ligne

#22 Le 13/10/2018, à 14:50

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bonjour,

bluc : merci quand même. Je vais continuer à chercher car j'aimerais bien y arriver.

Bertrand : merci de passer par là. J'ai 60 petites vidéos en .MTS pour une trentaine de mn de vidéo au total.

J'ai installé mkvtoolnix-gui, j'ai ouvert le premier fichier .MTS avec ce logiciel, j'ai fait "Ajouter des fichiers sources" (Tous les fichiers multimédia gérés) et j'ai cliqué sur "Lancer le multiplexage". J'ai obtenu seulement la première vidéo dans un fichier de 2,2 Go
Dans la partie "Pistes, chapitres et balises" j'ai vu que dans la colonne "Piste par défaut", seulement la première vidéo avait la mention "OUI", toutes les autres sont à "NON" mais je ne sais pas ce qu'il faut faire pour les mettre à "OUI".

Il faut savoir, que je n'y connais pas grand chose en vidéo/audio et que quelque chose m'échappe là certainement, mais quoi ?

Hors ligne

#23 Le 13/10/2018, à 15:04

Bertrand49

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Sophie2 a écrit :

Bonjour,

bluc : merci quand même. Je vais continuer à chercher car j'aimerais bien y arriver.

Bertrand : merci de passer par là. J'ai 60 petites vidéos en .MTS pour une trentaine de mn de vidéo au total.

J'ai installé mkvtoolnix-gui, j'ai ouvert le premier fichier .MTS avec ce logiciel, j'ai fait "Ajouter des fichiers sources" (Tous les fichiers multimédia gérés) et j'ai cliqué sur "Lancer le multiplexage". J'ai obtenu seulement la première vidéo dans un fichier de 2,2 Go
Dans la partie "Pistes, chapitres et balises" j'ai vu que dans la colonne "Piste par défaut", seulement la première vidéo avait la mention "OUI", toutes les autres sont à "NON" mais je ne sais pas ce qu'il faut faire pour les mettre à "OUI".

Il faut savoir, que je n'y connais pas grand chose en vidéo/audio et que quelque chose m'échappe là certainement, mais quoi ?

Ce n'est pas pour ajouter d'autres vidéos dans le même conteneur, c'est normal. Les chapitres, balises, sous-titres non désirés peuvent être décochés avant d'appliquer lancer:multiplexage. C'est la première étape pour obtenir les fichiers rassemblés dans un .mkv
S'il y en a beaucoup à mettre bout à bout, alors c'est un logiciel de montage vidéo qu'il faut.

Hors ligne

#24 Le 13/10/2018, à 15:27

Sophie2

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Bertrand49 a écrit :

S'il y en a beaucoup à mettre bout à bout, alors c'est un logiciel de montage vidéo qu'il faut.

Exact, c'est ça que je cherche à faire, je voudrais trouver un logiciel qui fonctionne sous Ubuntu pour mettre bout à bout mes 60 petites vidéos qui font au total environ 30 mn de vidéo. Je les ai en .MTS, il me faudrait les convertir en un autre format car les .MTS on tendance à sautiller ; et ensuite il me faudrait les assembler (ou les assembler et le convertir ensuite).

Quel logiciel de montage vidéo utiliserais-tu dans ce cas ?

Hors ligne

#25 Le 13/10/2018, à 15:38

Bertrand49

Re : Assembler des fichiers vidéos .MTS et obtenir un fichier en .mp4

Sophie2 a écrit :
Bertrand49 a écrit :

S'il y en a beaucoup à mettre bout à bout, alors c'est un logiciel de montage vidéo qu'il faut.

Exact, c'est ça que je cherche à faire, je voudrais trouver un logiciel qui fonctionne sous Ubuntu pour mettre bout à bout mes 60 petites vidéos qui font au total environ 30 mn de vidéo. Je les ai en .MTS, il me faudrait les convertir en un autre format car les .MTS on tendance à sautiller ; et ensuite il me faudrait les assembler (ou les assembler et le convertir ensuite).

Quel logiciel de montage vidéo utiliserais-tu dans ce cas ?

Ça dépend des goûts et des possibilités de l'ordinateur, car si on veut ajouter des effets de transition, etc. c'est bien mais ça consomme des ressources et il faut une très bonne carte graphique. Openshot video-editor est pour moi intuitif et facile à comprendre, mais il y en a d'autres comme kdenlive, il faut en essayer plusieurs, il y a une importante documentation ici

Hors ligne