Search Unity

IL2CPP Issue when running ffmpeg from a process()

Discussion in 'Windows' started by RobRab2000, Mar 17, 2020.

  1. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    29
    Hi,

    I seem to be having a bit of a strange issue with IL2CPP. Basiclly I've been spinning up and an instance of ffmpeg from unity to render sets of pngs into videos. This has been working fine but since I updated to 2019.3, I've had issues. It works fine from the editor but when I make a windows build it doesn't work and I get this error in the player.log file:

    ffmpeg.png

    It looks like there is an issue with IL2CPP so I switched the scripting backend to Mono and now its working again.

    Is this maybe an issue with IL2CPP or is it maybe an implementation thing where it needs to be done differently?

    Here is the code I'm using to to fire up ffmpeg:

    Code (CSharp):
    1. private void PrepFfmpeg()
    2.     {
    3.         // Define the ffmpeg command based on the config file
    4.         var command = AA_Tools.GetConfigFile("ffmpeglocation", @"C:\Export\ffmpeg.exe");
    5.  
    6.         var arguments = GetFfmpegArguments();
    7.  
    8.         Debug.Log("Running command: \n" + command + "\n with parameters \n" + arguments);
    9.  
    10.         RunFfmpeg(command, arguments);
    11.     }
    12.  
    13.  
    14.     // Time the process
    15.     Stopwatch processStopwatch = new Stopwatch();
    16.     StringBuilder sb = new StringBuilder();
    17.  
    18.     private void RunFfmpeg(string command, string arguments)
    19.     {
    20.         sb = new StringBuilder();
    21.         var p = new Process();
    22.  
    23.         // Assign temporary cache
    24.         var workingDirectory = "";
    25.         p.StartInfo.WorkingDirectory = !string.IsNullOrEmpty(workingDirectory) ? workingDirectory : Application.temporaryCachePath;
    26.        
    27.         p.StartInfo = new System.Diagnostics.ProcessStartInfo();
    28.         p.StartInfo.UseShellExecute = false;
    29.         p.StartInfo.CreateNoWindow = true;
    30.         p.EnableRaisingEvents = true;
    31.        
    32.         p.Exited += new EventHandler(OnProcessExit);
    33.         p.StartInfo.FileName = @command;
    34.         p.StartInfo.Arguments = " " +  @arguments;
    35.        
    36.         // redirect the output
    37.         p.StartInfo.RedirectStandardOutput = true;
    38.         p.StartInfo.RedirectStandardError = true;
    39.        
    40.         // hookup the eventhandlers to capture the data that is received
    41.         p.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
    42.         p.ErrorDataReceived += (sender, args) => sb.AppendLine(args.Data);
    43.        
    44.         processStopwatch.Start();
    45.  
    46.         p.Start();
    47.         // start our event pumps
    48.         p.BeginOutputReadLine();
    49.         p.BeginErrorReadLine();
    50.     }
    51.  
    52.     private void OnProcessExit(object sender, EventArgs e)
    53.     {
    54.         processStopwatch.Stop();
    55.  
    56.         Debug.Log("successfully ran. time elapsed: " + processStopwatch.ElapsedMilliseconds);
    57.  
    58.         // Set the status to Successful
    59.         m_ExportSettings.currentProgress = RenderJobStatus.Success;
    60.  
    61.         Debug.Log("Ffmpeg output: \n" + sb.ToString());
    62.     }
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    IL2CPP does not have support for the C# Process class, so if you want to create a separate process, please continue to use the Mono scripting backend.
     
  3. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    29
    Ah okay cool, thanks for replying :)

    Is this something that might get added at some point?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    It is possible to add (in that there is no technical limitation blocking it), but we don't have it on our roadmap now.
     
  5. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    29
    Great, thanks for the clarity