如何分割具有奇怪关键帧“ pkt_pts_time = N / A”的视频? [英] How to split a video that has weird keyframes "pkt_pts_time=N/A"?

查看:436
本文介绍了如何分割具有奇怪关键帧“ pkt_pts_time = N / A”的视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在普通视频(在mkv上为h264)上运行这样的命令:

avconv -i videofile.avi -c复制-flags + global_header -segment_time 60 -f段 videofile-part。%03d .mp4

I can run a command like this on normal videos (h264 on mkv):
avconv -i videofile.avi -c copy -flags +global_header -segment_time 60 -f segment "videofile-part."%03d".mp4"

但在具有这种格式和容器的视频上(我至少有)会失败:
.avi文件上的
MPEG-4

but on videos with this format and container (the ones I have at least) it will fail:
MPEG-4 on a .avi file

如果我对其进行探测,则会得到拆分器忽略的关键帧:

ffprobe videofile.avi -show_entries frame = key_frame,pict_type,pkt_pts_time -select_streams v -of compact -v 0 | grep frame = 1 (从本技巧开始 https://stackoverflow.com/a/48687236/1422630

if I probe it I get key frames that are ignored by the splittter:
ffprobe videofile.avi -show_entries frame=key_frame,pict_type,pkt_pts_time -select_streams v -of compact -v 0 | grep frame=1 (from this tip https://stackoverflow.com/a/48687236/1422630)

,我得到了很多:

frame | key_frame = 1 | pkt_pts_time = N / A | pict_type = I

and I get a lot of this:
"frame|key_frame=1|pkt_pts_time=N/A|pict_type=I"

正常视频会输出如下所示的行:

frame | key_frame = 1 | pkt_pts_time = 44.252542 | pict_type = I

a normal video would output lines like this:
"frame|key_frame=1|pkt_pts_time=44.252542|pict_type=I"

因此,显然avconv需要有效的 pkt_pts_time才能工作...

so clearly avconv needs valid "pkt_pts_time" to work...

或者(不需要命令行工具):

是否可以在视频中添加适当的关键帧(带有值的pkt_pts_time)以使其可以被avconv正确分割?

还是我应该转换

Alternatively (not requiring a command line tool):
any fast way to add proper keyframes (pkt_pts_time with value) to the video to let it be splitted properly by avconv?
or may be I should convert a big video fastly (copying the video stream) into a format that has normal keyframes detected by avconv?

Obs。:
$可以将大视频快速地(复制视频流)快速转换为具有由avconv检测到的关键帧的格式? b $ b我正在使用linux ubuntu。

我正在使用 avconv 创建一个bash脚本,但是可以接受其他可脚本编写的工具(命令行工具)

Obs.:
I am using linux ubuntu.
I am creating a bash script using avconv, but other scriptable tools (command line tools) are acceptable if they work.

PS。:这种方法在unix stackexchange上是否更合适?

PS.: would this fit better on unix stackexchange?

推荐答案

使用最新版本的ffmpeg(4.0+),请使用

Using a recent version of ffmpeg (4.0+), use

ffmpeg -fflags + genpts -i videofile.avi -c复制-segment_time 60 -f段 videofile-part。%03d.mp4

分配丢失的PTS。

这篇关于如何分割具有奇怪关键帧“ pkt_pts_time = N / A”的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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