Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#!/bin/bash
EXT=(*.flv *.mp* *.mkv)
for i in "${EXT[@]}"; do ffmpeg -i "$i" -acodec ac3 -ab 128k -vcodec libx264 -vpre hq -profile high -preset veryslow -crf 15 -threads 2 ${i%.*}.mkv";done
exit 0
Edit 1
Audio bit rate changed to 128k because 96k produced some bad results. libfaac changed to ac3 do to libfaac making a binary that can not be re-distrobuted, and changed the format to mkv instead of mp4 because it is more versitile. This will create files with h.264 and ac3 in one mkv file. video preset changed to medium because normal does not exist.
Edit 2
Changed crf to 15 because 22 produced some low quality picture. Also use the -tune option for specific types of media so that compression and quality will be better. -tune animation for animation, -tune grain for grainy sources, and -tune film for basically film that is not grainy nor animation. Some of these options should be changed to fit specific needs.
Last edited by darkstarbyte; 02-01-2012 at 09:10 PM.
you will define an array and any reference to it with a plain $EXT will only list the first element, the "*.flv". To expand it for your "for loop" to all elements in the array, it must be referenced as:
I am half asleep and I need help with this shell script.
Code:
#!/bin/bash
# Writen by darkstarbyte and catkin for Gentoo. Date 12-28-10
# You will have to run this as root.
# This shell script is ment to compile a vanilla kernel on Genoo.
# This version is now outdated as of 1-jan-11
# This is my first shell script and I am very tired...
# Also this is written by anyone else who would kindly help.
# If you do help, tell me the name you would like to be listed as.
echo "Welcome to the Gentoo vanilla kernel builder";
echo >> web_temp_for_vanilla.sh_temp;
while_line=5
echo "If you say yes you will be presented with a list of kernel options.(y,n)";
while read answer
do # darkstarbyte 12-30-10 this whole line.
{ # darkstarbyte 12-30-10 this whole line.
if [ $answer = y ] # added spaces in between r, =, and ] #catkin #12-29-10
then
exit
# I was hoping this would exit this loop.
elif [ $answer = n ] # added spacing with r, =, and ] # catkin #12-29-10 catkin edit.
then
exit
exit
# I was hoping this would exit the script.
else
echo "Try again."
fi
{ # darkstarbyte 12-30-10 this whole line.
while $while_line = 5 # added spaces between e, =, and 5 #catkin #12-29-10
do
{ # darkstarbyte 12-30-10 this whole line.
wget --tries=2 --output-document=web_temp_for_vanilla.sh_temp http://www.kernel.org
echo hit q to quit.
# I was hoping this would not do anything until the user hits enter.
cat web | less
echo "If you would like to continue type y, if you would like to take another look at the web page then type n"; # this should not have # been separated by enter echo just before these comments. # darkstarbyte 12-29-10
do
read
answer
if [ answer = y ] # spacing in between r, =, and y #catkin 12-29-10
then
cat web_temp_for_vanilla.sh_temp | less
else
exit
} # darkstarbyte 12-30-10 this whole line.
rm web_temp_for_vanilla.sh_temp
echo "What kernel version do you want?";
read version
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$version.tar.bz2
tar -jxvf linux-$version.tar.bz2 -C /usr/src/
cd /usr/src/linux-$version
echo "Are you ready to configure the kernel?(y,n)"
read answer
if [ $answer = y ] # spacing in between r, =, y, and ] #catkin #12-29-10
{ # darkstarbyte 12-30-10 this whole line.
then
make menuconfig
} # darkstarbyte 12-30-10 this whole line.
elif [ $answer = n ] #spacing in between r, =, n, and ] #catken #12-19-10
then
{ # darkstarbyte 12-30-10 this whole line.
echo "bye";
exit
} # darkstarbyte 12-30-10 this whole line.
else
echo "Try again."
make && make modules_install
cp arch/x86/boot/bzimage /boot/linux-$version
echo "linux-$version" >> /boot/grub.conf;
cd ~
echo "done";
exit
Change log like system inspired by the linux kernel.
Last edited by darkstarbyte; 01-01-2011 at 08:36 PM.
Reason: Repairs to my shell script. and change log note.
My edited shell script is back. With brackets, and note to document it. This version is also at my previous post.
I am half asleep and I need help with this shell script.
Code:
#!/bin/bash
# Writen by darkstarbyte for Gentoo. Date 12-30-10
# This is catkin's evolution of my shell script, with a few minor edits.
# You will have to run this as root.
# This shell script is meant to compile a vanilla kernel on Genoo.
# This is my first shell script and I am very tired...
# Also this is written by anyone else who would kindly help.
# If you do help, tell me the name you would like to be listed as.
echo 'Welcome to the Gentoo vanilla kernel builder'
echo >> web_temp_for_vanilla.sh_temp # What is this intended to do?
echo "View list of kernel options? (y or n)" # The second quotation. Darkstarbyte 1-jan-11
while read answer
do
case $answer in
y | Y )
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2 # Helpful to show what was entered. Error messages conventionally written to stderr
esac
done
while_line=5 # Easier to understand what it is for here but it is not changed ... ?
while [[ $while_line -eq 5 ]] # Previous version runs $while_line. [[ more robust than [
do
wget --tries=2 --output-document=web_temp_for_vanilla.sh_temp http://www.kernel.org
# Would be prudent to have an error trap
while true
do
echo 'V to view web page, C to continue'
read answer
case $answer in
v | V )
cat web_temp_for_vanilla.sh_temp | less
;;
c | C )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
rm web_temp_for_vanilla.sh_temp
echo 'Which kernel version do you want?'
read version
# Would be prudent to have some sanity checking on the version entered
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$version.tar.bz2
# Would be prudent to have an error trap
tar -jxvf linux-$version.tar.bz2 -C /usr/src/
# Would be prudent to have an error trap
cd /usr/src/linux-$version
# Would be prudent to have an error trap
while true
do
echo 'Configure kernel? (y or n)'
read answer
case $answer in
y | Y )
make menuconfig # No break after this in case user wants to configure some more
;;
n | N )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
while true
do
echo 'Build and install? (y or n)'
read answer
case $answer in
y | Y )
make \
&& make modules_install \
&& cp arch/x86/boot/bzimage /boot/linux-$version \
&& echo "linux-$version" >> /boot/grub.conf # What is this intended to do?
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2
esac
done
done
# This code never reached because there is no break from the outermost do-done loop above
# After this script exits the calling shell's currrent directory is as it was
# before this script was called so the next line achieves nothing
cd ~
echo "${0##*/}: exiting"
exit
Change log inspired by the linux kernel.
Last edited by darkstarbyte; 01-01-2011 at 08:23 PM.
Reason: Updated version by catkin.
The { } groups are not necessary or useful. Here's an untested evolution of the script illustrating some techniques you may find useful. I do not yet understand the logic (= the control flow, conditional execution) intended, especially about the use of $while_line and which steps you want the user to be able to skip and when you want them to be able to terminate the script. Presumably the script is intended for use by sysadmins who could be expected to be OK with a "Use Ctrl+C to terminate this script at any of the prompts"; this would simplify the programming, leaving more time for error trapping. In its present state this script is a long way from how I would write it so I have removed my name from the credits; not to say it isn't a worthy effort but you will likely say the same thing in a few months, weeks or days.
BTW the MM-DD-YY date format is ambiguous in countries which use the DD-MM-YY format when DD is 12 or less; DDmmmYY (such as 30dec10) is as brief as possible while being unambiguous, otherwise 30-Dec-10 has advantages.
Code:
#!/bin/bash
# Writen by darkstarbyte for Gentoo. Date 12-30-10
# You will have to run this as root.
# This shell script is meant to compile a vanilla kernel on Genoo.
# This is my first shell script and I am very tired...
# Also this is written by anyone else who would kindly help.
# If you do help, tell me the name you would like to be listed as.
echo 'Welcome to the Gentoo vanilla kernel builder'
echo >> web_temp_for_vanilla.sh_temp # What is this intended to do?
echo "View list of kernel options? (y or n)'
while read answer
do
case $answer in
y | Y )
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2 # Helpful to show what was entered. Error messages conventionally written to stderr
esac
done
while_line=5 # Easier to understand what it is for here but it is not changed ... ?
while [[ $while_line -eq 5 ]] # Previous version runs $while_line. [[ more robust than [
do
wget --tries=2 --output-document=web_temp_for_vanilla.sh_temp http://www.kernel.org
# Would be prudent to have an error trap
while true
do
echo 'V to view web page, C to continue'
read answer
case $answer in
v | V )
cat web_temp_for_vanilla.sh_temp | less
;;
c | C )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
rm web_temp_for_vanilla.sh_temp
echo 'Which kernel version do you want?'
read version
# Would be prudent to have some sanity checking on the version entered
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$version.tar.bz2
# Would be prudent to have an error trap
tar -jxvf linux-$version.tar.bz2 -C /usr/src/
# Would be prudent to have an error trap
cd /usr/src/linux-$version
# Would be prudent to have an error trap
while true
do
echo 'Configure kernel? (y or n)'
read answer
case $answer in
y | Y )
make menuconfig # No break after this in case user wants to configure some more
;;
n | N )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
while true
do
echo 'Build and install? (y or n)'
read answer
case $answer in
y | Y )
make \
&& make modules_install \
&& cp arch/x86/boot/bzimage /boot/linux-$version \
&& echo "linux-$version" >> /boot/grub.conf # What is this intended to do?
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2
esac
done
done
# This code never reached because there is no break from the outermost do-done loop above
# After this script exits the calling shell's currrent directory is as it was
# before this script was called so the next line achieves nothing
cd ~
echo "${0##*/}: exiting"
exit
Last edited by catkin; 12-30-2010 at 10:53 AM.
Reason: usually used -> use
Hopefully this will be the last version of my shell script kernel builder for Gentoo.
Here it is. (Keep in mind this is for Gentoo with grub 0.97. Read comment to know how to make it for a newer version.)
Code:
#!/bin/bash
# Writen by darkstarbyte for Gentoo. Date 12-30-10
# This is catkin's evolution of my shell script, with a few minor edits.
# You will have to run this as root.
# This shell script is meant to compile a vanilla kernel on Genoo.
# This is my first shell script and I am very tired...
# Also this is written by anyone else who would kindly help.
# If you do help, tell me the name you would like to be listed as.
echo 'Welcome to the Gentoo vanilla kernel builder'
echo >> web_temp_for_vanilla.sh_temp # What is this intended to do?
pwd >> directory
echo "Are you sure you want to compile your own kernel? (y or n)" # The second quotation and the writing. Darkstarbyte 1-jan-11
while read answer
do
case $answer in
y | Y )
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2 # Helpful to show what was entered. Error messages conventionally written to stderr
esac
done
while_line=5 # Removed comment. darkstarbyte 1-2-11
while [[ $while_line -eq 5 ]] # Previous version runs $while_line. [[ more robust than [
do
wget --background --tries=2 --output-document=web_temp_for_vanilla.sh_temp http://www.kernel.org # Background option darkstarbyte 1-jan-11
# Would be prudent to have an error trap
while true
do
echo 'V to view web page, C to continue. (To quit viewing the webpage hit q)'
read answer
case $answer in
v | V )
cat web_temp_for_vanilla.sh_temp | less
;;
c | C )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
rm web_temp_for_vanilla.sh_temp
echo 'Which kernel version do you want?'
read version
rm linux-$version.tar.bz2 # darkstarbyte 1-jan-11
# Would be prudent to have some sanity checking on the version entered
rm wget-log # darkstarbyte 1-jan-11
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$version.tar.bz2
# Would be prudent to have an error trap
tar -jxf linux-$version.tar.bz2 -C /usr/src/ # I got rid of verbose for those with no frame buffers. # darkstarbyte 1-jan-11
# Would be prudent to have an error trap
cd /usr/src/linux-$version/
# Would be prudent to have an error trap
while true
do
echo 'Configure kernel? (y or n)'
read answer
case $answer in
y | Y )
make menuconfig # No break after this in case user wants to configure some more
;;
n | N )
break
;;
* )
echo "Invalid answer $answer" >&2
esac
done
# This allow the user to name the kernel. # darkstarbyte 1-jan-11
echo 'What would you like to name the kernel?' # This comment and to the end of the following while loop. # darkstarbyte 1-jan-11
while true
do
read name
echo "Are you sure you want to name your kenel $name?"
read answer
case $answer in
y | Y )
break
;;
n | N )
read name
echo "Are you sure you want to name your kernel $name.?"
;;
* )
echo "Invalid answer $answer" >&2
esac
done # My work ends for this loop. #darkstarbyte 1-jan-11
while true
do
echo 'Build and install? (y or n)'
echo 'This uses the old grub .97' # darkstarbyte 1-jan-11
read answer
case $answer in
y | Y )
make \
&& make modules_install \
&& cp arch/x86/boot/bzimage /boot/linux-$name \ #replaced comment and $version with $name. darkstarbyte 1-jan-11
echo "title linux-$name" >> /boot/grub/grub.conf # Got rid of &&. It was unneeded. # darkstarbyte 1-jan-11
# Added title and the file it is supposed to be written to.
# $name instead of $version. darkstarbyte 1-jan-11
# Line above this is intended to add the kernel to grub on new grub you use make grub and for lilo run make lilo. # darkstarbyte 1-jan-11
echo 'root(0,0)' >> /boot/grub/grub.conf # Added this whole line. # darkstarbyte 2-jan-11
echo "kernel linux-$name root=/dev/sda3"
break
;;
n | N )
exit
;;
* )
echo "Invalid answer $answer" >&2
esac
done
done
# Three lines of comments removed. darkstarbyte 1-jan-11.
cd $directory
echo "${0##*/}: exiting"
exit
Last edited by darkstarbyte; 01-02-2011 at 10:30 PM.
I am working on a slackware kernel builder. I am going to use the Gentoo one as a template. The only thing I need to do is add a sanity check, and configure it for lilo.
Canceled.
Last edited by darkstarbyte; 07-13-2011 at 04:35 PM.
Here is a shell script for taking mkv to mp4 files for the playstation 3. This is much faster than converting the file again.
Code:
#!/bin/bash
# Before you run this script you must know that your responsible
# for the changes it makes.
set -e # for debugging.
# My script assumes that you are using ac3.
# This script is built for those who use x264,
# with a mkv container.
# It is now a fixme.
for i in *.mkv; do \
two="${i%.*}.264"; \
audio="${i%.*}.ac3"; \
mkvextract tracks "$i" "1:$two" "2:$audio"; \
MP4Box -add "$two" -add "$audio" "${i%.*}.mp4"; \
rm "$two" "$audio";done
exit 0
There are some bugs in this script like the first track on the mkv has to be video the second audio. Also the audio can be off.
Last edited by darkstarbyte; 07-13-2011 at 05:00 PM.
Instead of making files in ffmpeg you might want to do things with x264.
Code:
#!/bin/bash
EXT=(*.avi *.flv *.mp4 *.wmv) # Add file extensions as needed.
for i in "${EXT[@]}"; do x264 --crf 15 --preset medium -o "${i%.*}.mkv" "$i";done
# Use the tune setting based on what type of source you have.
# --tune animation for animation, --tune grain for grainy sources, and --tune film for
# basically film that is not grainy nor animation.
# The reason why one should use tune is because certain types of media need to have loss
# in certain ways like for film it is best to have artifacts, and for animation it is best
# to have blur.
# Change preset based on need, you can use ultrafast, superfast,
# veryfast, faster, fast,
# medium, slow, slower, veryslow, and placebo.
exit 0
Last edited by darkstarbyte; 07-15-2011 at 08:31 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.