pub fn new_with_params(path:         Path,
                           width:        usize,
                           height:       usize,
                           bit_rate:     Option<usize>,
                           time_base:    Option<(usize, usize)>,
                           gop_size:     Option<usize>,
                           max_b_frames: Option<usize>,
                           pix_fmt:      Option<i32>)
                           -> Recorder {
        unsafe {
            avformat_init.doit(|| {
                avformat::av_register_all();
            });
        }

        let bit_rate     = bit_rate.unwrap_or(400000); // FIXME
        let time_base    = time_base.unwrap_or((1, 60));
        let gop_size     = gop_size.unwrap_or(10);
        let max_b_frames = max_b_frames.unwrap_or(1);
        let pix_fmt      = pix_fmt.unwrap_or(avutil::PIX_FMT_YUV420P);
        // width and height must be a multiple of two.
        let width        = if width  % 2 == 0 { width }  else { width + 1 };
        let height       = if height % 2 == 0 { height } else { height + 1 };

        Recorder {
            initialized:      false,
            curr_frame_index: 0,
            bit_rate:         bit_rate,
            width:            width,
            height:           height,
            time_base:        time_base,
            gop_size:         gop_size,
            max_b_frames:     max_b_frames,
            pix_fmt:          pix_fmt,
            frame:            ptr::mut_null(),
            tmp_frame:        ptr::mut_null(),
            context:          ptr::mut_null(),
            scale_context:    ptr::mut_null(),
            format_context:   ptr::mut_null(),
            video_st:         ptr::mut_null(),
            path:             path,
            frame_buf:        Vec::new(),
            tmp_frame_buf:    Vec::new()
        }
    }
/// Creates a new video recorder with custom recording parameters.
///
/// # Arguments:
/// * `path`         - path to the output file.
/// * `width`        - width of the recorded video.
/// * `height`       - height of the recorded video.
/// * `bit_rate`     - the average bit rate. Default value: 400000.
/// * `time_base`    - this is the fundamental unit of time (in seconds) in terms of which
///                    frame timestamps are represented. Default value: (1, 60), i-e, 60fps.
/// * `gop_size`     - the number of pictures in a group of pictures. Default value: 10.
/// * `max_b_frames` - maximum number of B-frames between non-B-frames. Default value: 1.
/// * `pix_fmt`      - pixel format. Default value: `avutil::PIX_FMT_YUV420P`.
Creates a new video recorder with custom recording parameters.
Creates a new video recorder with custom recording parameters .
pub fn new_with_params(path:         Path,
                           width:        usize,
                           height:       usize,
                           bit_rate:     Option<usize>,
                           time_base:    Option<(usize, usize)>,
                           gop_size:     Option<usize>,
                           max_b_frames: Option<usize>,
                           pix_fmt:      Option<i32>)
                           -> Recorder {
        unsafe {
            avformat_init.doit(|| {
                avformat::av_register_all();
            });
        }
        let bit_rate     = bit_rate.unwrap_or(400000); // FIXME
        let time_base    = time_base.unwrap_or((1, 60));
        let gop_size     = gop_size.unwrap_or(10);
        let max_b_frames = max_b_frames.unwrap_or(1);
        let pix_fmt      = pix_fmt.unwrap_or(avutil::PIX_FMT_YUV420P);
        // width and height must be a multiple of two.
        let width        = if width  % 2 == 0 { width }  else { width + 1 };
        let height       = if height % 2 == 0 { height } else { height + 1 };
        Recorder {
            initialized:      false,
            curr_frame_index: 0,
            bit_rate:         bit_rate,
            width:            width,
            height:           height,
            time_base:        time_base,
            gop_size:         gop_size,
            max_b_frames:     max_b_frames,
            pix_fmt:          pix_fmt,
            frame:            ptr::mut_null(),
            tmp_frame:        ptr::mut_null(),
            context:          ptr::mut_null(),
            scale_context:    ptr::mut_null(),
            format_context:   ptr::mut_null(),
            video_st:         ptr::mut_null(),
            path:             path,
            frame_buf:        Vec::new(),
            tmp_frame_buf:    Vec::new()
        }
    }
pub fn new_with_params ( path : Path , width : usize , height : usize , bit_rate : Option < usize > , time_base : Option < ( usize , usize ) > , gop_size : Option < usize > , max_b_frames : Option < usize > , pix_fmt : Option < i32 > ) -> Recorder { unsafe { avformat_init . doit ( | | { avformat :: av_register_all ( ) ; } ) ; } let bit_rate = bit_rate . unwrap_or ( 400000 ) ; // FIXME let time_base = time_base . unwrap_or ( ( 1 , 60 ) ) ; let gop_size = gop_size . unwrap_or ( 10 ) ; let max_b_frames = max_b_frames . unwrap_or ( 1 ) ; let pix_fmt = pix_fmt . unwrap_or ( avutil :: PIX_FMT_YUV420P ) ; // width and height must be a multiple of two. let width = if width % 2 == 0 { width } else { width + 1 } ; let height = if height % 2 == 0 { height } else { height + 1 } ; Recorder { initialized : false , curr_frame_index : 0 , bit_rate : bit_rate , width : width , height : height , time_base : time_base , gop_size : gop_size , max_b_frames : max_b_frames , pix_fmt : pix_fmt , frame : ptr :: mut_null ( ) , tmp_frame : ptr :: mut_null ( ) , context : ptr :: mut_null ( ) , scale_context : ptr :: mut_null ( ) , format_context : ptr :: mut_null ( ) , video_st : ptr :: mut_null ( ) , path : path , frame_buf : Vec :: new ( ) , tmp_frame_buf : Vec :: new ( ) } }
Creates a new video recorder with custom recording parameters.
Creates a new video recorder with custom recording parameters .
path
Path
width
usize
height
usize
bit_rate
Option<usize>
time_base
Option<(usize, usize)>
gop_size
Option<usize>
max_b_frames
Option<usize>
pix_fmt
Option<i32>
path
Path
width
usize
height
usize
bit_rate
Option<usize>
time_base
Option<(usize, usize)>
gop_size
Option<usize>
max_b_frames
Option<usize>
pix_fmt
Option<i32>
arguments:
`path`         - path to the output file.
`width`        - width of the recorded video.
`height`       - height of the recorded video.
`bit_rate`     - the average bit rate.
` path ` - path to the output file . ` width ` - width of the recorded video . ` height ` - height of the recorded video . ` bit_rate ` - the average bit rate .