Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: FFmpeg and x11grab?

  1. #21
    Join Date
    May 2007
    Beans
    264

    Re: FFmpeg and x11grab?

    Quote Originally Posted by n3had View Post
    Code:
    ffmpeg -f alsa -i plughw:0 -f x11grab -s 1920x1080 -r 24 -b 100k -bf 2 -g 300 -i :0.0 -ar 22050 -ab 128k -acodec libmp3lame -vcodec libxvid -aspect 1.77777778 -sameq MyScreencast.avi
    using the above command gives me very low fps around 5 i guess.

    Using the opensource Ati drivers for HD4200
    Not working for me and this is getting me insane!!!

    First of all, I had to adapt that command since it simply didn't work.
    ffmpeg didn't knew what "alsa" was :s
    > Unknown input or output format: alsa

    I'm using ffmpeg SVN-r19468 built on Jul 20 2009 20:26:33, gcc: 4.3.3

    I tried the following but only got a black screen and no sound:
    ffmpeg -f oss -i /dev/audio -f x11grab -s 1280x1024 -r 24 -b 100k -bf 2 -g 300 -i :0.0 -ar 22050 -ab 128k -acodec libmp3lame -vcodec libxvid -aspect 1.6 -sameq MyScreencast.avi
    Note that I'm trying to capture output audio.
    That is, I want to open a video file and capture what is played to the speakers.
    Ideally I would like to record both output and input audio streams.

    I have nVidia proprietary drivers.

    $ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 0: Intel [HDA Intel], device 1: AD198x Digital [AD198x Digital]
    Subdevices: 1/1
    Subdevice #0: subdevice #0


    $ cat /proc/asound/devices
    0: [ 0] : control
    1: : sequencer
    16: [ 0- 0]: digital audio playback
    17: [ 0- 1]: digital audio playback
    24: [ 0- 0]: digital audio capture
    25: [ 0- 1]: digital audio capture
    33: : timer

    $ cat /proc/asound/cards
    0 [Intel ]: HDA-Intel - HDA Intel
    HDA Intel at 0xf3ff8000 irq 22
    Any ideas?


    gnu/linux makes me :'(

  2. #22
    Join Date
    Sep 2009
    Beans
    401
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: FFmpeg and x11grab?

    Quote Originally Posted by kung fu buntu View Post
    First of all, I had to adapt that command since it simply didn't work.
    ffmpeg didn't knew what "alsa" was :s
    > Unknown input or output format: alsa
    You need an ffmpeg binary that was compiled with ALSA support enabled. I don't know where you got yours, but Ubuntu's version of libavdevice depends on libasound so I guess that would work. Unfortunately I can't test it right now.

    Note that I'm trying to capture output audio.
    That is, I want to open a video file and capture what is played to the speakers.
    Ideally I would like to record both output and input audio streams.
    To make this work, you need either a sound card with audio loopback in hardware (most HDA cards don't have that feature) or the ALSA loopback driver (snd-aloop).

    The loopback driver basically adds another sound card to your computer which does nothing except loop all output back as input. If you select this as the default sound card, you can route audio from all applications into ffmpeg or any other recording software.

  3. #23
    Join Date
    May 2007
    Beans
    264

    Re: FFmpeg and x11grab?

    Quote Originally Posted by VertexPusher View Post
    You need an ffmpeg binary that was compiled with ALSA support enabled. I don't know where you got yours, but Ubuntu's version of libavdevice depends on libasound so I guess that would work. Unfortunately I can't test it right now.
    I found out what I was doing wrong and I can now record video.
    But I still don't get any sound recording from alsa.

    Code:
    ffmpeg -f x11grab -s 1280x1024 -r 30 -b 100k -bf 2 -g 300 -i $DISPLAY.0 -aspect 1280:1024 -sameq      -ac 2 -ar 22050 -ab 128k     -acodec libmp3lame -vcodec libxvid        MyScreencast.avi
    When I use
    Code:
    ffmpeg -f alsa -i plughw:0 -f x11grab ...
    I get the error:
    plughw:0: no such file or directory
    But I also found out that I can use -f oss -i /dev/dsp1 to capture sound from my mic (although I have ugly clicks at every second with my usb webcam mic).
    This still doesn't solve my sound problem (of recording both input and output sound streams) because I also use headphones (and no, I can't take them off -- besides the quality wouldn't be the same).

    I'm using debian with debian-multimedia packages, this is my ffmpeg:
    FFmpeg version SVN-r21450, Copyright (c) 2000-2010 Fabrice Bellard, et al.
    built on Jan 26 2010 14:51:49 with gcc 4.4.3
    configuration: --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libfaad --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libtheora --enable-libdc1394 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-avfilter-lavf --enable-libopenjpeg --enable-version3 --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
    Could you paste yours?


    Quote Originally Posted by VertexPusher View Post
    To make this work, you need either a sound card with audio loopback in hardware (most HDA cards don't have that feature) or the ALSA loopback driver (snd-aloop).

    The loopback driver basically adds another sound card to your computer which does nothing except loop all output back as input. If you select this as the default sound card, you can route audio from all applications into ffmpeg or any other recording software.
    *ahem* and how could I do this?

    Would it be possible (and easy, or at least explained in a howto) to capture the (1) video, (2) audio output, and (3) audio input to different files. And then mix them all? This way I could choose 1 audio track or both by mixing them together.

  4. #24
    Join Date
    Sep 2006
    Beans
    558

    Re: FFmpeg and x11grab?

    I haven't read all the posts here, but if all you guys want to do is capture sounds from within the computer (like from webpages or media players) when using ffmpeg x11grab, after you execute ffmpeg just go to the pulseaudio volume control, select the recording tab and you should see ffmpeg there. Then just move it's stream to the monitor of internal audio... or whatever it's called on your system.

  5. #25
    Join Date
    Sep 2006
    Beans
    558

    Re: FFmpeg and x11grab?

    I've been playing with x11grab thanks to this thread and http://ubuntuforums.org/showthread.php?t=1392026. It is by far the most superior screen grabbing method. The only limitation I've seen is that it only "detects" (for lack of better terms) the input audio as mono.

    Stream #1.0: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s

    It's simple enough to use the Pulseaudio GUI tools to route whatever audio you want to record, however it seems to make no difference to x11grab how many channels the input has. Even specifying -ac 2 only give you an output file with 2 channels, but the input still only had 1 channels. Anyone know a way to force x11grab to have 2 input channels?

  6. #26
    Join Date
    Mar 2010
    Beans
    1

    Re: FFmpeg and x11grab?

    Quote Originally Posted by kung fu buntu View Post
    I found out what I was doing wrong and I can now record video.
    But I still don't get any sound recording from alsa.
    Please run
    Code:
    sudo aptitude install libasound2-dev
    and then recompile your ffmpeg to enable ALSA support.

  7. #27
    Join Date
    Sep 2006
    Beans
    558

    Re: FFmpeg and x11grab?

    I figured out how to get ffmpeg to see dual channel audio on the input side. The proper order is:

    Code:
    ffmpeg -f alsa -ac 2 -i pulse -acodec pcm_s16le -f x11grab -r 30 -s 1280x1024 -i :0.0 -aspect 4:3 -vcodec libx264 -vpre lossless_ultrafast -threads 0 SCREENCAST.mkv
    The method above allows ffmpeg to "see" 2 audio channels on the incoming side, rather than just 1 channel. You can also specify an audio bitrate after the "-ac 2" part, if you don't it just defaults to 64 kbps.

    These techniques are useful for doing audio/video captures from webpages (for example), not necessarily for pure "screen-casting" uses.

Page 3 of 3 FirstFirst 123

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •