Closed mcff2 closed 1 year ago
Hi @mcff2 !
You can try to investigate the problem using ffmpeg cmdline:
First, you can retrieve the ffmpeg supported encoders in your configuration:
$ ffmpeg -encoders
...
V..... h263 H.263 / H.263-1996
V..... h263_v4l2m2m V4L2 mem2mem H.263 encoder wrapper (codec h263)
V.S... h263p H.263+ / H.263-1998 / H.263 version 2
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V....D libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
V....D h264_amf AMD AMF H.264 Encoder (codec h264)
V....D h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
V..... h264_qsv H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
...
Check if your ffmpeg installation supports the libx264 (maybe you didn't install the right package, or if you have compiled ffmpeg yourself, maybe you miss the lixb264 configuration
Once it's done, you can also get informations on a specific codec (for example here h264_qsv):
$ ffmpeg -h encoder=h264_qsv
...
Encoder h264_qsv [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)]:
General capabilities: delay hybrid
Threading capabilities: none
Supported hardware devices: qsv qsv qsv
Supported pixel formats: nv12 p010le qsv
h264_qsv encoder AVOptions:
-async_depth <int> E..V....... Maximum processing parallelism (from 1 to INT_MAX) (default 4)
-avbr_accuracy <int> E..V....... Accuracy of the AVBR ratecontrol (unit of tenth of percent) (from 1 to 65535) (default 1)
-avbr_convergence <int> E..V....... Convergence of the AVBR ratecontrol (unit of 100 frames) (from 1 to 65535) (default 1)
-preset <int> E..V....... (from 1 to 7) (default medium)
veryfast 7 E..V.......
faster 6 E..V.......
fast 5 E..V.......
medium 4 E..V.......
slow 3 E..V.......
slower 2 E..V.......
veryslow 1 E..V.......
-forced_idr <boolean> E..V....... Forcing I frames as IDR frames (default false)
...
If you decide to compile your ffmpeg, here is an example of a configuration for the "./configuration" run:
ffmpeg-5.1.1]$ head config.h
/* Automatically generated by configure - do not modify! */
#ifndef FFMPEG_CONFIG_H
#define FFMPEG_CONFIG_H
#define FFMPEG_CONFIGURATION "--enable-gpl --enable-libx264 --enable-libx265 --enable-vaapi --enable-vdpau --enable-libmfx --enable-librav1e --enable-libaom --enable-libvpx --enable-libv4l2 --enable-libopus --enable-libmp3lame --enable-libfreetype --prefix=/usr --enable-shared"
...
So you may download ffmpeg 5.1.1 and do:
./configure --enable-gpl --enable-libx264 --enable-libx265 --enable-vaapi --enable-vdpau --enable-libmfx --enable-librav1e --enable-libaom --enable-libvpx --enable-libv4l2 --enable-libopus --enable-libmp3lame --enable-libfreetype --prefix=/usr --enable-shared
make
sudo make install
it enables libx264, qsv hardware compression (for intel cpu) If you have an nvidia, you may also add the h264_nvenc
Oh, another solution: Maybe you simply didn't install the x264 package on your distrib?
May I close this issue @mcff2 ?
Hi @mcff2 I have something for this one. On old ffmpeg version, for example on CentOS 7 distribution, ffmpeg needs to call a function to register all codecs. This function has been deprecated in new ffmpeg version, and we remove it's call in Sanzu some monthes ago. If you build sanzu on such systems, you have to apply the following patch which call the function in the encoder side and in the decoder side:
diff --git a/sanzu/src/video_decoder.rs b/sanzu/src/video_decoder.rs
index 76f146e..c715248 100644
--- a/sanzu/src/video_decoder.rs
+++ b/sanzu/src/video_decoder.rs
@@ -33,6 +33,10 @@ pub fn init_video_codec<'a>(
ffmpeg::av_log_set_level(ffmpeg::AV_LOG_FATAL);
}
+ unsafe {
+ ffmpeg::av_register_all();
+ }
+
let decoder: Box<dyn Decoder> = match name {
"null" => Box::new(DecoderNull {
data_rgb: None,
diff --git a/sanzu/src/video_encoder.rs b/sanzu/src/video_encoder.rs
index 5692b45..b341c3d 100644
--- a/sanzu/src/video_encoder.rs
+++ b/sanzu/src/video_encoder.rs
@@ -610,6 +610,11 @@ pub fn init_video_encoder<'a>(
unsafe {
ffmpeg::av_log_set_level(ffmpeg::AV_LOG_FATAL);
}
+
+ unsafe {
+ ffmpeg::av_register_all();
+ }
+
let encoder: Box<dyn Encoder> = match name {
"null" => Box::new(EncoderNull::new()),
name => {
I confirm that your guess was the good one. After adding those lines, it works.
Thanks !
Thank you for your feedback. We may not add a branch to support this old version of ffmpeg, as it is a deprecated API. Moreover, we approche the centos 7 eol.
No pb, and thanks for the support. Once it's identified, it's rather easy to add those two lines.
Hi,
I got a weird error : "[2023-01-25T07:01:46.989148100Z ERROR sanzu_server] Server error [2023-01-25T07:01:46.989242403Z ERROR sanzu_server] - due to Error in init video encoder [2023-01-25T07:01:46.989264520Z ERROR sanzu_server] - due to Error in EncoderBuilder [2023-01-25T07:01:46.989279303Z ERROR sanzu_server] - due to Error in new AVCodec [2023-01-25T07:01:46.989302310Z ERROR sanzu_server] - due to CodecNotFound: libx264"
But sanzu_server is dynamicaly linked to the correct libs :
I know that it's not easy to investigate with those limited infos. But based on your experience with sanzu_server, do you have any clue?