Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to use ffmpeg to use application audio only instead of the whole system audio while screen grabbing. How can I do this if the grabbing command is something like this? By application specific I mean it can be audio from chrome(audio is out from chrome through internet)

ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq  desktop.mkv

I tried to use pulse audio but I couldn't get it to work.

If someone could even post a link to a working pulse audio setup I would be grateful. I want to do this programatically. And also if I am running two separate audio streams I should be able to capture only one! I was not able to setup that using pavucontrol

share|improve this question

migrated from stackoverflow.com Mar 28 '13 at 1:12

This question came from our site for professional and enthusiast programmers.

1 Answer 1

First of all don't use -sameq: it does not mean "same quality" and has recently been removed from ffmpeg. Instead you can encode a losslessly with libx264:

ffmpeg -f x11grab -s $(xdpyinfo | grep 'dimensions:'|awk '{print $2}') -r 25 -i :0.0 -codec:v libx264 -preset ultrafast -qp 0 lossless.mkv

Using a lossless encoder is fast; meaning you have a better chance of actually capturing at your declared frame rate. However, the output can be a huge file, so once capturing is completed it is generally re-encoded to a more manageable size:

ffmpeg -i lossless.mkv -codec:v libx264 -preset medium -crf 23 -pix_fmt yuv420p output.mp4

If you computer can handle it you can skip the lossless intermediate step and encode directly to normal, lossy H.264 video.

As for the audio, according to HOWTO: Proper Screencasting on Linux:

Q: How can I control PulseAudio input? (e.g. capture application audio instead of mic)

A: Install “pavucontrol“. Start recording with ffmpeg. Start pavucontrol. Go to the “Recording” tab and you’ll find ffmpeg listed there. Change audio capture from “Internal Audio Analog Stereo” to “Monitor of Internal Audio Analog Stereo“. Now it should record system and application audio instead of microphone.

Your ffmpeg command may then look like:

ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1024x768 -i :0.0 -codec:a pcm_s16le -codec:v libx264 -preset ultrafast -qp 0 output.mkv 

Also see the FFmpeg and x264 Encoding Guide.

share|improve this answer
    
But I want to do this programatically. And also if I am running two separate audio streams I should be able to capture only one! I was not able to setup that using pavucontrol. –  Pavan K Mar 27 '13 at 20:56
    
@PavanK You should have mentioned this in your question. –  LordNeckbeard Mar 27 '13 at 21:45
    
I just did thanks for your answer and for your suggestion as well :) –  Pavan K Mar 27 '13 at 22:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.