FFMPEG 合并两个没有任何音频的视频

FFMPEG 合并两个没有任何音频的视频

我制作了两个不同的视频,它们是通过将多张图片组合成视频而创建的。下面是相关命令。

"-f","concat","-safe", "0","-i",path,"-vsync","vfr","-pix_fmt","yuv420p",Environment.getExternalStorageDirectory().path+"/output1.mp4"

这里的路径是文本文件的输入路径,其中我给出了所有需要合并的图像的路径。

现在我想将这两个视频合并为一个视频。为此,我使用以下命令。

-i, /storage/emulated/0/output.mp4, -i, /storage/emulated/0/output1.mp4, -filter_complex, [1:v][0:v]scale2ref[ua][b];[ua]setsar=1;[0:v][1:v]concat=n=2:v=1:a=0[v], -map, [v], -preset, ultrafast, /storage/emulated/0/output3.mp4

但它不起作用,日志中也没有给出任何错误。但这是进度方法中打印的最后一条语句,对我来说似乎是错误

流#1:0(und):视频:h264 (avc1 / 0x31637661),yuv420p,1000x800 [SAR 1:1 DAR 5:4],838 kb/s,0.83 fps,1 tbr,12800 tbn,50 tbc(默认)

这是两个视频的详细信息。

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:20.04, start: 0.000000, bitrate: 279 kb/s
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x854 [SAR 1:1 DAR 640:427], 279 kb/s, 0.25 fps, 0.20 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/output1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:06.04, start: 0.000000, bitrate: 839 kb/s
    Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1000x800 [SAR 1:1 DAR 5:4], 838 kb/s, 0.83 fps, 1 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Input #2, lavfi, from 'anullsrc':
  Duration: N/A, start: 0.000000, bitrate: 705 kb/s
    Stream #2:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s

我在这里做错了什么?

更新 这些是使用答案中共享的命令后的日志。

Successfully opened the file.
D/ffmpeg: progress [Parsed_scale2ref_0 @ 0xf16390c0] w:iw h:ih flags:'bilinear' interl:0
D/ffmpeg: progress [Parsed_setsar_1 @ 0xf1639120] Setting 'sar' to value '1'
D/ffmpeg: progress [Parsed_concat_2 @ 0xf1639180] Setting 'n' to value '2'
D/ffmpeg: progress [Parsed_concat_2 @ 0xf1639180] Setting 'v' to value '1'
D/ffmpeg: progress [Parsed_concat_2 @ 0xf1639180] Setting 'a' to value '0'
D/ffmpeg: progress Parsing a group of options: output url /storage/emulated/0/output3.mp4.
D/ffmpeg: progress Applying option map (set input stream mapping) with argument [v].
D/ffmpeg: progress Successfully parsed a group of options.
D/ffmpeg: progress Opening an output file: /storage/emulated/0/output3.mp4.

答案1

使用

-i, /storage/emulated/0/output.mp4, -i, /storage/emulated/0/output1.mp4, 
-filter_complex, [1:v][0:v]scale2ref[ua][b];[ua]setsar=1[ua];[b][ua]concat=n=2:v=1:a=0[v],
-map, [v], -preset, ultrafast, /storage/emulated/0/output3.mp4

相关内容