You are not logged in.

#126 2019-07-11 20:02:32

malm
jgmenu developer
Registered: 2016-10-13
Posts: 451
Website

Re: The great yad hacking thread

tint2 and yad are ace. Not sure you could easily do that with another panel!

Offline

#127 2019-07-12 12:13:42

misko_2083
Member
Registered: 2016-05-24
Posts: 212

Re: The great yad hacking thread

^Yes, it's not so easy with the other panels.
A panel plugin is necessary in those cases.

Offline

#128 2019-08-23 00:34:07

achim
New Member
Registered: 2019-08-23
Posts: 3

Re: The great yad hacking thread

Hello misko_2083,
in another forum you have ever helped very well. Now I find you here again by chance and have a question: I have created a YAD code under Linux Mint 18.3 and would like to build a progress bar for the FFMPEG command. But I need help. Here is my code:

#!/bin/bash

# videoformat auf 16:9 einstellen

cd /
cd /home/achim/Videos/

TITLE="Videoformat auf 16:9 einstellen"
TEXT="<span foreground='red'><b><big><big>
      Bitte eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"

filename=$(yad --width=1500 --height=600 --window-icon="/home/achim/.icons/Movies-icon24.png" --title="$TITLE" --text="$TEXT" --file-selection \
            --button=" Abbrechen!/home/achim/.icons/Button-stop-icon24.png":1 --button=" OK!/home/achim/.icons/Accept-icon24.png":0 \
            --file-filter='*.mp4')

pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}

[[ -z "$filename" ]] && exit 0

cd /
cd "$verz"

mediainfo --Output=file:///home/achim/.config/achim/medinfo.txt "$datm" > /home/achim/.config/achim/medlog.odt

va="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$datm")" # = 334.089000
va1=${vb%.*} # = 334
secs=va1 # 334
va2=$(printf '%H:%M:%S' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)))
#va3=`date +%00:%M:%S`
va3="$(date +%T)"

ffmpeg -hide_banner -i "$datm" -vf scale="1920:1080" -aspect 16:9 -b:a 320000 "${datm%.*}-169.mp4" | yad --progress \
--progress-text="DerVorgang startete um $va3 und dauert etwa $va2" --width=1200 --height=300 --center --window-icon="gtk-execute" \
--title="Die Konvertierung des Videos  '$datm'  läuft..." --timeout=$va1 --timeout-indicator=Bottom --no-button --auto-kill --auto-close

exit 0

# va1 (334 Sekunden) = Laufzeit der Fortschrittanzeige für dieses Beispiel

Do you have a tip for me? (Sorry for my bad English)

achim

Last edited by achim (2019-08-23 22:14:46)

Offline

#129 2019-08-23 16:46:07

ohnonot
...again
Registered: 2015-09-29
Posts: 3,842
Website

Re: The great yad hacking thread

^ all I can see is that ffmpeg itself does not know when it will be finished; where do you plan to get the percentages for the progress bar?
- Ok, answering my own question:

man ffmpeg
...
       -stats (global)
           Print encoding progress/statistics. It is on by default, to explicitly disable it you need to specify "-nostats".

       -progress url (global)
           Send program-friendly progress information to url.

           Progress information is written approximately every second and at the end of the encoding process. It is made of "key=value" lines. key consists of only alphanumeric characters. The last key
           of a sequence of progress information is always "progress".

Offline

#130 2019-08-23 22:20:19

achim
New Member
Registered: 2019-08-23
Posts: 3

Re: The great yad hacking thread

In between I helped myself a little and changed the code accordingly. But the progress bar is still a bit inaccurate. I keep working on it.

achim

Offline

#131 Yesterday 05:42:36

ohnonot
...again
Registered: 2015-09-29
Posts: 3,842
Website

Re: The great yad hacking thread

please use "$HOME" instead of /home/achim.
Makes it easier for others to test or use your script.

Offline

#132 Yesterday 13:11:33

clusterF
Member
Registered: 2019-05-07
Posts: 105

Re: The great yad hacking thread

@ achim, Might be a few hints in this script from here http://smokey01.com/help/yad-tips-0.0.2.html

#!/bin/sh

eval exec yad --title="xdf" \
	--image=drive-harddisk \
	--text="Disk\ usage:" \
	--buttons-layout=end \
	--width=650 \
	--multi-progress \
$(df -hT $1 | tail -n +2 | awk '{printf "--bar=\"<b>%s</b> (%s - %s) [%s/%s]\" %s ", $7, $1, $2, $4, $3, $6}')

Last edited by clusterF (Yesterday 13:16:41)


Everything not saved will be lost.

--Nintendo "Quit Screen" message

Offline

#133 Yesterday 18:12:57

achim
New Member
Registered: 2019-08-23
Posts: 3

Re: The great yad hacking thread

Hello everybody,

I have the code ready now and it works quite well. With the variables vb, vc and vd I have adjusted the speed of the progress bar, since ffmpeg runs faster with me than the tool ffprobe has determined. With the variable the speed of the progress bar can be changed according to the speed of the system.

If you can still make suggestions for improvement, I am always grateful for it.

I thank the users @ohnonot and @clusterF for their help.

Here is the script:

#!/bin/bash

# videoformat auf 16:9 einstellen

cd /
cd $HOME/Videos/

TITLE="Videoformat auf 16:9 einstellen"
TEXT="<span foreground='red'><b><big><big>
      Bitte eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"

filename=$(yad --width=1500 --height=600 --window-icon="$HOME/.icons/Movies-icon24.png" --title="$TITLE" --text="$TEXT" --file-selection \
            --button=" Abbrechen!$HOME/.icons/Button-stop-icon24.png":1 --button=" OK!$HOME/.icons/Accept-icon24.png":0 \
            --file-filter='*.mp4')

pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}

[[ -z "$filename" ]] && exit 0

cd /
cd "$verz"

mediainfo --Output=file:///$HOME/.config/achim/medinfo.txt "$datm" > $HOME/.config/achim/medlog.odt

va="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$datm")" # = 334.089000
vb=${va%.*} # = 334
vc=10
vd=6
((va1=$vb/$vc*$vd))
secs=vb # 334
va2=$(printf '%d Stunden, %d Minuten, %d Sekunden ' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)))
#va3=`date +%00:%M:%S`
va3="$(date +%T)"

ffmpeg -hide_banner -i "$datm" -vf scale="1920:1080" -aspect 16:9 -b:a 320000 "${datm%.*}-169.mp4" | yad --progress \
--progress-text="Der Vorgang startete um $va3 und dauert etwa $va2" --width=1200 --height=150 --center --window-icon="gtk-execute" \
--title="Die Konvertierung des Videos  '$datm'  läuft..." --timeout=$va1 --timeout-indicator=top --no-buttons --auto-kill --auto-close

yad --text-info --title="Die Mediainfos zu dem Video '$datm'  "   --width=1000 --height=800 --center --window-icon="gtk-execute" --wrap --back=gainsboro \
--fore=blue < $HOME//.config/achim/medlog.odt --fontname=" Monospace italic 12"

exit 0

# va1 (334 Sekunden) = Laufzeit der Fortschrittanzeige für dieses Beispiel

achim

Offline

#134 Today 05:56:56

ohnonot
...again
Registered: 2015-09-29
Posts: 3,842
Website

Re: The great yad hacking thread

^ Great!
A few things:

  • "cd /" is pointless. Remove it.

  • mediainfo files: are they temprary? are you planning on keeping them? If not, it might be a good idea to clean up after the script has finished. And use a folder that is present on all systems, not only yours.

  • Why is the input limited to .mp4 files?

  • I tested, the progress bar ran out before conversion was finished. Just a minute or so, but that's bad.

Offline

Board footer

Powered by FluxBB