gpt4 book ai didi

c - avconv 在 14.04 上从 libx264 管道时提示 "non monotonically increasing dts to muxer in stream"

转载 作者:太空狗 更新时间:2023-10-29 16:49:00 25 4
gpt4 key购买 nike

我有一段代码获取图像流并使用 x264 编码和 avconv 将它们写入文件。相关位如下

// Setup encoder
sprintf(cmd, "avconv -i pipe: -vcodec copy %s", filename);
fp = popen(cmd, "w");
x264_param_default_preset(&params, "ultrafast", "stillimage,zerolatency");
params.i_fps_num = fps;
params.i_fps_den = 1;
x264_picture_alloc(&in, X264_CSP_I420, width, height);
params.i_csp = X264_CSP_I420;
in.img.i_csp = X264_CSP_I420;
x.params.b_vfr_input = 0;
in.i_pts = -1;
out.i_pts = -1;
params.i_width = width;
params.i_height = height;
encoder = x264_encoder_open(&params);

in.img.i_plane = 1;
in.img.i_stride[0] = width;
ret = x264_encoder_headers(encoder, &nals, &nheader);
header_size = nals[0].i_payload + nals[1].i_payload + nals[2].i_payload;
fwrite(nals[0].p_payload, header_size, 1, fp);

...
// Loop body
++in.i_pts;
frame_size = x264_encoder_encode(encoder, &nals, &num_nals, &in, &out);
fwrite(nals[0].p_payload, frame_size, 1, fp);

为清楚起见,我省略了错误检查,但不会返回任何错误。事实上,在我将我的系统升级到 14.04 之前,这段代码可以完美运行(并且继续为尚未升级的同事完美运行)。

现在才运行 Ubuntu 14.04,我从 avconv 得到这个输出

[h264 @ 0x98dec0] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'pipe:'
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 640x480, 25 fps, 25 tbr, 25 tbn, 60 tbc
Output #0, mp4, to '../reel/test.mp4':
Metadata:
encoder : Lavf54.20.3
Stream #0.0: Video: libx264, yuv420p, 640x480, q=2-31, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
[mp4 @ 0x1347800] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 2 >= 2
av_interleaved_write_frame(): Invalid argument

尽管有错误,out.i_dts 确实在整个视频持续时间内单调增加(它始终等于 in.i_pts)。

我的一般假设是,较新版本的 avconv 对输入流的参数更加严格,因此虽然我选择的参数以前可能有效,但它们现在不起作用。

另一个可能相关的好奇是 avconv 检测到流是 25 FPS,即使 x264 配置的输入 FPS 为 30。

编辑:一些进一步的信息,相同的 dts 错误 (2>=2) 发生而不管初始 pts(输出 dts 与预期匹配)。

最佳答案

在“我不知道为什么这应该修复它,但确实如此”的时刻,将 -vcodec copy 更改为 -vcodec libx264(即使源编解码器已经是 libx264) 修复了 dts 错误。

关于c - avconv 在 14.04 上从 libx264 管道时提示 "non monotonically increasing dts to muxer in stream",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23408309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com