我有多个以横向和纵向模式制作的视频。我想将它们连接成一部电影。
为此我将肖像视频旋转为:
ffmpeg -i in.mp4 -vf transpose=1 out.mp4
构建文件列表以连接所有文件并将它们连接起来:
ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
结果无法播放。所有玩家在第一次从横向切换到旋转的肖像片段时挂起/崩溃。
回复LordNeckbeard的请求:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-07-20T12:50:32.000000Z
Duration: 00:00:30.36, start: 0.000000, bitrate: 20202 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 20005 kb/s, SAR 1:1 DAR 16:9, 29.45 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2017-07-20T12:50:32.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default)
Metadata:
creation_time : 2017-07-20T12:50:32.000000Z
handler_name : SoundHandle
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-07-24T13:57:42.000000Z
Duration: 00:00:31.94, start: 0.000000, bitrate: 20171 kb/s
Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 19997 kb/s, SAR 1:1 DAR 16:9, 29.43 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2017-07-24T13:57:42.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default)
Metadata:
creation_time : 2017-07-24T13:57:42.000000Z
handler_name : SoundHandle
At least one output file must be specified
答案 0 :(得分:0)
为文件$f
提供结果的最终算法是:
使用以下内容删除元数据轮换字段
ffmpeg -i $f -c copy -metadata:s:v:0 rotate=0 md_$f
旋转视频:
ffmpeg -i md_$f -vf transpose=1 rt_$f.mp4
转换为TS:
ffmpeg -i rt_$f -c copy -bsf:v h264_mp4toannexb -f mpegts $f.ts
将所有ts文件连接到:
ffmpeg -i "concat:f1.ts|f2.ts|f3.ts" -c copy -bsf:a aac_adtstoasc output.mp4