video - 将 .osp OpenShot 项目导出到 ffmpeg 脚本,作为通过交换 hell 解决视频导出卡住或崩溃的方法

标签 video ffmpeg concat cut

我有一个 35 英寸的大视频。

使用 OpenShot,我已经剪切了 30 多个小序列并将它们连接成一个 25"序列。

现在我尝试将结果导出为视频文件,但 OneShot 在 40% 和 80% 之间的导出/编码过程中随机崩溃或卡住,因此经过一个多小时的编码。它看起来是内存泄漏和内存分配拒绝的交换饱和,因为没有剩余空间。

我尝试过使用 x264(mp4) 和 vp8(webm) 编码,但没有任何效果。

我已经打开了 .osp 文件,它是一个很大的 json 文件,所有的剪辑都是这样引用的:

{
  clips:[
    {
      title: "<clipFileName.ext>",
      start:<seconds>.<decimals>,
      end:<seconds>.<decimals>,
      position:<seconds>.<decimals>
    }
  ]
}
  • title如果未重命名,则为 inputFileName。
  • start从输入文件开始的剪辑开始时间
  • end从输入文件开始的剪辑结束时间
  • position输出文件时间线中的剪辑开始位置

  • 我已阅读 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 时间可以hh:mm:ss.xxxhh:mm:ss或任何数量的seconds , 允许小数。

    我也读过ffmpeg can concat sequences : ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" output.ts
    那么,如何使用这些项目数据对我的视频进行编码?

    最佳答案

    因此,我构建了以下脚本以将所有剪辑提取为视频文件,然后将它们连接起来:

    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>

    关于video - 将 .osp OpenShot 项目导出到 ffmpeg 脚本,作为通过交换 hell 解决视频导出卡住或崩溃的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52077003/

    相关文章:

    Android:如何从 Assets 中播放视频?

    iPhone "cannot play".mp4 H.264 视频文件

    filter - 是否可以通过 -f concat 将 3 个视频与 ffmpeg 合并并在没有视频内容的情况下交叉淡入淡出

    python - 使用 Pandas [with key column] 将 CSV 与不同的列组合

    JavaScript:如何将 x 添加到数组 x 次?

    swift - 字符串(数据 : data, 编码:NSUTF8StringEncoding)返回 nil

    android - BufferQueue 已被放弃 : When playing video with TextureView

    batch-file - ffmpeg concat + 处理时发现无效数据 + 检查有效 avi 文件

    encoding - 使用 ffmpeg 进行多比特率编码

    android - 为什么在为 Android 编译 FFmpeg 时得到 "error: invalid instruction mnemonic"?