Monday, Dec 20, 2004

Integrating new features to visual plasma.

Visual Plasma v0.4

snapshot:



New feature
  • Video matting

  • Editing video volume/alpha

  • Adding titles

  • Editing title duration/alpha

  • Preview clip/result

  • Results
    - snapshot:



    - demo video: result.avi

    Saturday, Dec 18, 2004

    Developing title feature.

    Visual Plasma

    Interface
  • To add a title, user can select a animation effect from the title tab (currently only still text was implemented)

  • User can edit (text, position, scale) the title in the edit panel just like MS Powerpiont

  • User can modify the alpha (transparentcy) and duration by draging sliders.

  • snapshot:



    Implementation
  • Title object data structure
    - :
    - :

  • Draw a editable text in the edit panel
    - :
    - :

  • Bindings for resize and move is similar to video clip's
    - resize:
    - move:

  • Database update is similar as before

  • Problem
  • During input text, the text can not automaticly warp to newline when the text reach the bound of box.

  • Since scale tast is perform by zinc command, the text became ugly after scaling.



  • Thursday, Dec 16, 2004

    Developing crop feature

    Visual Plasma

    Crop Window

    When user select a video in the edit panel, it will also appear in the crop window. Usr can draw a box on the preview picture, and the part outside the box will be crop off. Then the edit panel will display the new croped video clip but the picture in crop window will remain the same (full) so that user can draw new crop box

    snapshot:



    Implementation
  • Initail Zinc
    - prop_panel_init will create a black zinc.
    - Button-1, B1-Motion bindings allow to draw box on zinc

  • Update dabtabase
    - db_update_crop will update database after user draw a box
    - it will call edit_panel_crop to produce a cropped image and update edit panel.

  • Cropping image
    - edit_panel_crop will read the PPM file byte by byte and only write the pixel byte which is inside crop box to the output file.
    - Source code:
        set f [open $filename r]
        set fout [open "tmp_crop_$img_id.ppm" w]
        
        set c ""
        set hdr "" 
        
        while { $c != "\n" } {
     	set c [read $f 1]
     	set hdr "$hdr$c"
        }
        set hdr_list [split $hdr]
        set 3w [expr 3 * [lindex $hdr_list 1]]
        set h [lindex $hdr_list 2]
        set 3x1 [expr 3 * $x1]
        set 3x2 [expr 3 * $x2]
    
        set w2 [expr $x2 - $x1]
        set h2 [expr $y2 - $y1]
        fconfigure $f -translation binary -buffersize 65536
        fconfigure $fout -translation binary -buffersize 65536
        
        puts -nonewline $fout "P6 $w2 $h2 255\n"
        
        for {set i 0} {$i < $h} {incr i} {
          	for {set j 0} {$j < $3w} {incr j} {
     	    if {$i >= $y1 && $i < $y2 && $j >= $3x1 && $j < $3x2} {
    		puts -nonewline $fout [read $f 1]
    	    } else {
    		seek $f 1 current
    	    }
    	    
    	}
        }
        
        close $f
        close $fout
    

  • Problem
  • Crop method is a very slow, it will cost around 1 second to produce one image file.

  • The reason should be it was written in Tcl.I have try to use Dalí library to perform this task, however, I haven't find the right way. The following code is my attempt, it create a mask and copy bytes to the output.
    - source code:
    crop.tcl
    - result:
    Very fast, less than 0.1 second to produce same result, it works fine if the crop point is {0 0 X X}, but works anomally when left-top corner point is not (0, 0). For example:





  • Tuesday, Dec 14, 2004



    TkZinc: Zinc Is Not Canvas!

    TkZinc is a powerful widget for Tcl/Tk, Perl/Tk and Python/Tkinter. It is very similar to Tk canvas in that they support structured graphics. Like the canvas, TkZinc implements items used to display graphical entities. Those items can be manipulated and bindings can be associated with them to implement interaction behaviors. But unlike the canvas, TkZinc can structure the items in a hierarchy, has support for scaling and rotation, clipping can be set for sub-trees of the item hierarchy, supports muti-contour curves.

    snapshot:



    Feature
  • Items
    - arc, curve, group, icon, map, rectangle, reticle, tabular, text, window ...
    - support more options: aplpha, linestyle, linepattern, fillpattern

  • Transformations
    - rotate, scale, skew, transform ...

  • openGL
    - color gradient
    - antialiasing
    - transparency

  • Editable Text
    need the text input support (zincText.tcl), it apply to those sensitive text item with tag "text". example:
    package require Tkzinc
    package require zincText
    zinc .z
    pack .z
    
    # Activate text input support from zincText
    zn_TextBings .z
    
    .z add add text 1 -position {50 230} -text \
    {this text is editable} -sensitive 1 -tags text
    



  • Monday, Dec 13, 2004

    Embedding new version of plamsa to visual plasma.

    Visual Plasma v0.3

    Change log
  • When user click a image in canvas, it will be put into the forground.
    - $canvas raise $img_id

  • The cursor will change when user enter a image or box
    - $canvas configure -cursor top_left_corner

  • User can put image in any position
    - a new varible called layer number is stored in clip object. When user move or resize an image, its layer number will update to be the max_layer_number + 1.
    - when making movie, a new algorithm will parse the position database, and generate plasma command.
    step 1: sort database as before;
    step 2: find width and height of result video, and create the background layer with a black JPG image;
    step 3: sort the database with the layer number;
    step 4: for each clip in the database, create a new video obejct , and modify its scale and position:
    set i 0
    foreach item $list {
        media .m.id$i [lindex $item 5]
        mpack .m.id$i
        set item_w [expr [lindex $item 3] - [lindex $item 1]]
        set item_h [expr [lindex $item 4] - [lindex $item 2]]
        set item_x [expr [lindex $item 1] - [lindex $list 0 1]]
        set item_y [expr [lindex $item 2] - [lindex $list 0 2]]
        .m.id$i scale $item_w $item_h
        .m.id$i pos $item_x $item_y
        incr i
    }
    - result:



  • Problems
  • The new encoder seems slower than before, and it cannot stop

  • Since the old packing algorithm has been discard, need a new method for auto-alignment



  • Friday, Dec 10, 2004

    Vee Jay Online



    VJOnline is digital audio/video stream mixer. User can multiplex a few A/V stream into one and broadcast over internet via RTSP(Real Time Streaming Protocol). It supports serveral transition effects when user switch the main channel and picture-in-picture effect. User can also add in text maquees and other text effects such as blinking.

    Feature
  • Transition effect
    during playing, user can switch channel with transition effect. - swich_channel will mute the old channel, create and pack the new channel
    - fade_in, pop_in, slide_in and curtain_in is procdure used to make spectial effects. They are implemented using keyframe alpha/scale/crop motion tween. remove_old_channel will remove all the sub layers.

  • Picture-in-Picture effect
    add_layer will add a new layer(176X120) to the old channel, user can specify the anchor point.

  • Text rendering
    - top/bottom maquee effects are implemented using keyframe pos motion tween.
    - blink effect use alpha motion tween.

  • Source
    - source code: vj.tcl
    - demo video: vj.avi


    Thursday, Dec 09, 2004

    Zhu Tao release new version of Plasma!

    Plasma Beta v3.0

    This version is released as a dynamic loadable module (tclplasma.so) for Tcl 8.4.8. instead of a executable file as before. Some syntax changed, and some new functions were added. Zhu Tao also implemante a simple Tk application called VeeJay Online, which can make some interesting effects such as trasition, PiP, and title.

    Change Log
  • New syntax
    - create a video or audio object:
    media $object_name $file_name(path | url | dev)
    - output A/V:
    mplay/mout $object_anme $destionations //dev=playback
    - for pack(mpack), when parent is not empty, -side whole is no need.
    - event, what is key?:
    mevent $object_name [-timer $num_of_frames] [-key $key]
    - keyframes can be used to make animation:
    mkeyframe $object_name [-motiontween] $frame_number
    - apply the effect?: mset $object_name
    - new option for media:
    mute, grayscale, volume, pos $x $y, alpha $a, crop $x1 $y1 $x2 $y2, script{$s}, text "" $x &y

  • New features
    - support format Mpeg2,4, AVI, WMV, MP3, JPG
    - achive PiP using layer concept, user can specify the position of foreground layer and one image can over other images.

    example:



    - titles can be added as a layer, user can give width and height of one charactor and modify the position. Here is a example:
    media .m ./susie.mpv
    media .m.t text "Hello World!" 40 30
    mpack .m.t
    .m.t pos 0 0
    mout .m test.avi
    Note that user need to set environment variable PLASMA_FONT_FILE to a ttf font file
    - A/V streams motion tween (alpha, size and position tweening, volume fading). Example:
    media .m susie.mpv
    media .m.t1 cactus.mpv
    mpack .m.t1
    
    .m.t1 scale 120 90
    .m.t1 pos 10 10
    .m.t1 alpha 0
    mkeyframe .m.t1.kf -motiontween 50
    .m.t1.kf alpha 100
    
    mset .m.t1.kf
    mout .m test.mpg

  • Problems
  • How to concatenate videos
    when packing a child object to parent, if parent is a container, it will be packed side-by-side, else, if the parent is a video, the child will be packed as a new layer witch produce picture-in-picture effect.

  • How to continue encoding
    when one layer reach its end, the encoder will stop its work, which make the duration to be the shorter than expected.

  • How to terminate encoding process
    after finish encoding, the program get stuck, do not konw how to terminate in other way than Ctrl+C :(

  • How to use event
    the syntax has changed, waiting for Zhu Tao's documentation.



  • Wednesday, Dec 08, 2004

    Convert interm progress report to tex format.

    LaTeX - A document preparation system

    LaTeX is a high-quality typesetting system, with features designed for the production of technical and scientific documentation. LaTeX is the de facto standard for the communication and publication of scientific documents. Here is a good tutorial website Getting to grips with Latex

    Commands
  • Document Structure
    - \part{part}
    - \chapter{chapter}
    - \section{section}
    - \subsection{subsection}
    - \subsubsection{subsubsection}
    - \paragraph{paragraph}
    - \subparagraph{subparagraph}

  • Importing Images
    - support JPEG and PNG formats
    - need to put \usepackage{graphicx} in the header
    - options: [width=x, height=x, scale=x, trim l b r t, clip]
    - usage: \includegraphics[options]{x.jpg}

  • Floats, Figures and Captions
    - need to put \usepackage{float} in the header
    - float example:
    \usepackage{float}
    
    \floatstyle{ruled}
    \newfloat{program}{thp}{lop}
    \floatname{program}{Program}
    
    \begin{document}
    
    \begin{program}
      \begin{verbatim}
    
    class HelloWorld {
      public static void main(String[] args) {
        System.out.println("Hello World!");
      }
    }
    \end{verbatim}
      \caption{The Hello World! program in Java.}
    \end{program}
    
    - cross-refrence: \ref{xxx} and \label{xxx}
    - figure example:
    \begin{figure}
      \begin{center}
        \reflectbox{\includegraphics{tucan.eps}}
      \end{center}
      \caption{A picture of the same tucan looking the other way!}
      \label{toucan}
    \end{figure}

  • Formatting
    - Dalí : Dal\'{i}
    - bold : \textbf{xxx}
    - footnote : \footnote{xxx}

  • Interim Progress Report
  • LaTex source
    - directory: www.comp.nus.edu.sg/~liubing/UROP/code/latex/

  • Compiled with socreport class
    pdf(1.0M)


  • Problem
    do not know how to add url in the bibliography.
    url="www.apple.com" can not be handled by socreport.bst, so use the misc instead:
    @misc{imovie,
      author = "Apple",
      title = "i{M}ovie, http://www.apple.com",
      year = 2004
    };
    
    However, it makes the reference page looks ugly :(



  • Tuesday, Dec 07, 2004

    Meeting Notes

  • Need to add new functions
    - add titles: new version of plasma has this feature, ask zhutao how to use and CVS the new one
    - overlay: should check Tk menu again about how to put image on the foreground in canvas
    - powerpoint is a good example, check it out

  • Temporal editing
    - timeline is hard to use, storyboard can be considerd
    - should also think about other visalazation to allow easy-to-use temporal editing

  • Final report
    - start to write report now
    - should write in LaTex format
    - LaTex class can be download here



  •