video - 使用ffmpeg连接后如何输出mp4

标签 video ffmpeg

我想合并几个 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 有单声道音频?

最佳答案

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

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

现在连接。

关于video - 使用ffmpeg连接后如何输出mp4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57662967/

相关文章:

c++ - 错误 : Ordinal 139 could not be located in swscale-2. dll

image - ffmpeg 图像到视频脚本有人吗?

http - 未缓冲的视频流如何中途​​启动

java - 无法使用 Xuggler 编码视频

linux - ffmpeg 与动态 block 连接

ruby - 如何在 ruby​​ 项目中包含库?

javascript - 如何从组件 <video></video> 获取帧

node.js - 在 Google Compute Engine 上自动安装 FFMPEG (Debian Wheezy 7.8)

c# - 如何在连接时使用 FFMPEG 压缩多个视频

ffmpeg - 如何使用 avprobe/ffprobe 检测音频采样率?