Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I've been experimenting with streaming via FFMpeg. I love how powerful it is! Currently I have it set up so that it streams my screen and adds an overlay for my webcam. Though, there is one thing that I'd like to be able to do that I just can't quite figure out: Throw up an on-demand splash screen.

Perhaps this would be better explained via example. Say you're streaming a game or something via Twitch for a long while. Then, you have to step away. You could

  1. Just walk away, or
  2. Throw up a "Be right back!" splash screen or something, perhaps with a little music (I've got that part figured out thanks to the awesomeness of Pulseaudio)

I figured the best way to accomplish this was via a second overlay that overlays the screen/webcam overlay.

I attempted to add a third input akin to this: ffmpeg -f v4l2 -i /dev/video0 -f xllgrab -i :0.0+738,0 -i ~/splashscreen.png -loop 1 -fliter_complex "[0:1][0:0]overlay=0:0[out];[out][2:0]overlay=0:0[final]" -f flv ~/Videos/test.flv (requires a newer version of ffmpeg than is in the Saucy repos)

And it worked, as the splash screen was transparent. I thought I'd do something clever and swap in a non-transparent image when I needed the splash screen but either ffmpeg caches the looped image or it ignores it when it suddenly can't find the file for a brief instance.

The second way I thought of was perhaps using a named pipe and using another ffmpeg instance to pipe in they overlay splash screen when I need it, but from what I've read, if ffmpeg doesn't find any data in the pipe it will not continue processing the rest of the video, instead it will only put out frames when it can pull from all the input sources.

If there are any ffmpeg gurus out there, I'd love to hear some ideas!

share|improve this question
I've already been through that article, thanks though =). The reason that won't necessarily work is because I'll be streaming fullscreen games via Twitch and due to some Wine issues, it's a little finicky at best. – Chuck R Mar 24 '14 at 20:29
Only other idea I have, excluding writing a patch to add -update functionality for the demuxer, is to simply stop the recording and then initiate a new ffmpeg command that just shows splashscreen.png. I don't know if that will work on Twitch or not since I'm not really familiar with the site. – LordNeckbeard Mar 24 '14 at 22:30
Yeah, it won't necessarily work with Twitch since it wouldn't be a graceful thing. It would kick the users off and then after a certain timeout it would load the video again, sync, rebuffer. It's just clunky. – Chuck R Mar 26 '14 at 7:46

1 Answer 1

up vote 2 down vote accepted

I have done it! Granted, it required some backflips, but none-the-less it works =D

Here is the script I used:


#NOTE: The framerate throttling can probably be removed due to the limit in
#the amount of data that can be written to a pipe before it blocks. My
#streams are at 1920x1080 and cat only puts 5 frames onto the pipe
#before it hangs waiting for a program to tread the pipe. I found this odd
#since my splash screen images were only 8k, whereas the pipe size is 1M.
#Therefore, it might be highly dependent on the resolution of your splash
#images. By removing the FPS logic of this script, a higher potential
#framerate can be achieved by the script if that's necessary.

#This is my third FFMpeg input. My other two are at framerates of
#10 (screen) and 30 (webcam). My output is 10 FPS. I had originally
#set this to 10 as well, but it caused FFMpeg to choke and start dropping
#frames for some reason, so I just added 5 since it's a common denominator
#of both 10 and 30. +2 may have also worked, but that seemed a little too
#close for me since even 11 had issues with output framerate, hovering
#around 9.9 FPS rather than the target 10 FPS.


#Tracks how many frames we've written this second
this_second=$(date +%s)

while [ 1 ]
  #Haven't written all the frames for this second
  if [ $files_this_second -lt $framerate ]
    if [ ! -f /file/to/test/to/throw/up/splash ]
      #Output the transparent "splash screen" (no splash screen)
      cat /path/to/a/transparent.png
      #Output the splash screen
      cat /path/to/a/splashscreen.png
    files_this_second=$(($files_this_second + 1))
    #The second has changed
    if [ "$(date +%s)" != "$this_second" ]
      this_second=$(date +%s)

I can then feed the output of this script into FFMpeg like so: | ffmpeg -f image2pipe -vcodec png -framerate 15 -i - (some other video source and parameters) -filter_complex "[1:0]setpts=PTS-STARTPTS[video];[0:0]setpts=PTS-STARTPTS[splashscreen];[video][splashscreen]overlay=0:0" (output format options and file)

Then, I set up a hotkey to run another simple script:


if [ -f /file/to/test/to/throw/up/splash ]
  rm /file/to/test/to/throw/up/splash
  touch /file/to/test/to/throw/up/splash

When I want to throw up the splash screen, I hit the hotkey. When I want to take it down I hit the hotkey again.

This is useful for a couple of things:

  1. A splash screen (as mentioned)
  2. Blanking the screen when entering passwords or something

It also bypasses the problem of the images getting cached like in my question above, so you'd simply have to replace the image with another to set another splash screen.

I think it's brilliant! What do you guys think?

NOTE: I am using a self-compiled version of FFMpeg because the one available in the Saucy repositories is pretty outdated. Also, the image2pipe format is undocumented that I can find.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.