Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 18 Nov 2019, 06:59
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
YAD - Tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 41 of 51 [754 Posts]   Goto page: Previous 1, 2, 3, ..., 39, 40, 41, 42, 43, ..., 49, 50, 51 Next
Author Message
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Mon 08 Apr 2019, 15:08    Post subject:  

achim wrote:
Hi Fred,

if you're interested, I changed the parameter order for the FFMPEG command as follows:
Code:
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -acodec copy -vcodec copy "$OUTPUT"


So everything works to my satisfaction.

Best regards

achim


Thanks achim, apparently the order of parameters makes a difference.
From what I understand reading about it on the web, the spitting isn't always exact , that will be only when the split point is a "keyframe" .
When re-encoding (instead using copy), maybe it can be exact, but I don't know much about ffmpeg, so not sure.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Tue 09 Apr 2019, 08:18    Post subject:  

Hello Fred,

Thank you for this information. If you know a more precise way to split videos, please let me know.

Up soon,

Achim
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Tue 09 Apr 2019, 11:27    Post subject:  

achim wrote:
Hello Fred,

Thank you for this information. If you know a more precise way to split videos, please let me know.

Up soon,

Achim


Hi achim, here's good info, I think, it mentions what difference the order of parameters makes and in the end that re-encoding is the best for splitting, but can have quality loss.
http://www.markbuckler.com/post/cutting-ffmpeg/
I found that for re-encoding (to mp4) this has nice quality (but takes a lot longer than copying):
Code:
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -vcodec libx264  -preset medium -crf 24 -acodec libmp3lame -ab 128k "$OUTPUT"

You may want to replace "libmp3lame" by "libfaac" if your ffmpeg supports it (and maybe change the bitrate for audio).

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Tue 09 Apr 2019, 22:19    Post subject:  

Hello Fred,

nice that you help me with the topic "cut videos with FFmpeg" so well. The link is very interesting and the command line
Code:
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -vcodec libx264  -preset veryfast -crf 16 -acodec libmp3lame -ab 196k "$OUTPUT"


I tested. As you can see, I have changed it a bit by experimenting. I think I get good results with this parameter setting now. Maybe I would like to create a YAD script later, with which I can query the parameters after the YT download. Let's see how much time I have for it. But one more thing: YAD is a great tool, it's fun.
I wish you all the best

achim
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 11 Apr 2019, 12:14    Post subject:  

Hello Fred,

I have spent too many hours solving a problem. Look at this code:

Code:
if [[ $INPUT = *.mp4 ]]; then
ffmpeg -i "${INPUT}" -vn -ar 44100 -ac 2 -ab 320k "${INPUT%.mp4}.mp3";
fi


FFmpeg will not stop automatically after that. I have to help with Ctrl + C. Do you have any idea why that is?

achim
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Thu 11 Apr 2019, 15:29    Post subject:  

Hi achim, strange.... tried your code and works fine for me.
Don't know. Maybe the encoding takes much longer than you expected ?

Let's not continue here if the subject isn't about YAD, better go on about ffmpeg in your thread (or other thread you create maybe):
http://murga-linux.com/puppy/viewtopic.php?t=115844

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 11 Apr 2019, 19:11    Post subject:  

OK, thanks Fred
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Sat 13 Apr 2019, 06:57    Post subject:  

Hi fred,

here is the complete code, which you can extend as you like (works very well!)

Code:
#!/bin/bash
# mp3 aus Video extrahieren (Einzeln)
cd
cd /home/achim/Youtube-Videos

TITLE="MP3 aus Video extrahieren"
TEXT="Bitte die Endung wählen und anschließend eine Datei selektieren: "

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

basePath=${filename%.*}
baseName=${basePath##*/}
newPath=${basePath%/*}
TEXT1="<span color='blue'>Die Datei "$baseName".mp3

wurde im Verzeichnis "$newPath" gespeichert!</span>"

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

case $filename in
        *.mp4)
ffmpeg -i "$filename" -vn -ar 44100 -ac 2 -ab 320k "$basePath".mp3
sleep 2
xdotool key "Return"
yad --center height=200 --width=550 --window-icon="/home/achim/.icons/Movies-icon24.png" --title="Ex­trak­ti­on aus Video erfolgreich" \
--text="$TEXT1" --image-on-top --image="/home/achim/.icons/Hand-thumbs-up-like-2-icon72.png" \
--no-buttons --close-on-unfocus ;;
        *.m4a)
ffmpeg -i "$filename" -vn -ar 44100 -ac 2 -ab 320k "$basePath".mp3
sleep 2
xdotool key "Return"
yad --center height=200 --width=550 --window-icon="/home/achim/.icons/Movies-icon24.png" --title="Ex­trak­ti­on aus Video erfolgreich" \
--text="$TEXT1" --image-on-top --image="/home/achim/.icons/Hand-thumbs-up-like-2-icon72.png" \
--no-buttons --close-on-unfocus ;;
        *.avi)
ffmpeg -i "$filename" -vn -ar 44100 -ac 2 -ab 320k "$basePath".mp3
sleep 2
xdotool key "Return"
yad --center height=200 --width=550 --window-icon="/home/achim/.icons/Movies-icon24.png" --title="Ex­trak­ti­on aus Video erfolgreich" \
--text="$TEXT1" --image-on-top --image="/home/achim/.icons/Hand-thumbs-up-like-2-icon72.png" \
--no-buttons --close-on-unfocus ;;
esac
exit 0
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Sat 13 Apr 2019, 15:34    Post subject:  

Hi achim,
Nice !
About the issue you had , it makes no difference for me if I comment out the xdotool line or not. Both ways will go to the terminal prompt only after the last yad dialog is closed (by unfocus)

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Mon 29 Apr 2019, 11:38    Post subject:  

Hi, I'd like to have a 'Preview' button for a form dialog
This simple example to demonstrate works OK with the button (fbtn) as a field inside the form (with choice opening leafpad or geany what's inside the text-box):
Code:
#!/bin/bash

export load_cmd='@bash -c "editor %1 %2"'

editor () {
echo $1 > /tmp/file
[ $2 = Leafpad ] && leafpad /tmp/file || geany /tmp/file
rm -f /tmp/file
}
export -f editor

yad --form --field "code :TXT" 'Hello World' --item-separator="|" --field "Choose editor:CB" "Leafpad|Geany" --field "Preview:fbtn" "$load_cmd" --button="gtk-cancel:1"  --button="gtk-ok:0"


But.. Don't know if possible, I'd like to have the 'Preview' button next to the cancel button (see second pic) and achieve the same (opening leafpad or geany with what's in the text-box) when clicking on it, maybe need to use a pipe, can't figure out how.

Fred
2019-04-29-175347_207x260_scrot.png
 Description   Using code above, this works as it should when clicking 'Preview'
 Filesize   18.48 KB
 Viewed   416 Time(s)

2019-04-29-175347_207x260_scrot.png

2019-04-29-173118_284x217_scrot.png
 Description   
 Filesize   18.21 KB
 Viewed   421 Time(s)

2019-04-29-173118_284x217_scrot.png


_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 2377
Location: Queensland

PostPosted: Mon 29 Apr 2019, 23:59    Post subject:  

Not yad, but will this do

Code:
#!/bin/sh
#
THIS_APP="$(readlink -e "$0")"
sleep 0.3
[ `pidof "$(basename "$THIS_APP")" -o %PPID | wc -w` -gt 1 ] && exit 1

export DIALOG='
<window title="" icon-name="edit">
   <vbox>
      <edit wrap-mode="3">
         <variable>EDIT</variable>
         <height>150</height>
         <width>500</width>
      </edit>
      <hbox homogeneous="true">
      <hbox>
       <comboboxtext>
   <variable>EDITOR</variable>
   <item>Leafpad</item>
   <item>Geany</item>
   </comboboxtext>
          <button>
            <label>Preview</label>
            <input file stock="gtk-ok"></input>
            <action>`echo "$EDIT" > /tmp/file ; "${EDITOR,}" /tmp/file` &</action>
          </button>
          <button cancel></button> 
        </hbox>
      </hbox>
   </vbox>
</window>'

gtkdialog --program=DIALOG

_________________
Carolina: Recent Repository Additions

Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Tue 30 Apr 2019, 07:36    Post subject:  

fredx181 wrote:
Hi, I'd like to have a 'Preview' button for a form dialog
This simple example to demonstrate works OK with the button (fbtn) as a field inside the form (with choice opening leafpad or geany what's inside the text-box):
Code:
#!/bin/bash

export load_cmd='@bash -c "editor %1 %2"'

editor () {
echo $1 > /tmp/file
[ $2 = Leafpad ] && leafpad /tmp/file || geany /tmp/file
rm -f /tmp/file
}
export -f editor

yad --form --field "code :TXT" 'Hello World' --item-separator="|" --field "Choose editor:CB" "Leafpad|Geany" --field "Preview:fbtn" "$load_cmd" --button="gtk-cancel:1"  --button="gtk-ok:0"


But.. Don't know if possible, I'd like to have the 'Preview' button next to the cancel button (see second pic) and achieve the same (opening leafpad or geany with what's in the text-box) when clicking on it, maybe need to use a pipe, can't figure out how.

Fred


Mораш прво да затвориш дијалог да би добио вредности поља.
Када поново отвориш дијалог, само учиташ сачуване вредности поља.
Code:
#!/bin/bash

editor () {
echo $1 > /tmp/file
[ $2 = leafpad ] &&  leafpad /tmp/file || geany /tmp/file
rm -f /tmp/file
}
export -f editor

while :
do
if [[ "${text[0]}" != "" ]]; then
   Saved="${text[0]}"
else
   Saved="Hello World"
fi

tralala="${text[1]}"

if [[ "$tralala" == "Leafpad" ]]; then
   tralala="Leafpad|Geany"
elif [[ "$tralala" == "Geany" ]]; then
   tralala="Geany|Leafpad"
else
   tralala="Leafpad|Geany"
fi

IFS='|'
text=($(echo -e "${Saved}\n${tralala}\n" | yad --form --field "code :TXT"   --item-separator="|" --field "Choose editor:CB" \
--button="Preview:2" --button="gtk-cancel:1"  --button="gtk-ok:0" --cycle-read))

res=$?

unset IFS

if [ $res -eq 1 ]; then
    break
elif [ $res -eq 252 ]; then
    break
elif [ $res -eq 2 ]; then
   editor "${text[0]}" "${text[1]}" &
fi

done

Питање је само који карактер је најбољи.
На пример, ако укуцаш "|" у поље текста, сваки каратер иза тога ће бити обрисан.
У сваком случају, мислим да је боље Џефријево решење.
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4159
Location: holland

PostPosted: Tue 30 Apr 2019, 12:54    Post subject:  

Thanks Geoffrey and misko_2083 anyway, but I decided to stay with the preview button inside the form, it's for my "Markdown to HTML" experiments, and I don't like very much that the button has the full width of the GUI (800) (that's why I asked about possible different way) but I guess I'll have to accept it.
http://murga-linux.com/puppy/viewtopic.php?p=1026741#1026741

EDIT:
@Geoffrey, thanks again, your gtkdialog code was a good start for my new md2html app:
http://murga-linux.com/puppy/viewtopic.php?p=1026936#1026936

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 02 May 2019, 19:40    Post subject: Yad Twiisted Coding - Checkit out.  

I've been busy hacking Yad & a little bash scripting.

I'm swapping out icons in this example. Using --tails to feed to --text-info a Single Paned Window.

I am using Tilda Terminal that positions exactly over --text-info window so user can be guided when running terminal commands.

Still a work in progress but, I have learned so much. Thank you Misko & others for helping me.

Video of Latest Work: https://www.youtube.com/watch?v=j8DsrCBo4rQ

Back to top
View user's profile Send private message Visit poster's website 
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Wed 08 May 2019, 21:29    Post subject:  

Fredx181, if you want to make one, even simpler version of yradio,
you can use the list for navigation between the radio categories and stations.

Here's an example with the notification icon.
Left click on the icon opens a list dialog with categories.
If you select the first category, the list will cycle read "back and "item-1".
Back returns to the categories, item-1 launches the window.

xdotool is here to close the list if the notification dialog is clicked (preferable behavior),
Right click opens the menu just so that the notification can be closed.
Code:
#!/bin/bash

ERR(){ echo "ERROR: $1" 1>&2; }

declare -i DEPCOUNT=0
for DEP in /usr/bin/{xdotool,yad,xprop};do
    [ -x "$DEP" ] || {
        ERR "$LINENO Dependency '$DEP' not met."
        DEPCOUNT+=1
        }
done

[ $DEPCOUNT -eq 0 ] || exit 1

VERSION=`yad --version | awk '{ print $1 }'`
verlte() {
    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}

verlt() {
    [ "$1" = "$2" ] && return 1 || verlte $1 $2
}

if verlt $VERSION 0.38.2; then
   yad --text=" The version of yad installed is too old for to run this program, \n Please upgrade yad to a version higher than 0.38.2   " \
       --button="gtk-close"
   exit
fi


# window class for the list dialog
export CLASS="left_click_001"

# fifo
export YAD_NOTIF=$(mktemp -u --tmpdir YAD_NOTIF.XXXXXX)
mkfifo "$YAD_NOTIF"

export listpipe="/tmp/ylist.$RANDOM"
mkfifo "$listpipe"


# trap that removes fifo
trap "rm -f $YAD_NOTIF $listpipe" EXIT

# function to return to the root category
yikes_back(){
   exec 3<> $listpipe
   echo -e '\f' >&3
   printf "%s\n" "gtk-ok" "yikes_one" "category 1" "gtk-no" "yikes_launch Cat-2" "Category-2" >&3
}
export -f yikes_back


# function to open first category
yikes_one(){
   exec 3<> $listpipe
   echo -e '\f' >&3
   printf "%s\n" "gtk-refresh" "yikes_back" "Back" >&3
   printf "%s\n" "gtk-ok" "yikes_launch item-1" "Item 1" >&3
}
export -f yikes_one

# function to launch
yikes_launch(){
   txt="$1"
   yad --text "Item launched $txt"
}
export -f yikes_launch

# function to launch the list dialog
list_dialog() {
# Ensures only one instance of this window
# if there is another yad window close any dialog with the mathing class
if [[ $(pgrep -c $(basename $0)) -ne 1 ]]; then
   pids="$(xdotool search --class "$CLASS")"
   wpid="$(xdotool getwindowfocus)"

   for pid in $pids; do
        # Compares window class pid with the pid of a window in focus
        if [[ "$pid" == "$wpid" ]]; then
           xdotool windowunmap $pid
           exit 1
        fi
   done
fi

exec 3<> $listpipe

yad --list \
    --class="$CLASS" \
    --column="":IMG \
    --column="" \
    --column="" \
    --no-headers --no-buttons \
    --undecorated \
    --close-on-unfocus \
    --on-top \
    --skip-taskbar \
    --mouse \
    --width=200 --height=300 \
    --hide-column="2" \
    --sticky --cycle-read \
    --select-action="sh -c \"echo %s | sed 's/[^ ]* //' 2>&1 | xargs -I {} bash -c {} \"" <&3 &

printf "%s\n" "gtk-ok" "yikes_one" "One" "gtk-no" "yikes_launch Category-2" "two" >&3
}
export -f list_dialog

# fuction to set the notification icon
function set_notification_icon() {
  echo "icon:firefox"
  echo "tooltip:Come on"
  echo "menu:About!bash -c 'yad --about'!gtk-about||Quit!quit!gtk-quit"
}

exec 3<> $YAD_NOTIF

yad --notification --command="bash -c 'list_dialog'" --listen <&3 & notifpid=$!

# waits until the notification icon is ready
until xdotool getwindowname $(xdotool search --pid "$notifpid" | tail -1) &>/dev/null; do
        # sleep until the window opens
        sleep 0.5       
done

set_notification_icon >&3

# Waits for notification to exit
wait $notifpid

exec 3>&-

exit 0
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 41 of 51 [754 Posts]   Goto page: Previous 1, 2, 3, ..., 39, 40, 41, 42, 43, ..., 49, 50, 51 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0743s ][ Queries: 12 (0.0110s) ][ GZIP on ]