我想合并 3 个文件,但每个文件的压缩格式都不同(xvideo、theora、x264),而且分辨率也不同。我使用了本指南但据我所知,只有当视频格式相同时才会如此。
加连接时我想更改视频分辨率并使用libx264 1500K
先感谢您
ffmpeg 输出
ffmpeg -i '/home/levan/log.ogv' -i '/home/levan/Videos/2.m4v' -i '/home/levan/Comp 1.mp4'
ffmpeg version 2.4.git Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 1 2014 23:29:20 with gcc 4.9.1 (Ubuntu 4.9.1-16ubuntu6)
configuration: --prefix=/home/levan/ffmpeg_build --extra-cflags=-I/home/levan/ffmpeg_build/include --extra-ldflags=-L/home/levan/ffmpeg_build/lib --bindir=/home/levan/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
libavutil 54. 11.100 / 54. 11.100
libavcodec 56. 10.100 / 56. 10.100
libavformat 56. 11.101 / 56. 11.101
libavdevice 56. 2.100 / 56. 2.100
libavfilter 5. 2.101 / 5. 2.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, ogg, from '/home/levan/log.ogv':
Duration: 00:00:01.73, start: 0.000000, bitrate: 729 kb/s
Stream #0:0(und): Video: theora, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 30 tbn, 30 tbc
Metadata:
LANGUAGE : und
HANDLER_NAME : VideoHandler
ENCODER : Lavc56.10.100 libtheora
MAJOR_BRAND : isom
MINOR_VERSION : 512
COMPATIBLE_BRANDS: isomiso2avc1mp41
Stream #0:1(und): Audio: vorbis, 48000 Hz, stereo, fltp, 160 kb/s
Metadata:
LANGUAGE : und
HANDLER_NAME : SoundHandler
ENCODER : Lavc56.10.100 libvorbis
MAJOR_BRAND : isom
MINOR_VERSION : 512
COMPATIBLE_BRANDS: isomiso2avc1mp41
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/home/levan/Videos/2.m4v':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : 2
encoder : HandBrake 6681svn 2015010301
Duration: 00:37:39.40, start: 10.169000, bitrate: 4495 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 960x544 [SAR 1:1 DAR 30:17], 4327 kb/s, 58.24 fps, 1 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 154 kb/s (default)
Metadata:
handler_name : Stereo
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/home/levan/Comp 1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2014-07-17 02:14:45
Duration: 00:00:05.03, start: 0.033333, bitrate: 17184 kb/s
Stream #2:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 17168 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2014-07-17 02:14:45
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
答案1
ffmpeg -i log.ogv -i 2.m4v -i 1.mp4 -filter_complex \
"[0:v]setpts=PTS-STARTPTS[v0]; \
[1:v]scale=-2:1080,pad=1920:ih:(ow-iw)/2:0,setsar=1/1,setpts=PTS-STARTPTS[v1]; \
[2:v]setpts=PTS-STARTPTS[v2]; \
[v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4
setpts
– 重置的时间戳concat
。scale
– 将较小的视频放大以与其他视频匹配。或者,您可以将其他视频缩小到 960x544。pad
– 添加填充;否则最终会变成 1906x1080。或者,您可以使用scale=1920:-2,crop=iw:720
(缩放结果为 1920x1088)并裁剪掉多余的 8 个像素,而不是填充。setsar
– 设置样本纵横比,使其与其他视频相同。concat
– 连接一切。
不幸的是我现在无法测试这个例子。