[MPlayer-dev-eng] Structure of Mencoder, want to record to new file based on serial-trigg

Martin Osmundsvåg mosmunds at broadpark.no
Tue Jun 17 19:27:24 CEST 2003


Hi!
I'm not sure if I should adress this question to this forum, but I hope 
it's allright :)
 
I'm would like to make a serial trigger for mencoder so it will record 
as long the DCD is low. The problem with mencoder is the time used for 
initialization. Therefore I looked at the code and found the main loop. 
I did the initializaion part and polled the serial port. When the port 
was trigged I jumped into the main loop -- mencoder started recording 
immediately.

The problem is that I want to start over again without quiting the 
program. The problem is that I can't start at the main() again. Then 
I'll get messages that it's unable to open /dev/video0: Device or 
resource busy. I have the following mencoder.c structure taken from it's 
rev 1.2.15:


void mencoder_exit(int level, char *how){
}

void parse_cfgfiles( m_config_t* conf ){
}

static int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
}

static int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
}

static void exit_sighandler(int x){
}

int main(int argc,char* argv[]){

  // declarations

  /* Test for cpu capabilities (and corresponding OS support) for 
optimizing */
  // check codec.conf
  // FIXME: get rid of -dvd and other tricky options
  // New config code
  // check font
  // :
  vo_init_osd();
 
  stream=open_stream(filename,0,&file_format);
 
  if(!stream){
    printf(MSGTR_CannotOpenFile_Device);
    mencoder_exit(1,NULL);
  }
  // :
  // set up video encoder:
  // set up output file:
  // ============= VIDEO ===============
  /* force output fourcc to .. */
  // ============= AUDIO ===============
  // setup filter:
  // :
  printf(MSGTR_WritingAVIHeader);
  muxer_write_header(muxer);
 
  decoded_frameno=0;
  // :
  signal(SIGINT,exit_sighandler);  // Interrupt from keyboard
  signal(SIGQUIT,exit_sighandler); // Quit from keyboard
  signal(SIGTERM,exit_sighandler); // kill
 
  timer_start=GetTimerMS();
  // :

  //---INCLUDED IN FILE--------------
  // Wait until trigged
  while(trigged){
    // wait a bit and poll again
  }
  // We are trigged, initialise timer, and start recording
  timer_start=GetTimerMS();
  //---END INCLUDED IN FILE-------------
 
 
  while(!at_eof){
   
    //---INCLUDED IN FILE--------------
    // Continue operation as long as you are trigged
    if(!trigged){
      at_eof=1;
      interrupted=1;
    }
    //---END INCLUDED IN FILE-------------

    if(sh_audio){
      // :
    }
    // get video frame!
    // :
    ptimer_start = GetTimerMS();
    // :
    videosamples++;
    videorate+=(GetTimerMS() - ptimer_start);
    // :
   
  } // while(!at_eof)
  // :
  if(sh_video){ uninit_video(sh_video);sh_video=NULL; }
  if(demuxer) free_demuxer(demuxer);
  if(stream) free_stream(stream); // kill cache thread

  //---INCLUDED IN FILE--------------
  // I'm finished with grabbing the stream, I want to get ready for the 
next one
  // What to do? Where do I start? It must be before the while(!at_eof) 
loop, but where?
  // What do I have to clean up, and initialize to be ready for another go?
  // I must open a new file, but use the same input source (V4L) and 
parameters.
  //---END INCLUDED IN FILE-------------

  return interrupted;
}

static int parse_end_at(struct config *conf, const char* param){
}

static uint8_t* flip_upside_down(uint8_t* dst, const uint8_t* src, int 
width,
                                 int height){
}

static int  lame_presets_set( lame_t gfp, int fast, int cbr, const char* 
preset_name ){
}

static void  lame_presets_longinfo_dm ( FILE* msgfp ){
}



What need to be cleaned after the while(!at_eof)-loop to be able to 
start over again?  My Idea is to make mencoder record each stream into 
separate files.

Any suggestions?

Thanks in advance

- Martin O.




More information about the MPlayer-dev-eng mailing list