Discussion:
[libav-user] Grabbing X11 Display
Ray Lopez
2009-01-13 14:56:19 UTC
Permalink
I am trying to grab the desktop display, scale it and then stream it to
another PC. I know you can do this through the command line interface and I
have done it this way successfully, but would like to write my own custom
implementation. So I proceeded with an example I found, modified it as I
understood things and this is some of what I have?


AVFormatContext *ifc;
AVCodecContext *cc;
AVInputFormat *iformat;
AVCodec *codec;

char* filename;
int i, videoStream = 0;

av_register_all();

iformat = av_find_input_format("x11grab");

if (!iformat)
{
fprintf(stderr, "Unknown input format: X11grab\n");
// return -1;
}

// Open video file
if(av_open_input_file(&ifc, filename, iformat, 0, NULL)!=0)
{
fprintf(stderr, "Couldn't open file\n");
return -1; // Couldn't open file
}


This fails because it is not a known input format. So is the format I
passing to av_find_input_format incorrect or I am not
approaching/understanding this altogether? How do I go about grabbing the
display frame?

Ray
Luca Abeni
2009-01-14 07:56:14 UTC
Permalink
Hi,

Ray Lopez wrote:
[...]
Post by Ray Lopez
av_register_all();
iformat = av_find_input_format("x11grab");
if (!iformat)
{
fprintf(stderr, "Unknown input format: X11grab\n");
// return -1;
}
// Open video file
if(av_open_input_file(&ifc, filename, iformat, 0, NULL)!=0)
{
fprintf(stderr, "Couldn't open file\n");
return -1; // Couldn't open file
}
This fails because it is not a known input format.
If av_find_input_format() is failing, I think there are two
possibilities:
1) You compiled ffmpeg without x11grab support, or
2) You forgot to call avdevice_register_all()

Also note that you should correctly set filename, otherwise
av_open_input_file() will fail.


Luca
Ray Lopez
2009-01-15 18:18:40 UTC
Permalink
The problem was with not calling avdevice_register_all(). I have since made
some headway after making this call, but have questions on some
AVFormatParameter variables. I don't have a clear understanding of
time_base, sample_rate and channels. Can someone explain or point me to
somewhere that explains these?

thanks, Ray
Post by Luca Abeni
Hi,
[...]
Post by Ray Lopez
av_register_all();
iformat = av_find_input_format("x11grab");
if (!iformat)
{
fprintf(stderr, "Unknown input format: X11grab\n");
// return -1;
}
// Open video file
if(av_open_input_file(&ifc, filename, iformat, 0, NULL)!=0)
{
fprintf(stderr, "Couldn't open file\n");
return -1; // Couldn't open file
}
This fails because it is not a known input format.
If av_find_input_format() is failing, I think there are two
1) You compiled ffmpeg without x11grab support, or
2) You forgot to call avdevice_register_all()
Also note that you should correctly set filename, otherwise
av_open_input_file() will fail.
Luca
_______________________________________________
libav-user mailing list
libav-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Michael Conrad
2009-01-15 18:42:13 UTC
Permalink
Post by Ray Lopez
The problem was with not calling avdevice_register_all(). I have since made
some headway after making this call, but have questions on some
AVFormatParameter variables. I don't have a clear understanding of
time_base, sample_rate and channels. Can someone explain or point me to
somewhere that explains these?
The Dranger tutorial covers it all. http://www.dranger.com/ffmpeg/

But the quick answer is that

* time_base is a unit of measurement for which all pts/dts values are
based on. So instead of making the pts/dts a count of microseconds, they
make it a count of time_base units. Basically they do this to eliminate
roundoff errors.
* sample_rate is the number of samples per second that should be
delivered to your soundcard
* channels is the number of independent sound channels, such as
"left,right" (2), or "frontleft,frontright,backleft,backright,center,sub"
(6)
--
Michael Conrad
IntelliTree Solutions llc.
513-552-6362
mconrad at intellitree.com
Continue reading on narkive:
Loading...