Skip to content

Generating Videos

Joy Alice Gu edited this page Apr 28, 2020 · 2 revisions

Converting frames to video with ffmpeg

Once you've rendered all the frames of your video, you can combine them into a video by using:

ffmpeg -r 60 -f image2 -s 800x600 -i ./Video_[TIME]_%4d.png -vcodec libx264 out.mp4

Where [TIME] should be replaced by the timestamp in each frame's filename (they should all be identical). If you don't have ffmpeg installed on your system, you can get it through most package managers, or you can download it directly, or use your own video creation program

Raytracing videos

Courtesy of former TA Zach Pomper in Spring 2019:

Hey guys, if you're interested in raytracing your animations, you can try adding this line to your application.cpp. Note that this feature hasn't been tested extensively, and will therefore not be going on github in the immediate future, so use at your own peril.

void Application::raytrace_video() {
  static string videoPrefix;

  if (action == Action::Raytrace_Video) {
    if (pathtracer->is_done()) {
      char num[32];
      sprintf(num, "%04d", timeline.getCurrentFrame());
      pathtracer->save_image(videoPrefix + num + string(".png"));
      timeline.step();

      if (timeline.getCurrentFrame() == timeline.getMaxFrame()) {
        timeline.action_stop();
        timeline.action_rewind();
        cout << "Done rendering video!" << endl;
        action = Action::Object;
        return;
      }
      pathtracer->stop();
      pathtracer->clear();
      set_up_pathtracer();
      pathtracer->start_raytracing();
      scene->render_splines_at(timeline.getCurrentFrame(),                       // <- Added
                               timeline.isCurrentlyPlaying(), useCapsuleRadius); // <- Added

    }
  } else {
Clone this wiki locally