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?

user1610950
  • 759
  • 2
  • 9
  • 22

2 Answers2

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
}
jai_s
  • 1,480
  • 7
  • 7
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

daisy
  • 53,527
  • 78
  • 236
  • 383
  • wow, bash is pretty nice! – user1610950 Feb 05 '16 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 05 '16 at 17:03