<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.slacky.eu/wikislack/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="it">
		<id>http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress_(en)&amp;feed=atom&amp;action=history</id>
		<title>Mencoderprogress (en) - Cronologia</title>
		<link rel="self" type="application/atom+xml" href="http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress_(en)&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress_(en)&amp;action=history"/>
		<updated>2013-05-23T13:25:09Z</updated>
		<subtitle>Cronologia della pagina su questo sito</subtitle>
		<generator>MediaWiki 1.20.3</generator>

	<entry>
		<id>http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress_(en)&amp;diff=5441&amp;oldid=prev</id>
		<title>414n: Nuova pagina: Category:Script  ''Per la versione in italiano di questa pagina, fiondarsi [http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress qui]''  = Introduction =   At first, I t...</title>
		<link rel="alternate" type="text/html" href="http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress_(en)&amp;diff=5441&amp;oldid=prev"/>
				<updated>2008-10-04T08:20:30Z</updated>
		
		<summary type="html">&lt;p&gt;Nuova pagina: &lt;a href=&quot;/slacky/Categoria:Script&quot; title=&quot;Categoria:Script&quot;&gt;Category:Script&lt;/a&gt;  &amp;#039;&amp;#039;Per la versione in italiano di questa pagina, fiondarsi [http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress qui]&amp;#039;&amp;#039;  = Introduction =   At first, I t...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nuova pagina&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Script]]&lt;br /&gt;
&lt;br /&gt;
''Per la versione in italiano di questa pagina, fiondarsi [http://www.slacky.eu/wikislack/index.php?title=Mencoderprogress qui]''&lt;br /&gt;
&lt;br /&gt;
= Introduction = &lt;br /&gt;
&lt;br /&gt;
At first, I thought to write down a script to capture ffmpeg conversions progress, in order to display it in percentage instead of the actual position (in seconds) inside the stream (not that great to have an idea of the actual progress).&lt;br /&gt;
After the completion of that script (which will be published shortly here on Wikislacky), I made a similar one for mencoder.&lt;br /&gt;
&lt;br /&gt;
mencoder shouldn't need a script like this which elaborates its output in order to display a percentage of the conversion progress, because it already does it. However, sometimes, the percentage shown by mencoder itself stays at 0% meanwhile the position inside the stream (in seconds) works everytime.&lt;br /&gt;
&lt;br /&gt;
Given this, I made this script. It's automatically invoked by my other script [http://www.slacky.eu/wikislack/index.php?title=ToZenAviMencoder_%28en%29 toZenAviMencoder], being it also available here on Wikislacky.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
This script screens the normal output on standard output (stdout) of mencoder to show, instead, the progress of the video conversion, using a percentage. If dialog is inside the PATH, it will be used. Otherwise, the progress will be shown using a normal echo.&lt;br /&gt;
&lt;br /&gt;
= Current Version =&lt;br /&gt;
&lt;br /&gt;
Current version is 1.01, released on 02/10/2008 (date is in dd/mm/yyyy format).&lt;br /&gt;
&lt;br /&gt;
= Dependencies =&lt;br /&gt;
&lt;br /&gt;
; GNU Bash : Needed in order to execute the script.&lt;br /&gt;
; mencoder : To produce the output to elaborate.&lt;br /&gt;
; awk : Used to process/filter information.&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
&lt;br /&gt;
The script must be piped with mencoder, so it can capture its output on standard output. A usage example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mencoder &amp;lt;parameters&amp;gt; | mencoderprogress.sh 634 &amp;quot;Converting Doo da doo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where:&lt;br /&gt;
; 634 : Is the movie length in seconds. I was forced to put it as a command line parameter because the output of mencoder (contrary to that of ffmpeg) lacks this information. If not specified, the default value of &amp;quot;9999999&amp;quot; is used (not much sense...).&lt;br /&gt;
; &amp;quot;Converting Doo da doo&amp;quot; : Is the message to be displayed during conversion. If not specified, the message &amp;quot;Converting video...&amp;quot; will be shown.&lt;br /&gt;
&lt;br /&gt;
'''UPDATE'''&lt;br /&gt;
&lt;br /&gt;
From version 1.01 a new user editable variable has been added:&lt;br /&gt;
&lt;br /&gt;
; REFRESH_TIME : Tells how much seconds must pass before the percentage needs to be updated (in seconds). If not set, default value is 3 (seconds).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Script =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Script used to show the progress of a mencoder conversion.&lt;br /&gt;
# Made for you by 414N &amp;lt;414N atATat slacky dotDOTdot it&amp;gt;&lt;br /&gt;
# 02/09/2008&lt;br /&gt;
# Versione 1.01&lt;br /&gt;
# Parameters:&lt;br /&gt;
# (stdin) : piped mencoder output&lt;br /&gt;
# $1 : Movie length (in seconds)&lt;br /&gt;
# $2 : Messagge to show&lt;br /&gt;
&lt;br /&gt;
# Arguments check&lt;br /&gt;
&lt;br /&gt;
DURATION=${1:-&amp;quot;9999999&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
MESSAGE=${2:-&amp;quot;Converting video...&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
# Variable which contains the last elaborated progress value. Used to save prints.&lt;br /&gt;
&lt;br /&gt;
OLDPROGRESS=0&lt;br /&gt;
&lt;br /&gt;
# Variable containg the actual progress, elaborated time to time.&lt;br /&gt;
&lt;br /&gt;
PROGRESS=0&lt;br /&gt;
&lt;br /&gt;
# Percentage refresh interval (to boost performance)&lt;br /&gt;
# It is in seconds.&lt;br /&gt;
&lt;br /&gt;
REFRESH_TIME=${REFRESH_TIME:-3}&lt;br /&gt;
&lt;br /&gt;
# dialog presence in PATH check&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$USE_DIALOG&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
	if [ `which dialog 2&amp;gt;/dev/null` = &amp;quot;&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		USE_DIALOG=0&lt;br /&gt;
	else&lt;br /&gt;
		USE_DIALOG=1&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Function to output the progress to screen&lt;br /&gt;
#&lt;br /&gt;
# Parameters:&lt;br /&gt;
# $1 = Actual progress (integer)&lt;br /&gt;
&lt;br /&gt;
function print_progress ()&lt;br /&gt;
{&lt;br /&gt;
	if [ &amp;quot;$USE_DIALOG&amp;quot; = 0 ]&lt;br /&gt;
	then&lt;br /&gt;
		echo -ne &amp;quot;$MESSAGE : $1%\r&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$1&amp;quot; | dialog --title &amp;quot;mencoder video conversion&amp;quot; --gauge &amp;quot;$MESSAGE&amp;quot; 10 50&lt;br /&gt;
	fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print_progress 0&lt;br /&gt;
&lt;br /&gt;
while read -e -d $'\r' INFO&lt;br /&gt;
do&lt;br /&gt;
	ACTUAL_TIME=$(echo &amp;quot;$INFO&amp;quot; | awk -F's' '{gsub(/ */,&amp;quot;&amp;quot;,$2); print $2}' | cut -d':' -f2 | awk '/^([1-9][0-9]*\.[0-9]*)$/')&lt;br /&gt;
	if [ $ACTUAL_TIME ]&lt;br /&gt;
	then &lt;br /&gt;
		PROGRESS=$(echo &amp;quot;$ACTUAL_TIME $DURATION&amp;quot; | awk '{printf &amp;quot;%.0f\n&amp;quot;,$1 / $2 * 100}')&lt;br /&gt;
		if [ &amp;quot;$PROGRESS&amp;quot; -ne &amp;quot;$OLDPROGRESS&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			print_progress &amp;quot;$PROGRESS&amp;quot;&lt;br /&gt;
			OLDPROGRESS=&amp;quot;$PROGRESS&amp;quot;&lt;br /&gt;
			read -t &amp;quot;$REFRESH_TIME&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
done &lt;br /&gt;
if [ &amp;quot;$PROGRESS&amp;quot; -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
	exit 1&lt;br /&gt;
else&lt;br /&gt;
	print_progress 100&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
 &lt;br /&gt;
You just need to put the script inside a path contained in the PATH enviroment variable, and grant it execution permission. I suggest to create a folder (bin, for example) inside your home folder and put it in your PATH, editing/creating the ~/.bashrc and ~/.bash_profile files with the following&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export PATH+=&amp;quot;:~/bin&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Changelog =&lt;br /&gt;
&lt;br /&gt;
; 1.00 : initial version of the script.&lt;br /&gt;
; 1.01 : added a refresh interval in order to boost performance.&lt;br /&gt;
&lt;br /&gt;
= Feedback = &lt;br /&gt;
&lt;br /&gt;
If you've got something to say/report, please do it [http://www.slacky.eu/forum/viewtopic.php?f=12&amp;amp;t=26147 here]. It's an italian Slackware forum.&lt;br /&gt;
&lt;br /&gt;
[mailto:414N_atATat_slacky_dotDOTdot_it 414n]&lt;/div&gt;</summary>
		<author><name>414n</name></author>	</entry>

	</feed>