As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label x11grabr. Show all posts

Last year, my patch got into FFmpeg repository, just now, after FFmpeg 0.12.2 marked as stable after 0.7.8, I saw my contribution (from FFmpeg manpage):

Unfortunately, I didn't carry on after I created x11grabr. The issue I has still remained and I didn't try to resolve it very hard. Since then nothing was done, it was sort of ceased of development. When I started x11grabr, I wished I could make it like XSplit on Linux. Despite issues, my computer couldn't handle much encoding let along I don't really have anything interesting for live broadcasting.

If you are interested, please send me an email, maybe we can team up.

I was cleaning up the subscription videos and recommendations on YouTube. After I finished I noticed I got a new comment on this video, so I checked my reader and immediately notice the $.

This is the second time I received money and the first time I didn't ask for it. It just came unexpectedly.

To be honesty, I don't consider x11grabr is at the stage for donation and I personally don't think putting a donation button will really get me some extra money. I did recall once someone asked how can send me some money for something I wrote, but I gratefully turned down the offer.

I feel no shame to admit most of my code is actually at garbage grade as in term of WINE, therefore I don't really want to receive donation. I would feel bad for it. Who doesn't like money, I do also, but I just don't feel right to receive the money.

Since the money is already in my account, I guess there is some button to return the money but I won't do it, that is another reason I won't do it. If this generous gentleman asks me for my Paypal email first, I would thank him and ask him for comments/suggestions instead of sending me money. (I am guessing my email isn't so secret after all.)

As of x11grabr, it has been almost two weeks no pushes to GitHub and actually not much on my computer. I did try to fix the A/V out-of-sync issue by using ffmpeg/libav as library, so x11grabr can output a container with time code, that should be able to fix it.

However, I didn't have much progress, I can generate a Matroska (MKV) with still a rawvideo (bgra pix format) from XImage's data, but the video just doesn't get right. There is something I don't use correctly. Unfortunately, I don't know what it is and to tell the truth, I don't exactly understand how to use ffmpeg/libav to generate a media file correctly.

I believe I have actually thought about to pause the development until... well, I am not sure. The project has been watched by three people and now the money. I feel I would need to continue one way or another.

I have asked at #libav on IRC and that's how I knew I should generate a media file. I could just ask again, but I don't really like using IRC.

A couple days ago, I wanted to post on ArchLinux's forums as a community contribution project announcement as well as a help wanted thread (I don't use Arch anymore, but Arch does have the best community in my opinion), but didn't do it.

Anyway, I would need to clean up my current working copy, so if I still can't figure out on my own, then I can ask for help with cleaner code.

Right now, I don't have any mood to do anything.

(If you already know how to resolve the A/V out-of-sync issue as well as generate media file using ffmpeg/libav, or you just want to join the project even you are learning like me, please shoot me an email or message me on GitHub)

I have been broadcasting my desktop for a couple of days, mainly because I would need to test my x11grabr. I recalled more than a year ago, I would need to set up things in order to get streaming out. ( You might be seeing a new box showing up at the end of this box, which would be telling you click on the play button! )


Note was shut down on August 5, 2014.

On you can grab the stream key in channel info page1, scroll down for Stream Key.

I am not going to bore you, so here is the script I am currently using:

# 2011-09-06T06:45:42Z



/path/to/x11grabr/x11grabr -s "$VIDEO_SIZE" -r "$FPS" -bnone |
ffmpeg -f rawvideo -pix_fmt bgra -s "$VIDEO_SIZE" -r "$FPS" -i - \
       -f alsa -ac 1 -ar 11025 -i pulse \
       -vcodec libx264 -vpre baseline \
       -acodec libmp3lame -ab 32k \
       -threads 0 \
       -f flv "$STREAM_URL"
       #-f alsa -ac 2 -ar 22050 -i pulse \
       #-acodec pcm_s16le \
       #-acodec libmp3lame -ab 64k \
       #-acodec aac -strict experimental -ab 64k \
       #-acodec aac -strict experimental \

I use 630x352 because it gives me pixel-to-pixel when viewing on I broadcast my desktop, so I dont like the image to be re-scaled. Also, you might want to use built-in x11grab in ffmpeg. So you may need to launch ffmpeg like (untested):

ffmpeg -f x11grab -pix_fmt bgra -s "$VIDEO_SIZE" -r "$FPS" -i :0.0 \
       # the rest of stuff

Note that I have submitted two patches, once they get released you would have better control.

1.1   IRC Chat webchat is pretty buggy, at least it doesnt like me much. I have seen message being eaten up, I thought why the other person kept talking to self. Another issue was funny, I had to turn off (uncheck) in order to show timestamp. But it seems fixed, right now.

If you use irssi, here is the simple configuration I have added:

servers = (
    address = "";
    chatnet = "jtvme";
    port = "6667";
    password = "<YOUR JTV PASSWORD>";
    use_ssl = "no";
    ssl_verify = "no";

chatnets = {
  jtvme = { type = "IRC"; };

channels = (
  { name = "#livibetter"; chatnet = "jtvme"; autojoin = "yes"; },

When I start broadcasting, I fire up irssi and issue /connect jtvme to connect to my own IRC channel.

If you dont have IRC client, currently stable Firefox allows you to open IRC via third-party website, its ehh, I forgot the name. Anyway, it has no problem to connect to JTVs IRC server. It took me sometime to Google correct information and pieced them up into my configuration.

1.2   Music

Streaming with music is always some vague issues. I love watching StarCraft II [SCII] channels and I have seen some complaints over some channels before, but right now it seems fine because those top-page popular channels play music via GrooveShark or YouTube. I dont know if its somewhat ignored by JTV. I dont believe those labels would let JTV off the hook.

At first, I didnt even have audio stream sent to JTV. I found its boring, so I started to play those music I downloaded from Jamendo before. I still didnt give them proper attribution, though I have put a recently played on channel page.

[SCII]Nope, I dont play, I just watch. I use Linux.

2   Ustream

As for Ustream, you need to download the FME XML file, search for <stream>, the string inside is your STREAM_KEY.


# Go Live -> Start Broadcasting


# flashver part is important
STREAM_URL="rtmp://$STREAM_KEY flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"

/path/to/x11grabr/x11grabr -s "$VIDEO_SIZE" -r "$FPS" -bnone |
ffmpeg -f rawvideo -pix_fmt bgra -s "$VIDEO_SIZE" -r "$FPS" -i - \
       -f alsa -ac 2 -ar 22050 -i pulse \
       -vcodec libx264 -vpre baseline \
       -acodec libmp3lame -ab 48k \
       -f flv "$STREAM_URL"
       # can use flv as well
       # -vcodec flv \
       #-b 1000 -vframes 500 \
       # -threads 0 \
       #-f alsa -ac 2 -ar 22050 -i pulse \
       # -acodec pcm_s16le \
       #-acodec libmp3lame -ab 32k \
       #-acodec libmp3lame -ab 64k \
       #-acodec aac -strict experimental -ab 64k \
       #-acodec aac -strict experimental -ab 32k \
       #-acodec aac -strict experimental \

3   Notes

I dont like broadcasting on Ustream, because it requires you to click on Start Broadcasting on the website and you need to keep the Flash on. Which we Linux users all know, Flash has not-so-good performance. If you know how to bypass it, please leave a comment. However, it has nice beginner controls of your stream, I think you can put on overlay text by using it.

And be careful for your stream key, ffmpeg might print out that URL, which would include your key. I think your can lower your log level, but I dont want to do that, read ffmpeg(1) if you need to.

[1] is gone, because is gone.

A quick update on x11grabr. Now the mouse click has been rendered in different shape and colors. Everything is still fixed in code.

Another not quite related thing about x11grabr is I am currently using it to stream and it works normally. However, I know it would have problem if audio stream is included. I am 99.999% sure it will be out of sync. Right now, I dont have audio streamed.

I still dont know how I should deal with this. I might ask on mailing list later. One resolution is to grab audio in x11grabr, but I will need to learn container and also how to combine video and audio.

This is just a quick announcement about what I am currently doing. I started a new project last week, x11grabr, X11 video GRABbeR. Its a fork of x11grab of libav/ffmpeg.

It can do what x11grab does and a little more as you can see in the screencast about. It has issues, but they wont be fixed anytime soon.

I list some tasks, go check up and give me some feedback and thoughts.

Its not ready for production use yet.