0

I have a big video rush 35".

With OpenShot i've cut more than 30 small sequences and concatenate them into one 25" sequence.

Now i try to export the result as video file but OneShot randomly crash or freeze during the export/encoding between 40% and 80% so after more than an hour of encoding. It look to be a memory leek and a swap saturation with memory allocation deny because no space left.

I've tried with x264(mp4) and vp8(webm) encoding, but nothing worked.

I've opened the .osp file, it's a big json file with all the clips referred like this :

{
  clips:[
    {
      title: "<clipFileName.ext>",
      start:<seconds>.<decimals>,
      end:<seconds>.<decimals>,
      position:<seconds>.<decimals>
    }
  ]
}
  • title if not renamed is the inputFileName.
  • start clip start time from the input file beginning
  • end clip end time from the input file beginning
  • position clip start position in the output file timeline

I've read ffmpeg can extract video parts / subclip / sequences with cut function : ffmpeg -ss 00:00:09.000 -i input.mp4 -to 00:00:20 output.mp4 Time can be hh:mm:ss.xxx or hh:mm:ss or any amount of seconds, allowing decimals.

I've also read ffmpeg can concat sequences : ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" output.ts

So, how to encode my video with these project data ?

1000i100
  • 400
  • 1
  • 3
  • 13

1 Answers1

1

So i build the following script to extract all clips as video files and then concat them :

function parser(e){
  const commandList = [];
  const outputFilesName = []
  const reader = new FileReader();
  reader.onload = function(){
    const j = JSON.parse(reader.result);
    j.clips.forEach(function(c){
      const fileName = f3d(c.position) + '.ts';
      outputFilesName.push(fileName);
      let cmd = `ffmpeg -i ${c.title} -ss ${f3d(c.start)} -to ${f3d(c.end)} `;
      cmd+= `-c copy -bsf:v h264_mp4toannexb -acodec libmp3lame -ab 128k -f mpegts `;
      cmd+= fileName;
      commandList.push(cmd);
    });
    const script = `Go to your video rush folder and run the following script :
    
${commandList.join(' && ')} && ffmpeg -i "concat:${outputFilesName.join('|')}" -c copy concatenated.mp4`
    document.getElementById('commands').innerHTML = script;
  };
  reader.readAsText(e.target.files[0]);
}

document.getElementById('osp').addEventListener('change', parser, false);
function f3d(floatNumber){
  return Math.round(floatNumber*1000)/1000;
}
<input id="osp" type="file" accept=".osp"/>

<pre id="commands"></pre>
1000i100
  • 400
  • 1
  • 3
  • 13