【问题标题】:Keep timecode in ffmpeg?在ffmpeg中保留时间码?
【发布时间】:2013-08-15 13:10:32
【问题描述】:

我正在运行一个脚本,该脚本可以制作 422 个代理以在 ffmpeg 中进行编辑,但文件上的时间码似乎丢失或无效。

我使用的参数:

ffmpeg -i file.mov -vcodec prores -profile:v 0 -an file.mov

有没有办法保存原始文件中的时间码?

我也来过 ffmbc,它似乎更适合这个,但它只适用于 linux。有什么方法可以为 osx 编译?

我在 osx 10.8.4

提前致谢!

【问题讨论】:

    标签: macos compilation ffmpeg timecodes


    【解决方案1】:

    来自手册页: http://ffmpeg.org/ffmpeg.html

    ‘-copyts’
    Do not process input timestamps, but keep their values without trying to sanitize them. In particular, do not remove the initial start time offset value.
    
    Note that, depending on the ‘vsync’ option or on specific muxer processing (e.g. in case the format option ‘avoid_negative_ts’ is enabled) the output timestamps may mismatch with the input timestamps even when this option is selected.
    
    ‘-copytb mode’
    Specify how to set the encoder timebase when stream copying. mode is an integer numeric value, and can assume one of the following values:
    
    ‘1’
    Use the demuxer timebase.
    
    The time base is copied to the output encoder from the corresponding input demuxer. This is sometimes required to avoid non monotonically increasing timestamps when copying video streams with variable frame rate.
    
    ‘0’
    Use the decoder timebase.
    
    The time base is copied to the output encoder from the corresponding input decoder.
    
    ‘-1’
    Try to make the choice automatically, in order to generate a sane output.
    
    Default value is -1.
    

    【讨论】:

    • 由于参数的顺序在 ffmpeg 命令中确实很重要,我很想看看 copyts 的示例用法。因为我无法让它工作。我收到Output file is empty, nothing was encoded 错误。
    【解决方案2】:

    ffmpeg 的最新版本默认保留时间码。我刚刚测试过:

    ffmpeg -i A152C001_131008UZ.MXF -an -vcodec prores -profile:v 0 testtc.mov
    ffmpeg version 2.0.1-tessus Copyright (c) 2000-2013 the FFmpeg developers
      built on Aug 10 2013 21:25:56 with llvm-gcc 4.2.1 (LLVM build 2336.1.00)
      configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --enable-runtime-cpudetect
      libavutil      52. 38.100 / 52. 38.100
      libavcodec     55. 18.102 / 55. 18.102
      libavformat    55. 12.100 / 55. 12.100
      libavdevice    55.  3.100 / 55.  3.100
      libavfilter     3. 79.101 /  3. 79.101
      libswscale      2.  3.100 /  2.  3.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  3.100 / 52.  3.100
    ...
    Input #0, mxf, from 'A152C001_131008UZ.MXF':
      Metadata:
    ...
        timecode        : 18:56:52:22
    ...
    Output #0, mov, to 'testtc.mov':
      Metadata:
    ...
        timecode        : 18:56:52:22
    ...
    

    生成的 Quicktime 确实有正确的时间码(如 QT7 所示)。

    我从http://www.evermeet.cx/ffmpeg/ 获得了我的 Mac OS X ffmpeg 二进制文件

    ffmbc 可通过homebrew (brew install ffmbc) 用于 Mac OS X。但是,默认情况下它不保留时间码。您需要使用-timecode hh:mm:ss:ff 选项指定它。

    如果你安装了 homebrew,你也可以使用它来安装 ffmpeg。

    【讨论】:

      【解决方案3】:

      时间码通常以特定于文件格式的格式出现,因此不能指望 ffmpeg 在没有明确说明的情况下直接“复制”它。

      有时它被添加为文件的全局元数据,有时它专门添加到视频流中,有时它可能作为元数据添加到一个单独的“数据”流中。

      您需要找到原始时间码所在的流。

      您可以通过运行来确定这一点

      ffmpeg -i INPUT
      

      示例输出(摘录):

      ffmpeg version...
      ...
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inputfile.mp4':
        Metadata:
      ...
        Stream #0:0(und): Video: h264...
      ...
        Stream #0:2(und): Data: none (rtmd / 0x646D7472), 2252 kb/s (default)
          Metadata:
            creation_time   : 2021-06-19T16:39:17.000000Z
            handler_name    : Timed Metadata Media Handler
            timecode        : 07:15:07:17
      
      

      这将显示有关所有输入流的信息,包括元数据。然后记下包含时间码的流编号,在此示例中为输入 0 的流 2,并使用 -map_metadata 将其映射到全局元数据。

      例如,这会将索引为 2 (s:2) 的流的元数据从第一个输入 (0:) 映射到文件的全局(默认)元数据,并将音频-视频流复制到输出:

      ffmpeg -i INPUT -map_metadata 0:s:2 -c copy OUTPUT
      

      请注意,“s”的编号和含义与其他更常见的选项不同。在ffmpeg documentation 中查看更多信息。

      ffmpeg 然后从该流中读取它所理解的任何内容(主要包括时间码),将其转换为目标文件格式的指定元数据格式,并将其包含在输出中。

      生成的文件将具有可在 DaVinci Resolve 或 Premiere Pro 等编辑软件中识别的时间码。

      【讨论】:

        猜你喜欢
        • 2015-06-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-16
        相关资源
        最近更新 更多