arecordmydesktop 0.0.7


i got everytime problems with my audio card and record mydesktop

Using 44100Hz instead.
Recording on device hw:0,0 is set to:
2 channels at 44100Hz
Capturing!
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.
Broken pipe: Overrun occurred.     

ok and i got always a bad audio so i have used arecord like someone has suggested on launchpad

https://bugs.launchpad.net/ubuntu/+source/recordmydesktop/+bug/339648

so i have created my personal script to screen grabbin and i got it ! now i can do my screencast with very good audio and i can denoise it automatically.

you can find it here

INSTALLATION

Install this:

sudo apt-get install oggz-tools recordmydesktop vorbis-tools sox libsox-fmt-all

Download and save it on :

/usr/local/bin/arecordmydesktop

if you don’t want install kdialog then you should create a settings file like this in this location

$HOME/arecordmydesktop.txt

:

Format for video file: ogv
Video L Size: 1280
Video H Size: 800
Video Bitrate: 1000
Audio Bitrate: 192
Frame for second: 25
Frame for second recordmydesktop: 15
Sampling Rate: 44100
CPU(dual core = 2 ): 1
Mencoder profiler for lavc: None(faster)
Mencoder profiler for xvid: None(faster)
Mencoder profiler for h264: None(faster)


**EDIT:

jaunty version 0.0.6
Karmic re-version 0.0.7 (oggz-merge instead of oggzmerge…wth…)

#!/bin/bash
######################################################################
# based on a script from lauchpad i don't remember well xD
#Creative a kubuntu user
#thanks a lot to :
#
#
#
#irc bash script channel for suggestion fix and more thank u guys !!
#
# for this work expecially Trash form irc bash channel
######################################################################
# 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.
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see
#
#
#
##check program#########################################
wokingfolder="$PWD"
tempfolder=/tmp/arecordmydesktop
noiseprofile="$HOME/noise.wav"
tempnamevideo="$tempfolder/temp.ogv"
tempnameaudio="$tempfolder/tempfull.wav"
if [[  -e "$tempfolder" ]];then
rm -Rf  "$tempfolder" ; mkdir "$tempfolder"
else
mkdir "$tempfolder"
fi
functionusageerror(){
echo "###############################################################"
echo ""
echo "arecordmydesktop version 0.0.7"
echo ""
echo "Record your desktop with recordmydesktop and arecord for audio "
echo "This resolve the problem with audio syncro"
echo "###############################################################"
echo ""
echo ""
echo "Usage:
arecordmydesktop -d  -o
Press ENTER to stop capturing and  start encoding
output format will be added automatically
**Note if you have not kdialog please see \"how to create settings file\" down
Options
-o  :   without extension
-d  : denoise audio 1-10
example:
arecordmydesktop -d 1 -o myfile
-r : Delete old settings
arecordmydesktop -r
-h : print this help
###################
DENOISE FUNCTION
###################
in order to use this function you have to record some
seconds of silence (\"perfect silence\") in this file
$HOME/noise.wav
typing this :
rec -c 1 -o $HOME/noise.wav
then the script will do automatically the rest
anyway here some stuff (you should use : SoX v14.2.0)
#############################################
SOX denoise function ; generating noise profile
##############################################
sox -c 1 $HOME/noise.wav -n trim 0 2 noiseprof $HOME/speech.noise-profile
#############################################
SOX denoise function ; denoise
##############################################
sox -c 1  INPUTFILE.WAV OUTFILE.wav noisered $HOME/speech.noise-profile  VALUE
value shoul be 0-1 (default 0.5)
i have scaled to 1-10 because i don't want write 0. stuff
you shouldn't denoise with >0.5 (in my so >5 for arecordmydesktop)
** note: -c 1 means 1 channel if you record with 1 channel and you try to use
2 channel you could get sox get this message
line 173: 22562 Segmentation fault      sox \$tempnameaudio \$tempfolder/temp.wav noisered \$HOME/speech.noise-profile \$1
so please make sure you used 1 channels
############################
HOW TO CREATER SETTINGS FILE
############################
If you have not kdialog in your system you can create
a settings file like this one and save here
$HOME/arecordmydesktop.txt
##########Settingsfile################################
Format for video file: ogv
Video L Size: 1280
Video H Size: 800
Video Bitrate: 1000
Audio Bitrate: 192
Frame for second: 25
Frame for second recordmydesktop: 15
Sampling Rate: 44100
CPU(dual core = 2 ): 1
Mencoder profiler for lavc: None(faster)
Mencoder profiler for xvid: None(faster)
Mencoder profiler for h264: None(faster)
########################################################
"
}
checkprogram(){
program[0]=recordmydesktop
program[1]=lame
program[2]=mencoder
program[3]=oggenc
program[4]=oggz-merge
program[5]=faac
program[6]=xrandr
program[7]=ffmpeg2theora
#program[3]=kdialog
for program in "${program[@]}";
do if ! type -p "$program" >/dev/null;
then echo "$program not found; PLEASE INSTALL IT" >&2
echo "error exiting..." >&2
echo
echo "You need of xrandr and..."
echo "For debian : sudo apt-get install oggz-tools recordmydesktop  mencoder vorbis-tools sox libsox-fmt-all ffmpeg2theora faac lame  "
exit 1;
fi; done
}
functionaudiodenoise(){
if [[ ! $1  ]]; then
echo "No denoise"
mv "$tempnameaudio" "$tempfolder/temp.wav"
else
if [[ ! -e  $HOME/nspeech.noise-profile  ]]; then #if doesn't exist the file noiseprofile.prf
if [[  -e "$noiseprofile" ]];then
echo "generating noiseprofile.."; sox -c 1 $noiseprofile -n trim 0 2 noiseprof $HOME/speech.noise-profile
else
echo "sorry no noise profile found. Please enter record 15 seconds of silence and save with this name $noiseprofile  "
echo "Error you want denoise but you didn't prepare a $HOME/noise.wav file before"
echo ""
echo "use this before rec -c 1 -o $HOME/noise.wav"
echo ""
echo "rec -c 1 -o $HOME/noise.wav"
echo ""
exit
fi
echo "denoising..please wait"
fi
sox -c 1 $tempnameaudio $tempfolder/temp.wav noisered $HOME/speech.noise-profile  $1
fi
}
functionclean(){
[[  -e "$tempfolder" ]]   && rm -Rf  "$tempfolder" || mkdir "$tempfolder"
exit 2
}
functionrecord(){
echo $1
# Starts audio recording.
arecord --quiet --file-type wav --rate=44100 > $tempnameaudio & pidA=$!
echo "Audio recording started with process ID $pidA"
# Starts recordmydesktop without
recordmydesktop -fps $1 --no-sound --overwrite -o $tempnamevideo 2>/tmp/arecord.txt &
pidV=$!
echo "Video recording started with process ID $pidV"
#foo& foo_pid=$! stuff; wait; echo everything has finished
# Waits for the user to press enter.
echo ""
echo "Press ENTER to finish."
read nothing
# Kills arecord and sends a Ctrl+C signal to recordmydesktop.
echo "Terminating processes $pidA and $pidV..."
kill -15 $pidA $pidV ; wait;
}
#
if [[ ! -e  "$HOME/arecordmydesktop.txt"  ]];then
defaulresolutionL=$(xrandr  | awk '/, current /{print $8}')
defaulresolutionH=$(xrandr  | awk '/, current /{gsub(/\,/,"");print $10}')
echo "No configuration file found ... creating"
if ! type -p kdialog >/dev/null; #if doesn't exist kdialog...
then
echo "No kialog detected generating default $HOME/arecordmydesktop.txt..."
echo
echo "Format for video file: ogv"   >>$HOME/arecordmydesktop.txt
echo "Video L Size: 1280"   >>$HOME/arecordmydesktop.txt
echo "Video H Size: 800"   >>$HOME/arecordmydesktop.txt
echo "Video Bitrate: 1000"   >>$HOME/arecordmydesktop.txt
echo "Audio Bitrate: 192"   >>$HOME/arecordmydesktop.txt
echo "Frame for second: 25"   >>$HOME/arecordmydesktop.txt
echo "Frame for second recordmydesktop: 15"   >>$HOME/arecordmydesktop.txt
echo "Sampling Rate: 44100"   >>$HOME/arecordmydesktop.txt
echo "CPU(dual core = 2 ): 1"   >>$HOME/arecordmydesktop.txt
echo "Mencoder profiler for lavc: None(faster)"   >>$HOME/arecordmydesktop.txt
echo "Mencoder profiler for xvid: None(faster)"   >>$HOME/arecordmydesktop.txt
echo "Mencoder profiler for h264: None(faster)"   >>$HOME/arecordmydesktop.txt
else
echo "Kdialog detected.."
echo -n "Format for video file: ">>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Format Video:" ogv avi mov mp4 flv mpeg2 mpeg1  wmv --default ogv --title $"Video Format">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Video L Size: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $" Video L Size Fullscreen($defaulresolutionL) :" 2048 1280 1024 1080 800 720 640 576 480 320 240 272 --default  $defaulresolutionL  --title $"Prefered Video Bitrate (pixel)">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Video H Size: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Video H Size Fullscreen($defaulresolutionH) :" 2048 1280 1024 1080 800 720 640 576 480 320  240 272   --default  $defaulresolutionH  --title $"Prefered Video Bitrate (pixel)">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Video Bitrate: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Video Bitrate (KB) :" 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2200 2400 2600 2800 2900 3000 4000 5000 6000   --default 1000  --title $"Prefered Video Bitrate (KB)">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Audio Bitrate: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Audio Bitrate for video file (KB) :" 32 64 92 128 192 256 320 --default 192  --title $"Prefered Audio Bitrate  for video file (KB)">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Frame for second: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Frame for seconds Value for mencoder:" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 29 21 22 23 24 25 27 28 29 30000/1001 30 --default 25  --title $"Frame for seconds Value">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Frame for second recordmydesktop: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Frame when you record :" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 29 21 22 23 24 25 27 28 29  30   --default 15  --title $"Frame for seconds Value">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Sampling Rate: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Choose Your Prefered Resampling Rate  (HZ) :" 8000 16000 44100 48000 --default 44100  --title $"Resampling Rate (KB)">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "CPU(dual core = 2 ): " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"CPU (dual core = 2 ) :" 1 2 3 4 5 6 7 8 16 3.4 xD --default 1  --title $"CPU">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Mencoder profiler for lavc: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Mencoder Prefered Profile lavc  :" $"None(faster)" $"Realtime" $"Fast" $"High quality" $"Very High Quality"   --default $"None(faster)"  --title $"CPU">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Mencoder profiler for xvid: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Mencoder Prefered Profile xvid  :" $"None(faster)" $"Realtime" $"Fast" $"High quality" $"Very High Quality"   --default $"None(faster)"  --title $"CPU">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
echo -n "Mencoder profiler for h264: " >>"$HOME/arecordmydesktop.txt" &&  kdialog --combobox $"Mencoder Prefered Profile H264  :" $"None(faster)"  $"Fast" $"High quality" $"Very High Quality"   --default $"None(faster)"  --title $"CPU">>"$HOME/arecordmydesktop.txt"
echo >>"$HOME/arecordmydesktop.txt"
fi
fi
pcontainervideo=$(awk '/Format for video file:/ {print $5}' "$HOME/arecordmydesktop.txt")
pvideoLSIZE=$(awk '/Video L Size:/ {print $4}' "$HOME/arecordmydesktop.txt")
pvideoHSIZE=$(awk '/Video H Size:/ {print $4}' "$HOME/arecordmydesktop.txt")
pvideobitrate=$(awk '/Video Bitrate:/ {print $3}' "$HOME/arecordmydesktop.txt")
paudiobitrate=$(awk '/Audio Bitrate:/ {print $3}' "$HOME/arecordmydesktop.txt")
pfpsrec=$(awk '/Frame for second recordmydesktop:/ {print $5}' "$HOME/arecordmydesktop.txt")
pfps=$(awk '/Frame for second mencoder:/ {print $4}' "$HOME/arecordmydesktop.txt")
presamplingrate=$(awk '/Sampling Rate:/ {print $3}' "$HOME/arecordmydesktop.txt")
pcpu=$(awk '/CPU/ {print $6}' "$HOME/arecordmydesktop.txt")
pmencoderprofilelavc=$(awk '/Mencoder profiler for lavc:/ {print $5}' "$HOME/arecordmydesktop.txt")
pmencoderprofilexvid=$(awk '/Mencoder profiler for xvid:/ {print $5}' "$HOME/arecordmydesktop.txt")
pmencoderprofileh264=$(awk '/Mencoder profiler for h264:/ {print $5}' "$HOME/arecordmydesktop.txt")
if [[ $pcpu == 1 ]] ;then
mcpu=""
else
mcpu=":threads=$pcpu"
fi
resolution="-vf scale=$pvideoLSIZE:$pvideoHSIZE,harddup"
checkprogram
case $1 in
-d)
noiselevel=$2; shift 2 ;outputfile=$2
if [[ ! "$noiselevel"  ]]; then
functionusageerror
echo " please set denoise value (1-10)"
exit
elif [[ $noiselevel -lt 10 ]]; then  # -lt means less
noiselevel="0.$noiselevel"
echo "Denoise value " $noiselevel
elif [[ $noiselevel -ge 10 ]]; then  # -ge Greater or Equal
noiselevel=1
echo "Denoise value  $noiselevel"
fi
if [[ ! $outputfile  ]]; then
echo "no name...."
outputfile=screencast
fi
;;
-o)
outputfile=$2; shift 1 ; checkenoise=$2 ;shift 1; noiselevel=$2
if [[ ! $checkenoise  ]]; then
if [[ ! $outputfile  ]];then
outputfile=screencast
fi
elif [[ ! $noiselevel  ]]; then
functionusageerror
echo " please set denoise value (1-10)"
exit
elif [[ $noiselevel -lt 10 ]]; then
noiselevel=0.$noiselevel
echo "Denoise value " $noiselevel
if [[ ! $outputfile  ]];then
outputfile=screencast
fi
elif [[ $noiselevel -ge 10 ]]; then
noiselevel=1
echo "Denoise value " $noiselevel
if [[ ! $outputfile  ]];then
outputfile=screencast
fi
fi
;;
-h)
functionusageerror
exit
;;
-r)
echo "Deleting settings..."
rm "$HOME/arecordmydesktop.txt"
exit
;;
*)
echo  " hey! lazy $USER detected mm are you  my  programmer?
outputfile "
outputfile=screencast
;;
esac
functionrecord $pfpsrec
functionaudiodenoise $noiselevel
#functioname
case $pcontainervideo in
ogv)
defaulresolutionL=$(xrandr  | awk '/, current /{print $8}')
defaulresolutionH=$(xrandr  | awk '/, current /{gsub(/\,/,"");print $10}')
if [[ $defaulresolutionL===$pvideoLSIZE &&  $defaulresolutionH==$pvideoHSIZE ]]; then
oggenc -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.oga 2>&1
oggz-merge --output $wokingfolder/$outputfile.ogv  $tempfolder/temp.oga $tempnamevideo
else
oggenc -b $paudiobitrate  $tempfolder/temp.wav  -o $tempfolder/temp.oga 2>&1
oggz-merge --output $tempfolder/resize.ogv  $tempfolder/temp.oga $tempnamevideo
ffmpeg2theora -x $pvideoLSIZE -y $pvideoHSIZE  $tempfolder/resize.ogv -o $wokingfolder/$outputfile.ogv
fi
;;
avi)
mvcodec=xvid
macodec=copy
# Converts the audio to mp3.
lame -m j -h --vbr-new -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.mp3
#oggenc -R $presamplingrate -b $paudiobitrate
# Converts the video to avi.
mencoder $resolution -ovc $mvcodec -xvidencopts bitrate=$pvideobitrate$mcpu -oac $macodec -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$wokingfolder/$outputfile.$pcontainervideo"
echo "mencoder $resolution -ovc $mvcodec  -xvidencopts bitrate=$pvideobitrate$mcpu -oac $macodec -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$wokingfolder/$outputfile.$pcontainervideo""
;;
mp4|mov)
mvcodec=x264
macodec=copy
faac -b $paudiobitrate -c $presamplingrate  -o  $tempfolder/temp.aac $tempfolder/temp.wav
mencoder  $resolution -ovc $mvcodec -x264encopts bitrate=$pvideobitrate$mcpu -oac copy -audiofile $tempfolder/temp.aac $tempnamevideo -o "$wokingfolder/$outputfile.$pcontainervideo"
;;
flv)
mvcodec=lavc
macodec=copy
lame -m j -h --vbr-new -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.mp3
mencoder $resolution  -ovc $mvcodec -lavcopts vcodec=flv:vbitrate=$pvideobitrate$mcpu -oac copy -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$wokingfolder/$outputfile.$pcontainervideo"
;;
mpeg2)
pcontainervideo=mpeg
mvcodec=lavc
macodec=copy
lame -m j -h --vbr-new -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.mp3
mencoder $resolution  -ovc $mvcodec -lavcopts vcodec=mpeg2video:vbitrate=$pvideobitrate$mcpu -oac copy -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$wokingfolder/$outputfile.$pcontainervideo"
;;
mpeg1)
pcontainervideo=mpeg
mvcodec=lavc
macodec=copy
lame -m j -h --vbr-new -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.mp3
mencoder $resolution  -ovc $mvcodec -lavcopts vcodec=mpeg1video:vbitrate=$pvideobitrate$mcpu -oac copy -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$baseName-final".$pcontainervideo
functionclean
;;
wmv)
mvcodec=lavc
macodec=copy
lame -m j -h --vbr-new -b $paudiobitrate $tempfolder/temp.wav  -o $tempfolder/temp.mp3
mencoder $resolution  -ovc $mvcodec -lavcopts vcodec=wmv2:vbitrate=$pvideobitrate:abitrate=$paudiobitrate$mcpu -oac lavc -audiofile $tempfolder/temp.mp3 $tempnamevideo -o "$baseName-final".$pcontainervideo
;;
esac
echo "file is here $wokingfolder/$outputfile.$pcontainervideo"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: