[FFmpeg-devel] New filter: remap (usecase is fisheye video)
fsluiter at gmail.com
Tue Apr 5 01:40:56 CEST 2016
I wrote a new filter for ffmpeg and would value your comments. Files
attached are not proper git or diff patches, but the filter itself is only
a single file.
My usecase was to create a filter that would allow me to process video shot
with a 180 fisheye lens, but this filter is very generic and can also be
used in many other usecases.
I included two examples:
- a simple 180 degree rotation
- a fisheye to equirectangular remap (or projection)
Other use cases can be:
It basically is a matter of creating the right xy_mapfiles for your usecase.
See readme for commands to generate the examples.
* Pixel remap filter
* This filter copies pixel by pixel a source frame to a target frame.
* It remaps the pixels to a new x,y destination based on two files
* Map files are passed as a parameter and are in PGM format (P2 or P5),
* where the values are y(rows)/x(cols) coordinates of the source_frame.
* The *target* frame dimension is based on mapfile dimensions: specified
* header of the mapfile and reflected in the number of datavalues.
* Dimensions of ymap and xmap must be equal. Datavalues zero or higher as
* are used as coordinates. Any datavalue in the ymap or xmap which value
* then the *source* frame height or width is silently ignored, leaving a
* blank/chromakey pixel. This can safely be used as a feature to create
* Algorithm digest:
* Target_frame[y][x] = Source_frame[ ymap[y][x] ][ [xmap[y][x] ];
Obvious points to improve:
- test and add other video formats, I did not have the knowledge on all of
- I was struggling a bit with C (I used to code in C++ long time ago) and
pixelformats, so the function I adapted contains some ugly code for 8bit
character reads and 16bit read for binary PGM files. Not proud of it, would
welcome improvements greatly.
Possible additions for version 2.0:
- Anti aliasing, remapping can cause lots of jagged edges.
- possibility to read a sequence of ymap/xmap files. For this most
convenient would be to read those files as inputs to ffmpeg, and not as a
parameter to the fillter. This could create a possibility for usecases to
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 175493 bytes
Desc: not available
More information about the ffmpeg-devel