I'm now trying to use gmerlin/encoder.h  but am having some trouble.

I do------------------------:

int astream, vstream;
bg_cfg_registry_t* config_reg;
bg_plugin_registry_t* plugin_reg;
char * tmp_path;
bg_cfg_section_t *     section;
gavl_video_format_t  vformat;
gavl_audio_format_t  aformat;

bg_encoder_t * encoder;


config_reg = bg_cfg_registry_create();
tmp_path =  bg_search_file_read("generic", "config.xml");
bg_cfg_registry_load(config_reg, tmp_path);

// How do I know what to load or look for here?
section = bg_cfg_registry_find_section(config_reg, "plugins");
plugin_reg = bg_plugin_registry_create(section);

// I then create the encoder but don't know why I pass it plugin_reg or
// section.  What's the deal here?  

encoder = bg_encoder_create( plugin_reg, section, NULL, 0, 0);

// open it up
if ( bg_encoder_open( encoder, "testvideo", NULL,  NULL)) {

        // I then set up my aformat and vformat 

        aformat.samples_per_frame = 256;
        aformat.samplerate = 48000;
        aformat.num_channels =2;
        aformat.sample_format = GAVL_SAMPLE_FLOAT ;
        aformat.interleave_mode= GAVL_INTERLEAVE_NONE;
        aformat.channel_locations[0] = GAVL_CHID_FRONT_LEFT;
        aformat.channel_locations[1] = GAVL_CHID_FRONT_RIGHT ;

        vformat.frame_width = 360;
        vformat.frame_height = 240;
        vformat.image_width = 360;
        vformat.image_height = 240;
        vformat.pixel_width = 1;
        vformat.pixel_height = 1;
        vformat.pixelformat = GAVL_RGB_24;
        vformat.frame_duration = 1001;
        vformat.timescale = 30000;
        vformat.framerate_mode = GAVL_FRAMERATE_CONSTANT;
        vformat.chroma_placement = GAVL_CHROMA_PLACEMENT_DEFAULT;
        vformat.interlace_mode=GAVL_INTERLACE_NONE;
        vformat.timecode_format.int_framerate=30;

        // then I add an audio stream, this seems to work 
        printf("got here\n");
        astream = bg_encoder_add_audio_stream(encoder, NULL,
                        &aformat, 0);
        printf("added astream %d\n", astream);

        // !!!!!!!!!!!!!!!!!!!!!!!!!!
        // IT CRASHES HERE BELOW.  WHY?
        vstream = bg_encoder_add_video_stream(encoder,  &vformat, 1);
        printf("added vstream %d\n", vstream);

        // Assuming I can get past this, what do I do next?
        // do I need to check the formats to see if they are the
        // same as what I passed to the encoder?

        bg_encoder_get_audio_format(encoder, astream, &checkaformat);
        bg_encoder_get_video_format(encoder, vstream, &checkvformat);

        // I assume I then start the encoder
        bg_encoder_start(encoder);

        // create frames and  set up a while loop 
        // to generate content for the audio-video frames
        // and then write them 
        //int bg_encoder_write_audio_frame(bg_encoder_t *, gavl_audio_frame_t * 
frame, int stream);
        //int bg_encoder_write_video_frame(bg_encoder_t *, gavl_video_frame_t * 
frame, int stream);

        // What am I missing?

}

// destroy what I created
bg_plugin_registry_destroy (plugin_reg);
bg_cfg_registry_destroy( config_reg );


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Gmerlin-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gmerlin-general

Reply via email to