LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2011, 10:38 AM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Rep: Reputation: 48
how to use ffmpeg x11 grab inside windows


i am using windows xp .
i like ffmpeg especially its desktop recording in mpeg format without any loss of information .
Code:
ffmpeg -f x11grab -i :0.0 /tmp/out.mpg
I think X server does not run in xp .
Is there a work around to use ffmpeg for desktop recording in xp ?
I didn't like camstudio etc.
 
Old 12-09-2011, 10:41 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Just curious, but why are you posting this in a linux sub-forum? If this is about windows, then it needs to be at least moved, if not asked on a different forum. I'm not really sure if ffmpeg is the same on windows.
 
Old 12-09-2011, 11:15 AM   #3
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
Actually ffmpeg binaries are available for windows & they transcode as well .
ffmpeg is open source .
So , I thought there must be some expert who has done it .
 
Old 12-09-2011, 11:21 AM   #4
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
By the way , I read http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=3&t=27
Then got http://ffmpeg.zeranoe.com/builds/sou...1a73d6.tar.bz2

Code:
E:\software\media\ffmpeg-git-8475ec1-win32-static\ffmpeg-git-8475ec1-win32-static\bin>ffmpeg.exe -list_devices true -f dshow -i dummy
ffmpeg version N-34318-g8475ec1, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 31 2011 17:50:05 with gcc 4.6.1
  configuration: --enable-gpl --enable-version3 --enable-runtime-cpudetect --ena
ble-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --ena
ble-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --en
able-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib

  libavutil    51. 22. 0 / 51. 22. 0
  libavcodec   53. 26. 0 / 53. 26. 0
  libavformat  53. 18. 0 / 53. 18. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 45. 3 /  2. 45. 3
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[dshow @ 003F94C0] DirectShow video devices
[dshow @ 003F94C0] Could not enumerate video devices.
[dshow @ 003F94C0] DirectShow audio devices
[dshow @ 003F94C0]  "VIA HD Audio Input"
dummy: Immediate exit requested
Also I got http://download0.videohelp.com/downl...t10-090724.zip & ran graphedt.exe . There is no sub-option in graph > insert filters > video capture sources .
 
Old 12-09-2011, 11:22 AM   #5
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
I know that

But as far as what you are trying to do, x11grab will not work in windows, since windows does not run an X server......
 
Old 12-10-2011, 06:26 AM   #6
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
Finally I am able to record desktop in windows using ffmpeg with clarity unbelievable.

I got Screen Capturer Recorder v0.3.6 from http://sourceforge.net/projects/scre...6.exe/download
Here is readme.txt at https://github.com/rdp/screen-captur...o-windows-free
Code:
This program allows one to "record" your desktop, or even stream it, with the help of VLC.

It also includes some helper "record your screen capture" and setup utilities.
  In order to use those you'll want/need the java JRE installed on your system first.

It also includes a free, general purpose, open source directshow desktop/screen source capture filter.
You can use this with any (directshow compatible) program to capture or stream, like VLC.

It also includes a directshow source capture filter device for recording "what you hear" in windows 7/vista.
  see https://github.com/rdp/virtual-audio-capture-grabber-device
  and some utilities for it.

== Installation ==

Download installer and run, from 

  https://sourceforge.net/projects/screencapturer/files
    (sorry it's on sourceforge: github limits their disk usage space and I'm hitting up against the limit)

 NB that you may need need to install the MSVC 2010 runtime distro first, if it's not already
 installed on your machine (typically, it already is).
 http://www.microsoft.com/download/en/details.aspx?id=5555

== Usage ==

Use some helper programs provided in 
 Start menu -> Programs -> Screen Capture Recorder -> XXX

Or use any 3rd party program that can read from a Directshow Capture Device (ex: VLC).

VLC example: http://betterlogic.com/roger/2010/07/how-to-use-vlc-as-a-free-open-source-alternative-to-playon-tv

ffmpeg example (requires ffmpeg 32 bit -- 64 bit is available upon request):

  $ ffplay -f dshow -i video="screen-capture-recorder"

or

  $ ffmpeg -f dshow  -i video="screen-capture-recorder"  -r 20 -t 10 screen-capture.mp4 # -t 10 for 10 seconds recording

or combine it with recording "what you hear" audio [vista/windows 7] (using ffmpeg in this example):

  $ ffplay -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder" # this example gives feedback be careful...
  
The audio device name can be other dshow audio devices, as well.

Avisynth also works with it.  Add it to a filter graph using graphedit, then use DirectShowSource as your 
input source with that graphedit filename specified.

gstreamer works, as well:

  $ gst-launch.exe dshowvideosrc device-name=screen-capture-recorder ! ffmpegcolorspace ! directdrawsink

I've even had Skype accidentally use it, thinking it was my webcam.
Let me know if you want an easier way made for it for anything.

== Configuration ==

By default, it captures the "full screen" of the main desktop monitor (all windows, overlapping, there).

To configure it differently, run the provided "configuration setup utilities" or 
adjust registry settings before starting a run (advanced users only):

HKEY_CURRENT_USER\Software\os_screen_capture
with DWORD keys respected of:
  start_x, start_y, width, height, fps
  # monitor_number, hwnd_to_use, show_mouse   # unimplemented, but can be created if there is any request for them:
  
ex: see incoming.reg (though NB that those values are in hex, so editing that file is a bit tedious).  

If any value registry value is set to 0, that means "not set" so it uses the default for that value.

== Trouble shooting/Feedback/Questions ==

it's too slow!
  Run the "benchmark your capture speed" utility to see how slow it is.
  A few things that can help: if you're on vista+
    turn off aero display manager (esp. if you have dual monitors, this can help).
    http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/
  disabling or enabling "hardware acceleration" for the desktop might help, too.
  try switching from 32 to 16 bit.  It's a tidge faster to capture (90fps compared to 80fps on my box)
  It captures much more quickly if aero is turned off (as 
  in with aero, capturing a 650x976 window takes 50ms, without aero, 
  3ms).  The rest of a single screenshot capture takes about 7ms (sum 
  10ms without aero), so you can see the relative cost it adds [!]
  If you have dual core, then theoretically capturing with aero on will 
  just cause the capture thread to probably eat "an entire core" if you are trying to capture at 
  20 fps or higher.  So it may be worth it, if you have the extra cpu, to not care.

Note that if your output is, say, going to be 10 fps "used" in the end.
Ex: ffmpeg -f dshow -i video=video-capture-recorder yo.mp4 -r 10 # output file is only 10 fps

Then to save cpu, the "good" directshow applications have their own "source fps" parameter,
that they pass on to this filter.
ex: vlc.exe dshow:// ... :dshow-fps=1.5
vlc then passes this in to SetFormat after negotiation, and the device accepts it.

Some "bad" directshow applications don't pass this in.
So there may be a case where it is wasting cpu somehow, by capturing too many or the like.
So for those programs, you'll want to set the force_max_fps parameter, which will limit its
capture frequency.  It may be the only way to pull in some rogue applications (ffmpeg <cough>).

Setting force_max_fps to greater than 30 also allows you to get fps greater than 30.  It "enables" them,
by giving it a higher max default.  I didn't think people would normally care/want them so there you have.

Other feedback/problems/questions ping me rogerdpack@gmail.com or mailing list: http://groups.google.com/group/roger-projects

==  Redistribution ==

You can use this/redistribute it with your own software if you wish by just redistributing the DLL 
(PushDesktop.ax) alongside with your app (see installer_just_device.iss).
You'd have to register it manually (regsvr32 PushDesktop.ax, may need administrator rights) as part of your install.
Also note that end users also need the MSVC 2010 redistributable previously installed (or you have to make it available 
in the same dir as your exe) for the dll to work/install, in case end users don't have it installed, in that case).
Or you may be able to recompile it to work around that, etc.

== Code/Future work/Attributions ==

The code is gently lifted from ("inspired by")
  ....\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\filters\pushsource as well as some other dshow demos around.
  so you'll probably want to install the Windows SDK before messing around with the source code.

I can add features upon reasonable demand.

Basically you want a feature, ping me, you got it.

To build it locally, install VS Express 2010, install Microsoft SDK, open up your equivalent of 
\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses\baseclasses.sln
build it (debug)
now add to your local build (project properties, from the source_code\pushdesktop.sln) adjust the VC++ Directories (Include/Library) 
to point to your baseclasses.

== Attributions ==

the included speed test utility was originally from http://stereopsis.com/blttest
(bitblt is quite hardware dependent, or so I'm told).

FFMpeg also included, see their site for licensing details/source: ffmpeg.org


---------- Post added 12-10-11 at 04:57 PM ----------

I am trying to record a part of desktop now.
 
Old 12-10-2011, 06:37 AM   #7
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
audio is not recorded though.
Actually
Code:
"c:\Program Files\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe" -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder"  -s 352x288 -r 20 -t 20 mobile-resolution-screen-capture.mp4
told

[dshow @ 003F96C0] Could not find audio device.
audio=virtual-audio-capturer:video=screen-capture-recorder: Input/output error

Last edited by sumeet inani; 12-10-2011 at 06:42 AM.
 
Old 12-10-2011, 06:49 AM   #8
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
You have to install https://github.com/downloads/rdp/vir...e%20v0.2.2.exe (for windows 7 , vista)

Here is readme.txt at https://github.com/rdp/virtual-audio...vice/downloads
Code:
This is an audio capture device allowing you to capture all the "wave out sound" that is playing on your speakers 
(i.e. record what you hear) for Windows 7/Vista.  Windows XP users please read the "history" section
for something else you can try in its place.

NB THAT IT IS USED WITHIN THE MORE FULL FEATURED https://github.com/rdp/screen-capture-recorder-to-video-windows-free

== Installation ==

To use, download+install here: https://github.com/rdp/virtual-audio-capture-grabber-device/downloads
then use it via its included "record for x seconds" utility, or
via any other program that can take directshow devices as an input.

  If you want other options for its use, like broadcasting, or saving from it or any specific audio device input (ex: waveout with Windows XP)
  then download this utility: https://github.com/rdp/screen-capture-recorder-to-video-windows-free
  which has has more options and a different/better UI for broadcast/recording.

 NB that you may need need to install the MSVC 2010 runtime distro first, if it's not already
  installed on your machine (typically, it already is).
  http://www.microsoft.com/download/en/details.aspx?id=5555

== Usage ==

Example: VLC media player: media [menu] -> open capture device -> select capture audio device "virtual-audio-capturer"

Example: ffmpeg (to save audio to file yo.mp3 from what is currently playing, requires 32 bit ffmpeg, 64 bit DLL available upon demand):
$ ffmpeg  -f dshow -i audio="virtual-audio-capturer" yo.mp3

(also see https://github.com/rdp/screen-capture-recorder-program if you want to stream your desktop with audio
as well or capture it or the like)

NB that you'll need java JRE installed to use the bundled utility apps.

History/XP users:

Basically, with windows XP, you can typically already "record what you hear"
Run sndvol32 (Start menu -> Accessories -> Volume/Audio), choose options [menu] -> properties -> recording radio button, click ok, 
now click the "select" checkbox underneath "Wave Out Mix"

Now with for example VLC choose "Open Capture Device" -> Audio Device Name -> select "your soundcard's name" (other
programs just select your soundcard's name).

With Windows Vista/7, for some reason many sound card drivers do not include this as an option.
Some do though. You can check if yours already does by following instructions here:
http://downloadsquad.switched.com/2007/01/15/how-to-enable-wave-out-recording-in-vista
You may want to download and install new audio drivers first before looking for it, sometimes that helps.

If you're in Vista/Windows 7 and see a "Wave Out Mix" following the above instructions
then you're good to go: enable it, and you can use it (you thus don't need virtual-audio-capture-grabber-device at
all).

If you don't see it then you're in luck this, device is for you.
Windows Vista/7 offer a new interface called a "loopback" adapter that captures the outgoing audio just
as it is sent to your speakers [1].

This little utility captures the loopback audio and offers it to you as an input device
that you can then record (it's captured as a directshow audio capture device, if that means anything to you).
VLC can use this to record, for example.  There are some example apps included with this package.

Basically I programmed this as an open source (free) competitor to virtual audio cable.
Ping me if you want me to convert it into a "real" kernel level audio device so that any program can use it,
not just directshow compatible ones.
Ping me if you want an easier "start/stop" recorder, too.


Another option is "If your sound card doesn't have the option to record what you hear, 
use a cable (with 3.5mm headphone jacks on both ends) to connect the line out of your 
sound card to the line in (using a splitter if you need to be able to hear what you're doing, 
and disabling mic boost if you use a microphone input)."

But that's hardware and this is a software answer :)



==Troubleshooting/feedback ==

If you use it in VLC you'll need a directshow cache of at least 40ms, for whatever reason.
Also note that it's tuned set to work best for recording "what you hear" 
if this doesn't work for you then ping me I maybe could add a more "realtime" option or 
something.
Basically any feedback welcome, if it doesn't work.
Also note that if you turn down your system volume within windows, it will still continue recording
or playing, as apparently it captures it at "normal volume" regardless of how high your speaker output is.
Any feedback welcome, including feature requests like "support more audio channels than 2".

If you want a smaller download you can just download the file source_code\Release\audio_sniffer.ax then run regsvr32 audio_sniffer.ax as an admin user.

rogerdpack@gmail.com or mailing list http://groups.google.com/group/roger-projects

== attribution ==

Some source code originally from the windows SDK samples, some taken from [1]
So you'll probably need to install the Windows SDK before playing around with the source code, legally.

Also you may find this project, a directshow screen capture device, similarly useful:
https://github.com/rdp/on-screen-capture-recorder-to-video-windows-free

Enjoy!

[1] http://blogs.msdn.com/b/matthew_van_eerde/archive/2008/12/16/sample-wasapi-loopback-capture-record-what-you-hear.aspx
In my case of XP
Code:
I saw "VIA HD Audio Input" in start>programs>accessories>entertainment>volume control
Go to options>properties>
See mixer device for recording.


Full desktop recording (audio+video) succeeds using
Code:
"c:\Program Files\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe" -f dshow -i audio="VIA HD Audio Input":video="screen-capture-recorder"  -s 352x288 -r 20 -t 20 mobile-resolution-screen-capture.mp4
[/color]

Last edited by sumeet inani; 12-10-2011 at 07:51 AM.
 
Old 12-10-2011, 07:13 AM   #9
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
question remains about recording portion of desktop
 
Old 12-10-2011, 08:43 PM   #10
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
I am overjoyed to report that grabbing a portion of desktop just needs registry entry creation.
Quote:
== Configuration ==

By default, it captures the "full screen" of the main desktop monitor (all windows, overlapping, there).

To configure it differently, run the provided "configuration setup utilities" or
adjust registry settings before starting a run (advanced users only):

HKEY_CURRENT_USER\Software\os_screen_capture
with DWORD keys respected of:
start_x, start_y, width, height, fps
# monitor_number, hwnd_to_use, show_mouse # unimplemented, but can be created if there is any request for them:

ex: see incoming.reg (though NB that those values are in hex, so editing that file is a bit tedious).

If any value registry value is set to 0, that means "not set" so it uses the default for that value.
I did bother software developer 'rogerdpack' for that.

Now this thread is solved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ffmpeg.SlackBuild: line 194: cd: /tmp/SBo/package-ffmpeg/usr/man: No such file or dir darkstarbyte Linux - Software 7 12-29-2010 06:45 PM
Help me in installing ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encod mitesh.ever Red Hat 5 05-16-2009 01:14 PM
ffmpeg: Could not find video grab device drhind Linux - Desktop 0 01-15-2007 07:13 PM
Gtk and Glade: How to put windows inside windows enemorales Programming 1 07-13-2006 11:01 AM


All times are GMT -5. The time now is 07:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration