Menu

Segfault on Encoding

user
2005-03-07
2013-05-09
  • Nobody/Anonymous

    Hello,

    first: thanks for that great fobs library, it helped me a lot adding video decoding to my applications!

    But I have a problem encoding a video. Since there is no sample application for encoding in C++ I did the following:

    ----------- snip -------------

    #include "Encoder.h"
    #include <iostream>
    #include <unistd.h>

    using namespace omnividea::fobs;
    using namespace std;

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

      int w = 768;
      int h = 576;

      char* data = (char*) malloc(w * h * 3 * sizeof(char) );

      Encoder e("test.avi");
     
      ReturnCode code;
     
      code = e.chooseFormat("avi");
      if(isError(code)) {
        cout << "Error : " << code<< endl;
        exit(-1);
      }

      code = e.setVideoParameters(w, h, 800.0, 25.00, "mpeg4");
      if(isError(code)) {
        cout << "Error : " << code<< endl;
        exit(-1);
      }

      code = e.open();
      if(isError(code)) {
        cout << "Error : " << code<< endl;
        exit(-1);
      }

      cout << "Video info: Width=" << e.getWidth() << " Height=" << e.getHeight() << " BitRate=" << e.getBitRate() << " FrameRate="<< e.getFrameRate() << endl;

      for(int i = 0; i < 10; i++) {
        cout << "loop " << i << endl;
        code = e.addFrame(data, w, h);
        if(isError(code)) {
          cout << "Error : " << code<< endl;
          exit(-1);
        }
      }

      e.close();

      return 0;

    }

    ------------ snip --------------------

    The programm crashes in loop 2:

    Output #0, avi, to 'test.avi':
      Stream #0.0: Video: mpeg4, 768x576, 25.00 fps, q=2-31, 800 kb/s
    [mpeg4 @ 0x82d16dc]removing common factors from framerate
    Video info: Width=768 Height=576 BitRate=800 FrameRate=25
    loop 0
    loop 1
    [mpeg4 @ 0x82d16dc]Error, Invalid timestamp=0, last=0
    Segmentation fault

    If someone could please tell me what I do wrong that would help me a lot.

    I am using fobs 0.3pre2 from source with included ffmpeg on Suse Linux 9.2.

    Thanks,

    Andreas.

     
    • Jose San Pedro

      Jose San Pedro - 2005-03-07

      Hi,

      due to heavy demand of Fobs4jmf functinality I have kind of forgot about the original C++ part of the project ;) Yes, there seem to be issues with encoding and they are most likely due to changes in the encoding process in the latest versions of ffmpeg. I'll try to have a look at it but don't expect to see anything new before next week (really busy right now). I hope the wait won't be too long. I will post any news to the forum and publish the code via CVS.

      Cheers!

      Jose San Pedro

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.