How to convert video file type with robot voice feedback using bash script on Linux

  When I record my screen video, I used  desktop recorder software call "RecordMyDesktop" .You can get it by downloading from Ubuntu repositories. The recorder will record in .OGV file type. Video editor like Openshot (version 1.4.3), Kdenlive (version 4.8.5) ,Pitivi and others have problem in editing this  kind of file type.Sometime while using  the video editor to edit  .OGV file, you will get skipping frame,frame not moving or grey screen .

 To resolve this issue, I used "avconv" to convert my video to other file type . "avconv" is  fast and reliable tools  that can be use to grab audio/video source ,convert file and do many other cool stuff. There are certain settings that  I used to make sure the converted video is in good quality when using "avconv" . I will share some tricks on using "avconv" in other post.

   In this post, I will share how you can create a bash script to convert your video file,what the script does is, it will convert the file and will ask  user what name will it give to the new file with robot feedback voice . The script will only convert a single file at a time.To make it run on your machine, you need to save the script inside the folder which is included in your working PATH .Please refer here for more information.

Script drill down

1.My Normal script header

#Title : Video converter with robot feedback voice
#Author : N3rv3wr3ck
#Date : 17/1/2014
#Rev : 1.0

2. "Avconv" setting for my video conversion.I convert the file to MP4

avconv -i $1 -s hd1080 -c:v libx264 -crf 23 -c:a aac -strict -2 $1.mp4  # file type that you want to convert to

3. "espeak"is function that I use to convert text to speech.Make sure you put the word in ("") .On terminal it will echo "Please rename your file" .Once you type the file name,it will be store in variable "new"

espeak "Please rename your file"                                       # robot voice for file renaming
echo "Please rename your file " # show on screen
read new # store in variable "new"

4.This part of the script will rename the existing file in the directory. Since i'm using this script for .ogv file converted to  .Mp4 ,the converted file by default will have  naming convention something like "filename.ogv.mp4" . for loop control will look for file with ".ogv.mp4"and will rename the file using the name stored in variable "new" . The new file name will change it's naming convention to  "filename.mp4"

for file in *ogv.mp4;do                                         # The converter file will have ".ogv.mp4" 
file name mv "$file" "$new.mp4"                        # Rename the file using above variable 

Test it!!!

Please download the  full script here .

Next Post »