Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7216 in orxonox.OLD for branches/std/src/world_entities/recorder.cc


Ignore:
Timestamp:
Mar 12, 2006, 8:54:30 AM (19 years ago)
Author:
bensch
Message:

orxonox/std:: compile and run again, with many more std::strings….

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/world_entities/recorder.cc

    r7193 r7216  
    5454
    5555  LoadParam(root, "duration", this, Recorder, setStreamDuration);
     56
    5657  LoadParam(root, "fps", this, Recorder, setFPS);
     58
    5759  LoadParam(root, "name", this, Recorder, initVideo);
    5860}
     
    7173
    7274
    73 void Recorder::initVideo(const char* filename)
     75void Recorder::initVideo(const std::string& filename)
    7476{
    7577  frame_count = 0;
     
    7880
    7981  // auto detect the output format from the name, default is mpeg
    80   output_format = guess_format(NULL, filename, NULL);
     82  output_format = guess_format(NULL, filename.c_str(), NULL);
    8183  if (!output_format)
    8284  {
     
    9395
    9496  format_context->oformat = output_format;
    95   snprintf(format_context->filename, sizeof(format_context->filename), "%s", filename);
     97  snprintf(format_context->filename, sizeof(format_context->filename), "%s", filename.c_str());
    9698
    9799  // add video stream using the default format codec and initialize the codec
     
    104106
    105107  // print some information
    106   dump_format(format_context, 0, filename, 1);
     108  dump_format(format_context, 0, filename.c_str(), 1);
    107109
    108110  // now that all the parameters are set, we can open the
     
    110112  if(video_stream)
    111113    this->openVideo();
    112  
     114
    113115  // open the output file, if needed
    114116  if(!(output_format->flags & AVFMT_NOFILE))
    115117  {
    116     if(url_fopen(&format_context->pb, filename, URL_WRONLY) < 0)
    117       PRINTF(1)("Could not open %s\n", filename);
     118    if(url_fopen(&format_context->pb, filename.c_str(), URL_WRONLY) < 0)
     119      PRINTF(1)("Could not open %s\n", filename.c_str());
    118120  }
    119121
    120122  // write the stream header, if any
    121   av_write_header(format_context); 
     123  av_write_header(format_context);
    122124}
    123125
     
    129131  av_free(buffer);
    130132
    131   // write the trailer, if any 
     133  // write the trailer, if any
    132134  av_write_trailer(format_context);
    133  
     135
    134136  // free the streams
    135137  for(int i = 0; i < format_context->nb_streams; i++)
     
    175177
    176178void Recorder::allocPicture()
    177 { 
     179{
    178180  picture = avcodec_alloc_frame();
    179181  if(!picture)
     
    189191      return;
    190192  }
    191   avpicture_fill((AVPicture *)picture, picture_buf, 
     193  avpicture_fill((AVPicture *)picture, picture_buf,
    192194                  codec_context->pix_fmt, width, height);
    193195
     
    211213  if (!video_stream)
    212214    PRINTF(1)("Could not alloc stream\n");
    213  
     215
    214216  codec_context = video_stream->codec;
    215217  codec_context->codec_id = output_format->video_codec;
     
    219221  codec_context->bit_rate = 400000;
    220222  // resolution must be a multiple of two
    221   codec_context->width = State::getResX(); 
     223  codec_context->width = State::getResX();
    222224  codec_context->height = State::getResY();
    223225
     
    229231  // timebase should be 1/framerate and timestamp increments should be
    230232  // identically 1
    231   codec_context->time_base.den = (int)stream_frame_rate; 
     233  codec_context->time_base.den = (int)stream_frame_rate;
    232234  codec_context->time_base.num = 1;
    233235  codec_context->gop_size = 12;  // emit one intra frame every twelve frames at most
     
    235237
    236238  if (codec_context->codec_id == CODEC_ID_MPEG1VIDEO)
    237       // needed to avoid using macroblocks in which some coeffs overflow 
    238       // this doesnt happen with normal video, it just happens here as the 
     239      // needed to avoid using macroblocks in which some coeffs overflow
     240      // this doesnt happen with normal video, it just happens here as the
    239241      // motion of the chroma plane doesnt match the luma plane
    240242      codec_context->mb_decision=2;
     
    275277{
    276278  int out_size, err;
    277  
     279
    278280  codec_context = video_stream->codec;
    279  
     281
    280282  if(frame_count >= stream_nb_frames)
    281283  {
     
    287289    this->fillYuvImage();
    288290
    289  
     291
    290292  if(format_context->oformat->flags & AVFMT_RAWPICTURE)
    291293  {
     
    293295    // futur for that
    294296    av_init_packet(&packet);
    295    
     297
    296298    packet.flags |= PKT_FLAG_KEY;
    297299    packet.stream_index= video_stream->index;
    298300    packet.data= (uint8_t *)picture;
    299301    packet.size= sizeof(AVPicture);
    300    
     302
    301303    err = av_write_frame(format_context, &packet);
    302304  }
     
    309311    {
    310312      av_init_packet(&packet);
    311      
     313
    312314      packet.pts= av_rescale_q(codec_context->coded_frame->pts, codec_context->time_base, video_stream->time_base);
    313315      if(codec_context->coded_frame->key_frame)
     
    316318      packet.data= buffer;
    317319      packet.size= out_size;
    318      
     320
    319321      // write the compressed frame in the media file
    320322      err = av_write_frame(format_context, &packet);
Note: See TracChangeset for help on using the changeset viewer.