【问题标题】:ffmpeg - duration usage in input text fileffmpeg - 输入文本文件中的持续时间使用
【发布时间】:2018-05-12 00:19:53
【问题描述】:

我正在尝试使用 ffmpeg 来连接带有一些黑屏的视频片段。为此,我首先生成了一个 10 秒的空白视频(无音轨):

$ ffmpeg -f lavfi -i color=black:s=320x240:r=1 -f lavfi -i anullsrc -t 10 -vcodec libvpx -an blank.mkv

然后,我在 input.txt 文件(以下内容)中创建了最简单的场景,以便在黑屏三秒后播放一段视频(无音轨):

file 'blank.mkv'
duration 3
file 'video_example.mkv'

最后,运行以下 ffmpeg 命令来连接该输入文件的内容:

$ ffmpeg -f concat -i input.txt -codec:v copy -codec:a copy output.mkv

我遇到的问题是没有考虑duration 3,因此最终视频仍然有十秒的黑帧(而不是三秒),然后是我的视频。当在文件中使用duration x 时,还会显示“输出流中的非单调 DTS 0:0 ...” 消息。如果我删除持续时间,警告就会消失,并且也会首先输出 10 秒黑屏。

ffmpeg concat 命令的完整输出:

$ ffmpeg -hide_banner -f concat -i input.txt -codec:v copy -codec:a copy output.mkv
Input #0, concat, from 'input.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: vp8, yuv420p(progressive), 320x240, SAR 1:1 DAR 4:3, 1 fps, 1 tbr, 1k tbn, 1k tbc
    Metadata:
      ENCODER         : Lavc57.107.100 libvpx
      DURATION        : 00:00:10.000000000
File 'output.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: vp8 (VP80 / 0x30385056), yuv420p(progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 1 fps, 1 tbr, 1k tbn, 1k tbc
    Metadata:
      ENCODER         : Lavc57.107.100 libvpx
      DURATION        : 00:00:10.000000000
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[concat @ 000000000031a440] DTS 3000 < 9000 out of order
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 3000; changing to 9000. This may result in incorrect timestamps in the output file.
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 4001; changing to 9000. This may result in incorrect timestamps in the output file.
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 4998; changing to 9000. This may result in incorrect timestamps in the output file.
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 6004; changing to 9000. This may result in incorrect timestamps in the output file.
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 7002; changing to 9000. This may result in incorrect timestamps in the output file.
[matroska @ 0000000000328420] Non-monotonous DTS in output stream 0:0; previous: 9000, current: 8005; changing to 9000. This may result in incorrect timestamps in the output file.
frame= 5794 fps=0.0 q=-1.0 Lsize=    7109kB time=01:37:09.70 bitrate=  10.0kbits/s speed=5.16e+004x
video:7043kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.926229%

知道我做错了什么吗?该警告似乎暗示了这里的问题。

其他可能有用的信息:

$ ffprobe -hide_banner blank.mkv
Input #0, matroska,webm, from 'blank.mkv':
  Metadata:
    ENCODER         : Lavf57.83.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 1 kb/s
    Stream #0:0: Video: vp8, yuv420p(progressive), 320x240, SAR 1:1 DAR 4:3, 1 fps, 1 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc57.107.100 libvpx
      DURATION        : 00:00:10.000000000

$ ffprobe -hide_banner video_example.mkv
Input #0, matroska,webm, from 'video_example.mkv':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2018-05-04T17:57:04.000000Z
  Duration: 01:37:08.70, start: 15434.269000, bitrate: 9 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 320x240, SAR 1:1 DAR 4:3, 1 fps, 1 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video

$ ffmpeg -v
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)

【问题讨论】:

    标签: ffmpeg


    【解决方案1】:

    对于视频和音频文件,必须使用入点/出点。

    file 'blank.mkv'
    outpoint 3
    file 'video_example.mkv'
    

    duration 对于单个图像很有用,例如在制作幻灯片时,或者 ffmpeg 无法可靠地发现媒体持续时间的原始音频/视频流。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-27
      • 2015-03-17
      • 2012-08-12
      • 1970-01-01
      • 2015-05-29
      • 2011-09-21
      • 2019-10-28
      • 2023-03-09
      相关资源
      最近更新 更多