- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ffmpeg 2.1.3 和 libavcodec 55.39.101 混合视频(强制使用该版本,因为它在 google-chrome PNACL 端口项目中可用)。我所有的框架似乎都有坏的时间。他们试图在播放视频时在视频开始时立即全部渲染。
我将流时基设置为 1/25,但在调用 avformat_write_header 之后,它的值为 -18082736/1。在每一帧中,当我打印流 time_base 时,它表示 1/12800,而编解码器的 time_base 始终正常(1/25)。
av_format_write_header 前后的控制台日志:
before avformat_write_header stream time_base: 1/25
after avformat_write_header ret 0 stream time_base: -18082736/1
代码(为使帖子简短而进行了缩写,原始版本中的所有调用都进行了错误检查):
AVCodecContext *codecContext;
AVCodec * codec = avcodec_find_encoder(codec_id);
myOutputStream->stream = avformat_new_stream(outputFormatContext, *codec);
myOutputStream->stream->id = outputFormatContext->nb_streams-1;
codecContext = myOutputStream->stream->codec;
codecContext->codec_id = codec_id;
codecContext->bit_rate = 400000;
codecContext->width = width;
codecContext->height = height;
myOutputStream->stream->time_base = (AVRational){ 1, 25 };
codecContext->time_base = myOutputStream->stream->time_base;
codecContext->gop_size = 12;
codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
AVDictionary *opt = NULL;
av_dict_copy(&opt, opt_arg, 0);
ret = avcodec_open2(codecContext, codec, &opt);
av_dict_free(&opt);
myOutputStream->frame = alloc_picture(codecContext->pix_fmt, codecContext->width, codecContext->height);
myOutputStream->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, codecContext->width, codecContext->height);
//before: printing g_outputContext->stream time_base here
ret = avformat_write_header(g_outputContext, &opt);
//after: printing g_outputContext->stream time_base here
如果我在最终视频上运行 ffmpeg -i,我得到了这个(为什么持续时间为零?):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test4.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf55.19.104
Duration: 00:00:00.05, start: 0.000000, bitrate: 99549 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 800x600 [SAR 1:1 DAR 4:3], 463106 kb/s, 12800 fps, 12800 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
最佳答案
您需要在编码之后和写入文件之前操作数据包的 pts ... 流的 time_base 被 ffmpeg 更改并不罕见。在 https://www.ffmpeg.org/doxygen/trunk/ffmpeg_8c-source.html 查看 ffmpeg.c 源代码的第 869 行
关于video - FFMPEG avformat_write_header 改变我的流 time_base,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29850246/
我正在使用 MMPEG 的 C API 并收到此消息。所以我将 time_base 添加到我的流中 videoStream = avformat_new_stream(formatContext, c
我正在尝试使用 ffmpeg c api 更改视频播放速度。到目前为止,一切正常,除了应用于音频流时的时基变化不会加速音频。相反,它会切断部分音频。这大概是我所拥有的: for (uint64_t i
当我们想将音视频mux到OutputContext中时,我们必须转换AVPacekt的time_base。我困惑的是为什么输出 AVStream 的 time_base 是 (1, 90000)?出于
我想一劳永逸地知道时基计算和重新缩放在 FFMPEG 中是如何工作的。 在回答这个问题之前,我做了一些研究,发现了许多有争议的答案,这使得它更加困惑。 所以基于官方FFMPEG examples一个必
我正在使用 ffmpeg 2.1.3 和 libavcodec 55.39.101 混合视频(强制使用该版本,因为它在 google-chrome PNACL 端口项目中可用)。我所有的框架似乎都有坏
我转码视频(mkv 和 mp4)。 mkv转码为mkv时,输出很好(输出视频fps和duration与输入相同),但mkv转码为mp4时,输出fps小于输入2倍,输出视频时长大于输入2倍。 我只将视频
我是一名优秀的程序员,十分优秀!