Reputation: 2170
I have over 20000 FLV's at the moment. They currently have no alpha channel and are all CGI generated text on a black background.
My issue: I need to be able to remove the black background and make it transparent, so I can use these videos to layer over pictures in my flash project.
It needs to be an automated process, that can go through the whole dir of videos and remove the backgrounds
What I've tried?
I have spent the last three days pulling my hair out. Currently the option I see is to write a custom filter for ffmpeg.
The end goal:
Layer the flv videos over randomly generated videos in an adobe air application built in flex.
Upvotes: 3
Views: 1757
Reputation: 6729
If you have gstreamer, here is a pipeline to do it and to view your output. This one replaces all black in video hi.mp4 with the content from the other video. Play around with the values to get what you need. Will work if your text or background (one of them) has uniform color and within a range.
gst-launch filesrc location=hi.mp4 ! decodebin2 ! ffmpegcolorspace ! alpha alpha=1 method=3 target-r=0 target-g=0 target-b=0 white-sensitivity=0 black-sensitivity=128 ! videomixer name=vm ! ffmpegcolorspace ! sdlvideosink filesrc location=hi2.mp4 ! decodebin2 ! ffmpegcolorspace ! alpha alpha=1 ! vm.
You can then replace the sdlvideo sink with an encoder x264enc and pass through your audio from one of the videos to create your container.
If you don't know what gstreamer is or aren't inclined to use it then ffmpeg with frei0r will do the trick as lordneckbeard mentioned. I just felt this is quicker. :)
How to get to this pipeline?
sudo apt-get install gstreamer-0.10 base, good bad and ugly and libav/ffmpeg plugins and gstreamer-tools packages - Look at gstreamer.net if you want to build from source.
The command line above will work and display the file. Replace sdlvideo sink with something like: x264enc bitrate= ! flvmux ! filesink location=filename.flv
If you have never used gstreamer before you will have to do a little bit of reading up on what a pipeline is and how to run one. Plenty of tutorials available. If you are not inclined to use gstreamer then perhaps the other tools pointed out in other answers will help. However I suggest you use gstreamer because then you can also do other manipulations with it if you need any in the future.
Upvotes: 1
Reputation: 1189
I just found this - including source. It's quite impressive and might be what you're looking for with just a few tweaks. I love'd playing with the live video filter.
http://blog.onthewings.net/2009/12/10/chroma-key-and-thresholding-in-flash-pixel-bender-revised/
Good luck!
Upvotes: 2