Contenuto principale

exportVideo

Export RoadRunner scenario simulation data to video file using MATLAB

Since R2026a

    Description

    exportVideo(rrApp) exports the scenario simulation data of the specified RoadRunner Scenario application rrApp to a video file.

    example

    exportVideo(rrApp,Name=Value) sets options using one or more name-value arguments. For example, VideoResolution="SD" exports the scenario simulation data to a video file with a resolution of 640x480.

    Examples

    collapse all

    Export scenario simulation data to a video file using MATLAB®.

    Create a roadrunner object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject". This code assumes that RoadRunner is installed in the default location, and returns an object, rrApp, that provides functions for performing basic tasks such as opening, closing, and saving scenes and projects.

    rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");

    Note: If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup (RoadRunner) function to specify new default project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB sessions option from the corresponding drop down.

    Open the TrajectoryCutIn.rrscenario scenario in RoadRunner Scenario by using the openScenario function. This scenario is included by default in RoadRunner projects, and is located in the Scenarios folder of the project.

    filename = "TrajectoryCutIn.rrscenario";
    openScenario(rrApp,filename);

    Run the simulation by using the simulateScenario function, and set EnableLogging to true to enable RoadRunner Scenario to log the simulation data.

    simulateScenario(rrApp,EnableLogging=true);

    Export the simulation data by using the exportVideo function, specifying the rrApp object. Specify the folder path and the filename to which you want to export the video file using the VideoFolder and FileName name-value arguments, respectively. Once the simulation is complete, RoadRunner exports the video file to the specified export folder. You can now navigate to the export folder and locate the video file.

    exportVideo(rrApp,VideoFolder="C:\RR\MyProject\Exports",FileName="TrajectoryCutIn");

    Input Arguments

    collapse all

    RoadRunner application associated with a project, specified as a roadrunner object. This object provides functions for performing common workflow tasks such as opening, closing, and saving scenes and projects. rrApp provides functions that support importing data from files and exporting scenes to other formats from RoadRunner.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: exportVideo(rrApp,VideoResolution="SD") exports the scenario simulation data to a video file with a resolution of 640x480.

    Export folder path, specified as a character vector or string scalar. Use this argument to specify an absolute path to the folder in which to export the video file. If the specified folder path does not exist, then RoadRunner returns an error. If you do not specify a value for the VideoFolder argument, then RoadRunner exports the video to the Exports folder of the current project folder.

    Data Types: char | string

    Name of the exported video file, specified as a character vector or string scalar. RoadRunner exports the video file with the name FileName.ext, where ext is the extension corresponding to the format of the video file. RoadRunner supports only .mp4 and .avi video formats. The file format of the exported video depends on the video codec available on your system.

    If you do not specify a value for the FileName argument, the default behavior of RoadRunner depends on whether you have saved the current scenario.

    • If you have saved the current scenario, RoadRunner creates a file with the same name as the saved scenario. For example, MyScenario.ext.

    • If you have not saved the current scenario, RoadRunner creates a file with the name New Scenario. For example, New Scenario.ext.

    Data Types: char | string

    Resolution of the exported video file, specified as one of the values in this table:

    ValueResolution
    "SD"640x480
    "HD" 1280x720
    "FullHD"1920x1080
    "QuadHD"2560x1440

    Data Types: char | string

    Version History

    Introduced in R2026a