[vtkusers] vtkFFMPEGWriter bug?

nedc dnomdec.codes at gmail.com
Thu Jun 30 04:33:56 EDT 2011


Hi all,

First post here.  Thanks for all the good work so far!

I think I might have run into a bug in vtkFFMPEGWriter.  When the "End"
function is called, the writer frees the avStream before writing the
trailer.  In 5.4.2, this causes sporadic corruption  of the resulting avi
file due to the bad trailer.  In 5.6.1, the file can't even be written
because of a segfault.  I believe the code should be changed from

*original code (line 386 of vtkFFMPEGWriter.cxx):*
/
  if (this->avStream)
    {
    av_free(this->avStream);
    this->avStream = 0;
    }

  if (this->avFormatContext)
    {
    if (this->openedFile)
      {
      av_write_trailer(this->avFormatContext);
#ifdef VTK_FFMPEG_OLD_URL_FCLOSE
      url_fclose(&this->avFormatContext->pb);
#else
      url_fclose(this->avFormatContext->pb);
#endif
      this->openedFile = 0;
      }

    av_free(this->avFormatContext);
    this->avFormatContext = 0;
    }
/
to this *proposed code:*
/
  if (this->avFormatContext)
    {
    if (this->openedFile)
      {
      av_write_trailer(this->avFormatContext);
#ifdef VTK_FFMPEG_OLD_URL_FCLOSE
      url_fclose(&this->avFormatContext->pb);
#else
      url_fclose(this->avFormatContext->pb);
#endif
      this->openedFile = 0;
      }

    av_free(this->avFormatContext);
    this->avFormatContext = 0;
    }

  if (this->avStream)
    {
    av_free(this->avStream);
    this->avStream = 0;
    }/

Could some please correct / confirm?  Thanks a bunch!!

Best,
Ned

--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkFFMPEGWriter-bug-tp4538029p4538029.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list