我正在尝试使用libx264编解码器使用FFMPEG从一组帧中编码.mp4视频.
这是我正在运行的命令:
/usr/local/bin/ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4
Run Code Online (Sandbox Code Playgroud)
我有时会收到以下错误:
[libx264 @ 0xa3b85a0] height not divisible by 2 (520x369)
Run Code Online (Sandbox Code Playgroud)
在稍微搜索之后,似乎问题与缩放算法有关,可以通过添加-vf参数来修复.
但是,在我的情况下,我不想做任何缩放.理想情况下,我希望保持尺寸与框架完全相同.有什么建议?是否存在h264强制执行的某种宽高比?
当我尝试将webm文件转换为mp4时,输出非常不稳定,看起来ffmpeg已经删除了很多帧
我使用以下命令进行转换
ffmpeg -i movie.webm movie.mp4
ffmpeg -i movie.webm -vcodec libx264 movie.mp4
ffmpeg -i movie.webm -vcodec libx264 -qscale 0 movie.mp4
Run Code Online (Sandbox Code Playgroud)
他们都有同样的问题.当我使用ffprobe时,它似乎或多或少地显示帧.
更新:
built on Jun 14 2013 14:31:50 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --prefix=/home/user2/ffmpeg_build --extra-cflags=-I/home/user2/ffmpeg_build/include --extra-ldflags=-L/home/pavan4/ffmpeg_build/lib --bindir=/home/pavan4/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
libavutil 52. 35.101 / 52. 35.101
libavcodec 55. 16.100 / 55. 16.100
libavformat 55. 8.102 / 55. 8.102
libavdevice 55. 2.100 / 55. 2.100
libavfilter 3. 77.101 / 3. 77.101
libswscale …Run Code Online (Sandbox Code Playgroud) 我试图使用libavcodec/libavformat编码视频.音频效果很好,但当我尝试编码视频时,我收到以下错误:
[libx264 @ 0x10182a000]broken ffmpeg default settings detected
[libx264 @ 0x10182a000]use an encoding preset (vpre)
Run Code Online (Sandbox Code Playgroud)
使用命令行ffmpeg很容易修复,但我想在C中执行此操作.我的选项是
AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0);
AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec;
pVideoOutCodecCtx->codec_id = CODEC_ID_H264;
pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO;
pVideoOutCodecCtx->bit_rate = pVideoInCodecCtx->bit_rate;
pVideoOutCodecCtx->width = pVideoInCodecCtx->width;
pVideoOutCodecCtx->height = pVideoInCodecCtx->height;
pVideoOutCodecCtx->pix_fmt = pVideoInCodecCtx->pix_fmt;
pVideoOutCodecCtx->sample_rate = pVideoInCodecCtx->sample_rate;
pVideoOutCodecCtx->gop_size = 30;
Run Code Online (Sandbox Code Playgroud)
但是avcodec_open()失败了.
我需要设置哪些其他值才能使x264满意?
我在使用X264 Fourcc编解码器的VideoWrite时遇到了ffmpeg错误.我已经安装了所有依赖项.如何解决这个问题.我一直使用的示例代码如下.
VideoWriter oVideoWriter ("path.mp4", CV_FOURCC('X','2','6','4'), 15, frameSize, false);
Run Code Online (Sandbox Code Playgroud)
操作系统:64位Ubuntu 14.04
控制台错误:
[libx264 @ 0x8d6220] broken ffmpeg default settings detected
[libx264 @ 0x8d6220] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x8d6220] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x8d6220] speed presets are listed in x264 --help
[libx264 @ 0x8d6220] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified errorOpenCV Error: Unsupported format or combination of formats (Your version of Gstreamer doesn't support this …Run Code Online (Sandbox Code Playgroud) 我ffmpeg从Windows 10 的BtbN启用了 libx264 。这是命令:
ffmpeg -f gdigrab -c:v libx264 -framerate 30 -i title="FiveM" -f flv rtmp://MYSITE.COM/stream/MYSECRETKEY
Run Code Online (Sandbox Code Playgroud)
不幸的是我得到这个输出:
Unknown decoder 'libx264'
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ffmpeg将视频编码为具有恒定比特率的H.264(通过libx264库).我知道,我知道,VBR通常是首选,但对于这个特定的工作,我需要使用CBR(只要它是每秒这么多千字节;它不必是每帧精确的千字节,afaik) .我用来测试的示例视频来自:http://a1408.g.akamai.net/5/1408/1388/2005110403/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_iTunes.mov.zip(来自http:// support. apple.com/kb/HT1425)
使用MPEG-4 Video(使用命令ffmpeg -i sample_iTunes.mov -b 819968 -minrate 819968 -maxrate 819968 out.mov)对视频进行编码时,我可以获得恒定的比特率,并且比特率是预期的.通过QuickTime Inspector读取视频的规格,它的数据速率为844.94 kbit/s.凉.
但是,当我将编解码器更改为libx264时,它似乎完全忽略了我的比特率请求!我正在尝试的命令是" ffmpeg -i sample_iTunes.mov -vcodec libx264 -vpre medium -b 819968 -vb 819968 -minrate 819968 -maxrate 819968 -bufsize 400000 test.mov".但是当我通过QuickTime Inspector检查视频的规格时,它的数据速率为254.74 kbit/s.WTF?那甚至不是很接近!
我已经尝试过更改这么多参数并添加大量不同的东西,我花了两天时间用Google搜索,但我似乎无法让它工作.如果我使用MainConcept H.264编码器对视频进行编码,我可以得到一个恒定的比特率,但我需要这个来使用ffmpeg.
如果有人可以帮我弄清楚如何用FFmpeg进行CBR H.264编码,我会永远爱你!
过去一周我一直在尝试通过RTP实现H.264流,使用x264作为编码器,使用libavformat来打包和发送流.问题是,据我所知,它无法正常工作.
现在我只是编码随机数据(x264_picture_alloc)并从libx264中提取NAL帧.这很简单:
x264_picture_t pic_out;
x264_nal_t* nals;
int num_nals;
int frame_size = x264_encoder_encode(this->encoder, &nals, &num_nals, this->pic_in, &pic_out);
if (frame_size <= 0)
{
return frame_size;
}
// push NALs into the queue
for (int i = 0; i < num_nals; i++)
{
// create a NAL storage unit
NAL nal;
nal.size = nals[i].i_payload;
nal.payload = new uint8_t[nal.size];
memcpy(nal.payload, nals[i].p_payload, nal.size);
// push the storage into the NAL queue
{
// lock and push the NAL to the queue
boost::mutex::scoped_lock lock(this->nal_lock);
this->nal_queue.push(nal);
} …Run Code Online (Sandbox Code Playgroud) 使用ffmpeg和libx264进行编码,是否有预设或标志可以优化解码速度?
现在似乎使用Qtkit以非常不同的速度解码用相似文件大小进行转码的视频,并且我想知道是否存在编码选项以使解码速度最大化.
我正在使用ffmpeg libx264来编码从x11实时捕获的720p屏幕,其fps为30.当我使用-tune zerolatency参数时,每帧的平均编码时间可以与配置文件基线一样大到12ms.
在研究了ffmpeg x264源代码之后,我发现导致如此长编码时间的关键参数是切片线程,它通过-tune zerolatency启用.使用-x264-params slic-threads = 0禁用后,编码时间可低至2ms
禁用切片线程后,CPU使用率将为40%,而启用时仅为20%.
有人可以解释这个切片线程的细节吗?特别是在实时编码中(假设没有帧被缓冲以进行编码.仅在捕获帧时进行编码).
当我从avi文件解码帧然后在x264中解码它们并保存到mp4文件时,输出文件的fps总是12,800.因此文件播放速度非常快.但是,当我以avi格式保存编码的h264帧而不是mp4时,所以fps就像我想要的那样--25.
可能是什么问题呢?
这里是我在VS2010中编写的代码:
#include "stdafx.h"
#include "inttypes.h"
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include <libswscale/swscale.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
}
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
const char* inFileName = "C:\\000227_C1_GAME.avi";
const char* outFileName = "c:\\test.avi";
const char* outFileType = "avi";
av_register_all();
AVFormatContext* inContainer = NULL;
if(avformat_open_input(&inContainer, inFileName, NULL, NULL) < 0)
exit(1);
if(avformat_find_stream_info(inContainer, NULL) < 0)
exit(1);
// Find video stream
int videoStreamIndex = -1;
for (unsigned int i …Run Code Online (Sandbox Code Playgroud)