ffmpeg 连接不同时基的视频 [英] ffmpeg concat videos with different timebase

查看:23
本文介绍了ffmpeg 连接不同时基的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用

ffmpeg.exe -f concat -i file_path_list_txt -c copy out_out.mp4

连接

for file in 1265_*; do ffmpeg -i $file -crf 30 -b:a 23k -b:v 96k -threads 3 -y 'out_'$file; done

压缩视频.

当我播放生成的视频时,播放器显示视频长度远大于压缩视频片段的总和.并且在切片之间的联动处,帧可以播放很长时间,播放器上的时间在继续,但帧静止.

When I play the generated video, the player shows the video length is much longer than the sum of compressed video pieces. And at the linkage between slices,the frame can play a very long time,time on the player is going on,but the frame is still.

我使用 ffprobe 来显示原始视频片段和压缩视频片段.并找到了具有相同tbr,tbn,tbc的原始视频,而压缩后的视频没有.

I use ffprobe to show the original video pieces and compressed video pieces. And found the original videos with same tbr,tbn,tbc, while the compressed not.

原始视频:

Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, progressive), 1600x1144, 134 kb/s, 8.17 fps, 600 tbr, 600 tbn, 1200 tbc (default)
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, progressive), 1600x1144, 138 kb/s, 9.73 fps, 600 tbr, 600 tbn, 1200 tbc (default)

压缩视频:

Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1600x1144, 174 kb/s, 8.17 fps, 8.17 tbr, 245050 tbn, 16.33 tbc (default)
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1600x1144, 127 kb/s, 9.73 fps, 9.73 tbr, 1750800 tbn, 19.45 tbc (default)

当我连接时,在控制台中,ffmpeg 显示以下信息:

And when I concat, in the console,ffmpeg show below info:

[mp4 @ 000001fe0193b700] Application provided duration: 2585263321 / timestamp: 6303355764 is out of range for mov/mp4 format
[mp4 @ 000001fe0193b700] pts has no value
[mp4 @ 000001fe0193b700] Application provided duration: 2585443321 / timestamp: 6303535765 is out of range for mov/mp4 format
[mp4 @ 000001fe0193b700] pts has no value

在我的情况下,视频片段是逐次生成的,我不知道它何时停止,因此我无法在压缩之前进行连接.每次生成视频片段时,我都会对其进行压缩并附加.

In my situation the video pieces are generated time by time, and I don't know when it stops, so I cannot do concat before compress. Each time a video piece generated I comress it and append it.

推荐答案

压缩到 MOV/MP4 时,使用 -video_track_timescale N 设置一个通用的时间刻度 tbn.对于您的输入,N=600 看起来不错.

When compressing to MOV/MP4, set a common timescale tbn using -video_track_timescale N. For your input, N=600 looks fine.

这篇关于ffmpeg 连接不同时基的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆