Video export via FFMpeg

Post Reply
User avatar
NightRadio
Site Admin
Posts: 3008
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Video export via FFMpeg

Post by NightRadio » Tue Sep 06, 2011 8:25 pm

Only for Linux/OSX with FFMpeg installed.
Simple example of using the FFMpeg for Pixilang video export.

Работает только в Linux/OSX с установленным FFMpeg.
Простой пример, показывающий, как можно перенаправить видео-поток из Pixilang в FFMpeg. В итоге получаем файл /tmp/out.mpg

Code: Select all

VIDEO_XSIZE = 320
VIDEO_YSIZE = 240

fn VIDEO_THREAD()
{
    //system( "ffmpeg -pix_fmt rgba -s 320x240 -f rawvideo -i /tmp/ffmpeg_vpipe /tmp/out.mpg" )
    system( "ffmpeg -pix_fmt rgb32 -s 320x240 -f rawvideo -i /tmp/ffmpeg_vpipe /tmp/out.mpg" )
}

fn VIDEO_INIT()
{
    resize( get_screen(), VIDEO_XSIZE, VIDEO_YSIZE )
    system( "mkfifo /tmp/ffmpeg_vpipe" )
    thread_create( VIDEO_THREAD, 0 )
}

fn VIDEO_CLOSE()
{
    system( "rm /tmp/ffmpeg_vpipe" )
    if vpipe_f
    {
        fclose( vpipe_f )
    }
}

fn PUT_FRAME()
{
    if vpipe_f == 0 { vpipe_f = fopen( "/tmp/ffmpeg_vpipe", "wb" ) }
    if vpipe_f
    {
        scr = get_screen()
        fwrite( scr, get_size( scr ) * get_esize( scr ), vpipe_f )
    }
}

VIDEO_INIT()

clear()
fbox( -8, -1000, 2, 2000 )

scr = get_screen()
xsize = get_xsize( scr )
ysize = get_ysize( scr )
size = get_size( scr )

start:

i = 0 while( i < size )
{
    p = scr[ i ]
    pp = 0
    pp + scr[ i - 1 ] != BLACK
    pp + scr[ i + 1 ] != BLACK
    pp + scr[ i - xsize - 1 ] != BLACK
    pp + scr[ i - xsize - 0 ] != BLACK
    pp + scr[ i - xsize + 1 ] != BLACK
    pp + scr[ i + xsize - 1 ] != BLACK
    pp + scr[ i + xsize - 0 ] != BLACK
    pp + scr[ i + xsize + 1 ] != BLACK
    if p == BLACK && pp == 3 { scr[ i ] = WHITE }
    if p == WHITE && ( pp < 2 || pp > 3 ) { scr[ i ] = BLACK }
    i + 1
}

while( get_event() )
{
    if EVT[ EVT_TYPE ] == EVT_QUIT
    {
        VIDEO_CLOSE()
        halt
    }
}

PUT_FRAME()
frame()

go start

Post Reply