[MPlayer-dev-eng] Video mixer with mencoder

Ötvös Attila oattila at chello.hu
Mon Dec 10 00:39:48 CET 2007


Hi All!

I began development video mixer with mencoder. (This is 'draft' version!)

At moment implemented and new function are:
-------------------------------------------------------------
* -video-mixer <video mixer config file>
* Add shared memory reader/writer (from my CCTV)
* 'Silly' video sync (only frame to frame)
* Add shmemin, shmemout video filter
* cmdfile to shmemin filter
* 'Silly' video effect with shmemin (alpha, move, scale) 

Not implemented/ know bugs:
--------------------------------------
* Mixing audio channels
* Normal sync between videos
* More video effect filter
* Only work YV12 video format
* Set eof handler to insert video (close output file and exit if eof insert 
video)

I main modify:
------------------
* I move video encoder code from main() to main_loop() in mencoder.c
* Parse video mixer configure file if use -video-mixer options of mencoder
* I add skip_line() to config-parser
* The mencoder create 1-1 pthread to insert videos
* Use shmem:// output stream if insert video process
* I create silly mixer/demuxer to shmem
* I modified my stream_sharedmem.c (add sync read/write)
* I modified my vf_shmemin.c video filter to insert video frames 
(add 'dynamic' filter)

Sample use mencoder:
------------------------------
mencoder a.avi -ovc lavc -oac mp3lame -o sample.avi -video-mixer vmixer.conf

vmixer.conf:
----------------
# 'base' and output stream parameters:
#Insert video filter:
#shmmein.conf : command file to video effect
vf=shmemin=1:0:0:0:160:120::shmemin1.conf
vf=shmemin=2:0:160:0:160:120::shmemin2.conf

#Start insert videos section
#required parameters: inputid, input-file
inputid=1
input-file=b.avi
#Other options (see mencoder.conf):
nosound=yes

inputid=2
input-file=c.avi
vf=scale=160:200

shmemin.conf:
-------------------
#spts,epts,on,sa,sx,sy,sw,sh,sz,ea,ex,ey,ew,eh,ez
# spts : start pts (float)
# epts : end pts (float)
# on   : on/off (int)
# sa   : start alpha (int)
# sx   : start x (int)
# sy   : start y (int)
# sw   : start width (int)
# sh   : start height (int)
# sz   : start zoom (float)
# ea   : end alpha (int)*
# ex   : end x (int)
# ey   : end y (int)
# ew   : end width (int)
# eh   : end height (int)
# ez   : end zoom (float)

1.00,10.00,1,0,,,,,,255
10.00,15.00,,,,,,,,,160
15.00,20.00,,,,,,,,,,120
20.00,25.00,,,,,,,,,0,0,320,240
25.00,30.00,,,,,,,,,320,,0,
30.00,35.00,,0,0,0,320,240,,255
35.00,40.00,,,,,,,,,160,120,0,0

The shmemin video filter modify x,y,width,height and alpha from spts/epts, eg:
sx=0, ex=160
spts=10.00, epts=20.00
current pts=15.00 of output video

rate=(pts-spts)/(epts-spts);
x=(ex-sx)*rate+sx;

pts=10.00 -> x=0
pts=12.50 -> x=40
pts=15.00 -> x=80
pts=17.50 -> x=120
pts=20.00 -> x=160

The vmixer.diff, some sample files and sample video:

http://onebithq.com/root/mplayer/videomixer

This is 'draft' version! Please don't see white space, indent, align, etc. :).

Comment, proposal, plan or other?


PS:
My shmem patchs:
http://archives.free.net.ph/message/20070911.224159.eed63f99.en.html
http://archives.free.net.ph/message/20070911.224206.01675470.en.html

Best regards!

Attila



More information about the MPlayer-dev-eng mailing list