Help with ffmpeg

I used ffmpeg to record my desktop/games on Ubuntu. I, somehow, managed to come up with a command that actually recorded everything. It was:

ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1280x1024 -i :0.0 -acodec flac -vcodec libx264 -preset ultrafast -crf 0 -threads 0 output.mkv

But now on openSUSE I have absolutely no ideia how to get it to work. The Terminal output is

junior@PC-Jr:~> ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1280x1024 -i :0.0 -acodec flac -vcodec libx264 -preset ultrafast -crf 0 -threads 0 output3.mkv
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 22 2013 19:48:32 with gcc 4.7 (SUSE Linux)
  configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --disable-static --enable-debug --disable-stripping --extra-cflags='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fPIC -I/usr/include/gsm' --enable-gpl --enable-x11grab --enable-version3 --enable-pthreads --enable-avfilter --enable-libpulse --enable-libvpx --enable-libopus --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-postproc --enable-libdc1394 --enable-librtmp --enable-libfreetype --enable-avresample --enable-libtwolame --enable-libvo-aacenc
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
ALSA lib pcm.c:2223:(snd_pcm_open_noupdate) Unknown PCM pulse
[alsa @ 0x1fab460] cannot open audio device pulse (No such file or directory)
pulse: Input/output error

Things are pretty different from what I could see. Any help?

openSUSE 12.3 with KDE (main DE) and XFCE.

MOBO: Asrock N68 VS3 UCC
Default sound card

ffmpeg keeps changing its arguments. Hence what worked yesterday with one ffmpeg, may not work tomorrow with a different ffmpeg version. This is especially true when moving between distributions.

This is what currently works for me:

ffmpeg -f pulse -i default -f x11grab -r 25 -s 1920x1200 -i :0.0 -acodec pcm_s16le -vcodec libx264 -pix_fmt yuv422p -threads 0 output.avi

In the past that has given me some audio out of sync with the video. To adjust the sync of the recorded ‘output.avi’ I applied:

ffmpeg -i output.avi -itsoffset 0.1 -i output.avi -map 1:0 -map 0:1 -vcodec libx264 -pix_fmt yuv422p -ar 22050 outfixed.avi

giving me a outfixed.avi with a better video/audio sync.

Note I am not an ffmpeg expert. Rather I picked up ideas off of other’s on the web.

It seemed to have recorded although the system froze when I tried to open the file (With Kaffeine). When I tried to open with ‘Videos’ it said I needed a ‘H.264 Codec’ even though I installed all Codecs packs.

I give it more tries with different video codecs.

For playing H.264 files with ‘Videos’ (totem) you need gstreamer-plugins-ugly-orig-addon from Packman.
I guess you just installed the codecs for gstreamer-0_10.

Regarding your freeze with Kaffeine:
I guess this could be video driver related.
What gfx card do you have?
Please install the package “Mesa-demo-x” and post the output of “glxinfo | grep render”.
Does kaffeine show some output before the system freezes if you start it in a terminal window?

This is cool. I had always wondered how to use ffmpeg to capture everything going on with screen and sound. Works, although I had to use pulse audio volume control to set things to capture the right source. That said, my audio and video were out of sync by 19 seconds (!), which the code to correct posted above did not even come close to correcting. I ended up syncing them in kdenlive. My questions: (i) is there some way to actually determine the magnitude of the sync issue without simply watching the video? (ii) What in that line needs to be changed to get the correction right? I’m just guessing it’s that -itoffset parameter?

The command for syncing is specifically tuned for the lag in my PC. The arguments can be changed for your PC.

19 seconds is excessively large. My PC has a core-i7-920 with a GTX-260 graphic card using the proprietary nvidia graphic drivers. I wonder what your PC has, so as to have such a massive desync.

Not that I know of. You are trying to sync video to audio. ie it suggests to me both references are needed.

Try various values, see what works. Its been so long since I tuned the above for my PC (over a year ago) I can no longer remember.

Doing a quick surf suggested the units for -itoffset are in seconds. I can’t recall what what the ‘sign corrects’. Possibly try

ffmpeg -i output.avi -itsoffset 19 -i output.avi -map 1:0 -map 0:1 -vcodec libx264 -pix_fmt yuv422p -ar 22050 outfixed.avi


ffmpeg -i output.avi -itsoffset -19 -i output.avi -map 1:0 -map 0:1 -vcodec libx264 -pix_fmt yuv422p -ar 22050 outfixed.avi 

… and see if either gets you in the ball park. Then iteratively find values (18.8, 18.9, 19, 19.1, 19.2 … etc ) that bring the sync closer.

19 is huge. Enormous. Is there something else going on with your PC ?