Friday, June 19, 2015

VTK 5 and FFMPEG shenanigans on Windows

Over the years, trying to get VTK 5 to work with FFMPEG has always been tricky. Thankfully, VTK 6 has no such problems, but for those that have legacy code that use VTK 5, this is still a problem.

In this post I will cover some necessary tweaks, steps and links to getting FFMPEG IO working with your project that uses VTK 5, such as the 'Animate' plugin for sMILX and SMILI.

Firstly, I have found VTK 5.8 to be far more stable and workable than 5.10.1. In my scientific visualisation software SMILI, certain features don't work at all with the same code that runs fine on VTK 6 and 5.8.

Secondly, it seems VTK 5 has issues with Visual Studio 2013 (required to support Windows 8), but a patched version of VTK 5.10.1 available on GitHub works OK, though I had to fix a few round brackets here and here.

For version 1.2 of FFMPEG, this is what I recently did to get VTK 5.8 working with FFMPEG. The best link for FFMPEG deprecation changes are found here. Summarised, I had to fix vtkFFMPEGWriter.cxx as the following:
  1. av_set_parameters  - comment out
  3. url_fopen to avio_open and url_fclose to avio_close
  4. av_write_header to avformat_write_header, last arg to NULL
EDIT: You may also need AVCodecID, PKT_FLAG_KEY is replaced by AV_PKT_FLAG_KEY and replacing CODEC_TYPE_VIDEO with AVMEDIA_TYPE_VIDEO.
EDIT 2: I have created a GitHub VTK 5.8.0 fork with these changes applied.

EDIT 3: GCC 9.1 causes issues. It can be fixed by setting CMAKE_CXX_FLAGS as  -fpermissive -std=c++98 -DGLX_GLXEXT_LEGACY

No changes are required for VTK 6.1.0 at the time of writing.

Hope that helps
Cheers Shakes - L3mming

No comments:

Post a Comment