首页 \ 问答 \ 如果有多个通道,则合并,然后从音频文件中获取采样长度并将其保存到s3(If multiple channels, merge then take sample length from audio file and save it to s3)

如果有多个通道,则合并,然后从音频文件中获取采样长度并将其保存到s3(If multiple channels, merge then take sample length from audio file and save it to s3)

我正在使用transloadit从视频文件中提取音频,然后将其保存到S3。 这很好,但我想知道如何:

  1. 检查文件是否有多个频道,然后挤压一个按照https://transloadit.com/demos/audio-encoding/merging-multiple-audio-streams/ - 我需要检查这个或做我默认为使用这个机器人?

  2. 从音频文件中提取一个小样本 - 并将其另存为一个单独的文件。

例如,我有一个2h的音频文件,我想从中获取5%的长度并将其保存为sample.mp3

在ffmpeg中,我可以剪切:

ffmpeg -ss 0 -t 30 -i original.mp3 sample.mp3

但我不确定如何链接这个工作流程,这是我到目前为止:

const opts = {
  params: {
    notify_url: `${ process.env.SELF }/services/trans/${ jwToken }`,
    steps:      {
      import: {
        robot:  '/s3/import',
        use:    ':original',
        bucket: process.env.S3_INGEST,
        path:   ingest.key,
        key:    process.env.AWS_ID,
        secret: process.env.AWS_SECRET,
      },
      encode: {
        robot:        '/audio/encode',
        use:          'import',
        ffmpeg_stack: 'v2.2.3',
        preset:       'aac',
        ffmpeg:       {
          ab:  '128k',
        },
      },
      export: {
        robot:   '/s3/store',
        use:     'encode',
        bucket:  s3Export,
        path:    `${ prefix }/${ token }.m4a`,
        headers: {
          'Content-Type': 'audio/mp4',
          'x-amz-server-side-encryption': 'AES256',
        },
        key:    process.env.AWS_ID,
        secret: process.env.AWS_SECRET,
      },
    },
  },
};

在文档中, https://transloadit.com/docs/conversion-robots/我看不到如何做到这一点?

任何意见是非常感谢。


I am using transloadit to extract the audio from a video file, which is then saved to S3. This works great, but I wanted to know how to:

  1. check if the file has multiple channels and then squash it inot one as per https://transloadit.com/demos/audio-encoding/merging-multiple-audio-streams/ - do I need to check for this or do i default to use this robot?

  2. extract a small sample from the audio file - and save this as a separate file.

For example, I have a 2h audio file from which I want to take 5% of the length and save this as sample.mp3

In ffmpeg, i can cut:

ffmpeg -ss 0 -t 30 -i original.mp3 sample.mp3

but I am unsure how to chain this workflow, here is what i have thus far:

const opts = {
  params: {
    notify_url: `${ process.env.SELF }/services/trans/${ jwToken }`,
    steps:      {
      import: {
        robot:  '/s3/import',
        use:    ':original',
        bucket: process.env.S3_INGEST,
        path:   ingest.key,
        key:    process.env.AWS_ID,
        secret: process.env.AWS_SECRET,
      },
      encode: {
        robot:        '/audio/encode',
        use:          'import',
        ffmpeg_stack: 'v2.2.3',
        preset:       'aac',
        ffmpeg:       {
          ab:  '128k',
        },
      },
      export: {
        robot:   '/s3/store',
        use:     'encode',
        bucket:  s3Export,
        path:    `${ prefix }/${ token }.m4a`,
        headers: {
          'Content-Type': 'audio/mp4',
          'x-amz-server-side-encryption': 'AES256',
        },
        key:    process.env.AWS_ID,
        secret: process.env.AWS_SECRET,
      },
    },
  },
};

in the docs, https://transloadit.com/docs/conversion-robots/ i can't see how to do this?

any advice is much appreciated.


原文:https://stackoverflow.com/questions/43006931
更新时间:2023-09-11 18:09

最满意答案

您必须使用jquery将事件绑定到动态创建的元素。

$('.message').on('click', '#start', function(){

其中.message是你的#start元素#start元素。


You have to use the jquery on to bind events to dynamically created elements.

$('.message').on('click', '#start', function(){

Where .message is the elelment your #start element is in.

相关问答

更多
  • 这是一个很好的测试,只是为了看看jQuery是否正常工作: // Show menu $("a.showMenu").click(function () { alert('I am here'); // <--- if (menuStatus != true) { $(".ui-page-active").animate({ marginLeft: "165px", }, 300, function () { m ...
  • 使用计时器 var clicked = false; setInterval(function(){ clicked = false; },5000); if($('.button').click(function(){ if(!clicked){ do job; clicked = true; } }); use a timer var clicked = false; setInterval(function(){ clicked = ...
  • 你选择了一个错误的框架。 将它从Mootools更改为jQuery 。 将代码包装在ready函数中也是一种很好的做法。 $(function(){ $('div#target').click(function() { alert('div has been clicked'); }); }); ​ 工作样本http://jsfiddle.net/qgz2j/4/ You chose a wrong framework. Change i ...
  • $('#calendar').datepicker({ inline: true, firstDay: 1, showOtherMonths: true, dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], onSelect: function(date) { alert(date); }, });