gpt4 book ai didi

video - ffmpeg:以尽可能少的质量损失连接不同格式的视频

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

我有一组不同格式的视频片段,需要连接起来并作为单个视频上传到数据库。我需要以尽可能少的质量损失来做到这一点。例如,一组是:

video_1.mov - 796 frames, 432Mb,
video_2.mp4 - 913 frames, 58Mb,
video_3.mov - 625 frames, 345Mb

这应该连接到一个文件中: output.mov - 2334 frames, ?Mb
到目前为止,我正在这样做:
  • 转换 .mp4.movlossless encoding :
  • ffmpeg -i video_2.mp4 -c:v libx264 -preset veryslow -crf 0 -c:a copy video_2.mov
    在此步骤中产生错误:
    [h264 @ 0x558298795760] error while decoding MB 110 37, bytestream -69483.1kbits/s speed=0.227x     
    [h264 @ 0x558298795760] concealing 3659 DC, 3659 AC, 3659 MV errors in P frame

    这仍然输出 video_2.mov - frames 913, 112Mb
  • 使用concat demuxer合并视频:
  • ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mov
    在哪里 mylist.txt是:
    file 'video_1.mov'
    file 'video_2.mov'
    file 'video_3.mov'

    但是, concat demuxer 命令给出了错误:
    [concat @ 0x561cbae96900] Could not find codec parameters for stream 2 (Unknown: none): unknown codec.Consider increasing the value for the 'analyzeduration' and 'probesize' options

    紧随其后的是许多行:
    [mov @ 0x555b5dca4f00] Non-monotonous DTS in output stream 0:1; previous: 1527575, current: 1168413; changing to 1527576. This may result in incorrect timestamps in the output file.

    这些步骤的结果是 output.mov这是 432+345+112=889Mb 的正确大小但只有 1421帧数等于 video_1.mov - 796 frames 中的帧数和 video_3.mov - 625 frames .当我播放连接版本时, output.mov ,它会在 video_2.mov 的持续时间内卡住段,然后正常继续 video_3.mov .

    对此的任何帮助将不胜感激。

    编辑:

    运行 ffmpeg -n -i video_1.mov -i video_2.mp4 -i video_3.mov根据产生的评论:
    `ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
    configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
    libavutil 55. 78.100 / 55. 78.100
    libavcodec 57.107.100 / 57.107.100
    libavformat 57. 83.100 / 57. 83.100
    libavdevice 57. 10.100 / 57. 10.100
    libavfilter 6.107.100 / 6.107.100
    libavresample 3. 7. 0 / 3. 7. 0
    libswscale 4. 8.100 / 4. 8.100
    libswresample 2. 9.100 / 2. 9.100
    libpostproc 54. 7.100 / 54. 7.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_1.mov':
    Metadata:
    major_brand : qt
    minor_version : 0
    compatible_brands: qt
    creation_time : 2019-11-16T09:57:04.000000Z
    keywords : iMovie
    description :
    title :
    com.apple.quicktime.description:
    com.apple.quicktime.displayname:
    com.apple.quicktime.keywords: iMovie
    com.apple.quicktime.title:
    Duration: 00:00:31.84, start: 0.000000, bitrate: 108530 kb/s
    Stream #0:0(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
    creation_time : 2019-11-16T09:57:04.000000Z
    handler_name : Core Media Data Handler
    Stream #0:1(und): Video: prores (apcn / 0x6E637061), yuv422p10le(bt709, progressive), 1920x1080, 106992 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc (default)
    Metadata:
    creation_time : 2019-11-16T09:57:04.000000Z
    handler_name : Core Media Data Handler
    encoder : Apple ProRes 422
    timecode : 00:00:00:00
    Stream #0:2(und): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
    creation_time : 2019-11-16T09:57:04.000000Z
    handler_name : Core Media Data Handler
    timecode : 00:00:00:00
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video_2.mp4':
    Metadata:
    major_brand : mp42
    minor_version : 1
    compatible_brands: mp41mp42isom
    creation_time : 2019-11-16T09:55:40.000000Z
    Duration: 00:00:30.71, start: 0.000000, bitrate: 15320 kb/s
    Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 165 kb/s (default)
    Metadata:
    creation_time : 2019-11-16T09:55:40.000000Z
    handler_name : Core Media Audio
    Stream #1:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 15277 kb/s, 29.98 fps, 29.97 tbr, 90k tbn, 60 tbc (default)
    Metadata:
    creation_time : 2019-11-16T09:55:40.000000Z
    handler_name : Core Media Video
    Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video_3.mov':
    Metadata:
    major_brand : qt
    minor_version : 0
    compatible_brands: qt
    creation_time : 2019-11-16T09:57:19.000000Z
    keywords : iMovie
    description :
    title :
    com.apple.quicktime.description:
    com.apple.quicktime.displayname:
    com.apple.quicktime.keywords: iMovie
    com.apple.quicktime.title:
    Duration: 00:00:25.00, start: 0.000000, bitrate: 110329 kb/s
    Stream #2:0(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
    creation_time : 2019-11-16T09:57:19.000000Z
    handler_name : Core Media Data Handler
    Stream #2:1(und): Video: prores (apcn / 0x6E637061), yuv422p10le(bt709, progressive), 1920x1080, 108790 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc (default)
    Metadata:
    creation_time : 2019-11-16T09:57:19.000000Z
    handler_name : Core Media Data Handler
    encoder : Apple ProRes 422
    timecode : 00:00:00:00
    Stream #2:2(und): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
    creation_time : 2019-11-16T09:57:19.000000Z
    handler_name : Core Media Data Handler
    timecode : 00:00:00:00

    最佳答案

    要连接的所有输入必须具有相同的属性和格式。 video_2.mp4奇怪的是 MP4 中的 H.264 + AAC,而其他的是 MOV 中的 ProRes + PCM。

    一种选择是重新编码 video_2.mp4匹配其他输入:

    ffmpeg -i video_2.mp4 -map 0 -c:a pcm_s16be -c:v prores -r 25 -video_track_timescale 25 video_2.mov

    制作 mylist.txt :
    file 'video_1.mov'
    file 'video_2.mov'
    file 'video_3.mov'

    连接:
    ffmpeg -f concat -i mylist.txt -c copy output.mov

    关于video - ffmpeg:以尽可能少的质量损失连接不同格式的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62335472/

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