1

I have an alias to a ffmpeg command to start recording a session like this:

alias sreq='ffmpeg -f x11grab -r 24 -s 1024x768 -i :0.0 -qp 0 -c:v libx264 -preset veryslow'

I can just type sreq filename.mkv to start recording. This is pretty good but I'd like to fix this up a bit.

since I always record in .mkv format, how can I have it so that i can avoid having to type .mkv

how could I rework this alias command or something so that I can just type sreq filename or sreq /path/to/filename

and have it work as expected?

0

2 Answers 2

3

One way is to use a function instead of the alias - put this in your .bashrc or .bash_profile -

sreq()
{
 ffmpeg -f x11grab -r 24 -s 1024x768 -i :0.0 -qp 0 -c:v libx264  -preset veryslow $1.mkv
}
1

Why don't you just upgrade the alias to a function,

e.g

function sreq() 
{
   ffmpeg -f x11grab -r 24 -s 1024x768 -i :0.0 -qp 0 -c:v libx264 -preset veryslow "$1".mkv
}

When you type sreq /path/to/filename it would become ffmpeg ..(redacted)... /path/to/filename.mkv

2
  • wow, bash is pretty nice! Feb 5, 2016 at 16:57
  • 1
    This works with almost any bourne-like shell if you remove the function keyword. The POSIX compliant dash shell doesn't understand the function keyword, ksh understands the function keyword sometimes. Most shells understand f() { commands; }.
    – RobertL
    Feb 5, 2016 at 17:03

Not the answer you're looking for? Browse other questions tagged .