【问题标题】:How to output mp4 after concatenation using ffmpeg使用ffmpeg连接后如何输出mp4
【发布时间】:2019-12-30 22:39:00
【问题描述】:

我想合并几个 mp4 视频(具有不同的 fps、高度、宽度和比特率)。

我尝试了一些视频,但它总是隐藏或跳过input.txt 中的一些视频文件。

如何正确合并这些 mp4 文件?

谢谢!

我的命令:

ffmpeg, "-f", "concat", "-i", "concatfile.txt", "-c:v", "copy", "-sn", "-y", "merged_video.mp4", "-max_muxing_queue_size", "1024"

->视频播放不正确

编辑: 我现在在concat.txt_中输出每个视频的信息_

INPUT1:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000028cdd7c3d00] Auto-inserting h264_mp4toannexb bitstream filter

Input #0, concat, from 'concatfile.txt':

  Duration: N/A, start: 0.000000, bitrate: 535 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 435 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 05/10/2019.

    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 100 kb/s

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 05/10/2019.

INPUT2:
mov,mp4,m4a,3gp,3g2,mj2 @ 00000256592b3d00] Auto-inserting h264_mp4toannexb bitstream filter

Input #0, concat, from 'concatfile.txt':

  Duration: N/A, start: 0.000000, bitrate: 620 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 522 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.

    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 97 kb/s

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.


INPUT3:
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a774cd3d00] Auto-inserting h264_mp4toannexb bitstream filter

Input #0, concat, from 'concatfile.txt':

  Duration: N/A, start: 0.000000, bitrate: 609 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 513 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.

    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.


INPUT4:
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000165b1013c80] Auto-inserting h264_mp4toannexb bitstream filter

Input #0, concat, from 'concatfile.txt':

  Duration: N/A, start: 0.000000, bitrate: 510 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 415 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.

    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s

    Metadata:

      handler_name    : ISO Media file produced by Google Inc. Created on: 10/31/2018.

INPUT5:
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001c545493c80] Auto-inserting h264_mp4toannexb bitstream filter

Input #0, concat, from 'concatfile.txt':

  Duration: N/A, start: -0.042667, bitrate: 2972 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 900x600 [SAR 1:1 DAR 3:2], 2862 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:

      handler_name    : VideoHandler

    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 24000 Hz, mono, fltp, 110 kb/s

    Metadata:

      handler_name    : SoundHandler

可能是问题,最后一个 mp4 有单声道音频?

【问题讨论】:

  • 所有输入必须具有相同的属性。要么通过过滤和重新编码使其他内容匹配主要内容,然后使用 concat demuxer,或者通过使用 concat 过滤器在一个命令中重新编码和连接所有内容(这里有几个 Q/A 显示如何做)。如果您需要更多帮助,请在edit 您的问题中包含concatfile.txt 中列出的每个输入的信息,例如运行ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 并提供完整的日志。
  • 感谢您的快速回复,我已经更新了有关您推荐的问题。

标签: video ffmpeg


【解决方案1】:

所有输入必须具有相同的属性,但输入 #5 与其他输入不同:宽度、高度、音频采样率和音频通道布局。使其符合其他规范:

ffmpeg -i input5.mp4 -filter_complex "[0:v]scale=640:360:force_original_aspect_ratio=decrease,pad=640:360:(ow-iw)/2:(oh-ih)/2,setsar=1[v];[0:a]aformat=sample_rates=44100:channel_layouts=stereo[a]" -map "[v]" -map "[a]" input5b.mp4

现在连接。

【讨论】:

    猜你喜欢
    • 2011-11-12
    • 1970-01-01
    • 2012-01-26
    • 2019-08-15
    • 2020-05-20
    相关资源
    最近更新 更多