LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Show Progress with Nautilus script (https://www.linuxquestions.org/questions/programming-9/show-progress-with-nautilus-script-750186/)

handband2 08-25-2009 02:48 PM

Show Progress with Nautilus script
 
I have a script which I run to convert my .MTS videos to .flv. The script is in my Nautilus script folder. When I run the script it runs perfectly fine in the background without showing me any progress. I would like to see the progress of the conversions.

I've tried to get gnome-terminal and xterm pop-up to show the progress without success. I would appreciate it if someone could help, thanks!

Code:

#!/bin/bash

mkdir ./converted

for f in *.MTS; do ffmpeg -i "$f" -vcodec libx264 -acodec libmp3lame -ar 22050 -ab 32K -s 768x432 -f flv ./converted/"${f%.mpg}.flv"; done


schneidz 08-26-2009 10:07 AM

i think you want to look into zenity or gdialog.
http://linux.die.net/man/1/zenity
the option you need is probably --progress

handband2 08-27-2009 12:37 AM

Quote:

Originally Posted by schneidz (Post 3658363)
i think you want to look into zenity or gdialog.
http://linux.die.net/man/1/zenity
the option you need is probably --progress

schneidz,

Thanks, I did end up using zenity. This is what the code looks like now:
Code:

#!/bin/bash
## Youtube formating:  http://www.google.com/support/youtube/bin/answer.py?answer=132460&topic=16612&hl=en-US
## Recommended: 1280 x 720 (16x9 HD) and 640 x 480 (4:3 SD)
## http://www.flashsupport.com/books/fvst/files/tools/video_sizes.html
## Widescreen: 256x144  - 512x288 - 768x432 - 1024x576

#Check for required software...
ffmpeg_bin=`which ffmpeg | grep -c "ffmpeg"`

# Check for ffmpeg
if [ $ffmpeg_bin -eq "0" ]; then
zenity --error --title="Error - Missing Software" \
 --text="You do not have the ffmpeg package installed
Please install it in order to use this script.
Make sure that the Universe repositories are enabled and
then type: 'sudo apt-get install ffmpeg' at a terminal."
exit
fi

# Dialog box
SIZE=`zenity --height=220 --width=220 --list --radiolist \
        --title="Choose Resolution" \
        --column="Check" --column="Size" \
        "" "256x144" \
        "" "512x288" \
        "" "768x432" \
        "" "1024x576" \
        "" "1280x720"`

if [ "${SIZE}" == "" ]; then   
zenity --error --text="Resolution not defined by user.
Please choose a resolution to use. "
exit 1
fi

# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find . -maxdepth 1 -type f -name "*.MTS" | wc -l`
let "INCREMENT=100/$NUMBER_OF_FILES"

mkdir ./converted

# Converting Files
(for file in *.MTS; do
echo "$PROGRESS";
echo "# Converting $file ...";
ffmpeg -i "$f" -r 29.97 -vcodec libx264 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 21 -bt 256k -refs 1 -coder 0 -me_method full -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -s "${SIZE}" -aspect 16:9 -acodec libfaac -ab 112kb -ar 48000 -ac 2 ./converted/"${file%.MTS}.mp4"
let "PROGRESS+=$INCREMENT"
done
) | zenity  --progress --width=300 --title "Converting "${NUMBER_OF_FILES}" Files to "${SIZE}"" --percentage=0


schneidz 08-27-2009 10:05 AM

hi, i made this a while back in case you are interested:
http://www.linuxquestions.org/questi...tc.ksh-510861/
__________

also this post #2 has a mencoder based dvd ripper but no nautilus script front-end:
http://www.linuxquestions.org/questi...center-719104/

allankelly 03-31-2012 03:22 AM

Thanks for the zenity tip. I just want to see the output of my script so I pipe into zenity --text-info

Cheers, al.


All times are GMT -5. The time now is 07:32 AM.