gpt4 book ai didi

video - FFmpeg 问题 : encode/normalize then concat multiples videos

转载 作者:行者123 更新时间:2023-12-04 23:11:11 25 4
gpt4 key购买 nike

我想要:

  • 对大量视频进行编码以添加文本
  • 将它们连接成一个最终视频(最好重新编码)

  • 我需要分两步完成操作。我阅读了很多帖子,但没有找到正确的解决方案。
    视频来自不同的来源,因此具有不同的编码设置。
    要对视频进行编码,我使用以下命令:
    ffmpeg -i input.1.mp4 -vcodec libx264 -acodec aac -pix_fmt yuv420p-vf scale=1920:-2, drawtext=fontfile=./roboto.ttf: fontsize=40: text='ABC': x=(w-text_w)-w/20: y=(h-text_h)-h/20 -y export/out.1.mp4
    为了连接我尝试过:
    ffmpeg -safe 0 -f concat -i <(find ./export/ -type f -printf "file '$PWD/%p'\n" | sort) -c copy concat.out.mp4
    但是我有很多这样的警告,结果视频有问题:
    Non-monotonous DTS in output stream 0:0; previous: 2362816, current: 1624899; changing to 2362817. This may result in incorrect timestamps in the output file.
    一小部分编码视频信息:
      Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4138 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 5241 kb/s, 30.04 fps, 30.04 tbr, 22500 tbn (default)
    Stream #2:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4770 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #3:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4144 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #4:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 7547 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #5:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 10784 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #6:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 7165 kb/s, 30.04 fps, 30.04 tbr, 22500 tbn (default)
    Stream #7:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 3150 kb/s, 30.04 fps, 30.04 tbr, 22500 tbn (default)
    Stream #8:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 8996 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #9:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4673 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #10:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1920x1080, 3625 kb/s, 29 fps, 29 tbr, 14848 tbn (default)
    Stream #11:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1920x1080, 33163 kb/s, 29 fps, 29 tbr, 14848 tbn (default)
    Stream #12:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4624 kb/s, 29 fps, 29 tbr, 14848 tbn (default)
    Stream #13:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 4034 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #14:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 6519 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Stream #15:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 1816 kb/s, 30 fps, 30 tbr, 15360 tbn (default)

    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #4:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #5:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #6:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #7:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #8:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #9:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #10:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Stream #11:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Stream #12:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Stream #13:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #14:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Stream #15:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    我也试过:
    ffmpeg -i 091245.mp4 -i 115405.mp4 -i 160743.mp4 -i 081024.mp4 -i 172500.mp4 -i 101658.mp4 -i 115904.mp4 -i 170035.mp4 -i 004129.mp4 -i 181930.mp4 -i 092100_01.mp4 -i 132726_01.mp4 -i 153927_01~2.mp4 -i 123552.mp4 -i 075329.mp4 -i 124002.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] [3:v] [3:a] [4:v] [4:a] [5:v] [5:a] [6:v] [6:a] [7:v] [7:a] [8:v] [8:a] [9:v] [9:a] [10:v] [10:a] [11:v] [11:a] [12:v] [12:a] [13:v] [13:a] [14:v] [14:a] [15:v] [15:a] concat=n=16:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" concat.out.mkv
    工作正常,但重新编码所有视频。
    有没有更好的方法来标准化第一个编码的输出视频以便能够轻松地连接它们?

    最佳答案

    为了与 concat demuxer 正确连接,属性必须相同。

  • 您的视频有不同的时基 (tbn)。
  • 您的音频有不同的采样率。

  • 在您的编码命令中使它们相同:
    ffmpeg -i input.1.mp4 -vcodec libx264 -acodec aac -vf fps=30,scale=1920:-2, drawtext=fontfile=./roboto.ttf: fontsize=40: text='ABC': x=(w-text_w)-w/20: y=(h-text_h)-h/20,format=yuv420p -ar 48000 -y export/out.1.mp4

    关于video - FFmpeg 问题 : encode/normalize then concat multiples videos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68113755/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com