LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   slarm64 (https://www.linuxquestions.org/questions/slarm64-132/)
-   -   libX265 for ffmpeg? [& later: RazPi Graphics] (https://www.linuxquestions.org/questions/slarm64-132/libx265-for-ffmpeg-%5B-and-later-razpi-graphics%5D-4175716099/)

business_kid 08-26-2022 06:55 AM

libX265 for ffmpeg? [& later: RazPi Graphics]
 
Is the h265 codec(?) compiled for slarm64? I'm getting
Code:

Unknown encoder libx265
I've been reducing the size of some videos. It started with ten 1 hour things @ ~4GB each which shrank to ~400MB with h264 --> h265 conversion.

They took over 20 minutes each on my 6 core box @3.5Ghz using 850-1100% cpu averaging 2.5x normal speed while converting.

I wanted to try one on my RazPi for comparison purposes, but ffmpeg is embarrassed for the h265 encoder. It might compete with my old twin core laptop.


Edit: forgot to post the command:
Code:

ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 output.mp4

Dunc. 08-26-2022 07:52 AM

I just had a look on my rpi4.
Code:

duncan@rpi-4:~$ ffmpeg -codecs | grep 26
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11.2.0 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-4.4.1/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-gpl --enable-version3 --enable-avresample --arch=aarch64 --disable-encoder=aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libbluray --enable-libcaca --enable-libcdio --enable-frei0r --enable-openal --enable-libopus --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libmp3lame --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libpulse --enable-libsmbclient --enable-libxml2 --enable-librsvg --enable-libdrm
  libavutil      56. 70.100 / 56. 70.100
  libavcodec    58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter    7.110.100 /  7.110.100
  libavresample  4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample  3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
 DEV.L. flv1                FLV / Sorenson Spark / Sorenson H.263 (Flash Video) (decoders: flv ) (encoders: flv )
 DEV.L. h261                H.261
 DEV.L. h263                H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 (decoders: h263 h263_v4l2m2m ) (encoders: h263 h263_v4l2m2m )
 D.V.L. h263i                Intel H.263
 DEV.L. h263p                H.263+ / H.263-1998 / H.263 version 2
 DEV.LS h264                H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: h264_v4l2m2m h264_vaapi )
 DEV.L. hevc                H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_v4l2m2m ) (encoders: hevc_v4l2m2m hevc_vaapi )
 ..V.L. vvc                  H.266 / VVC (Versatile Video Coding)
 DEAIL. adpcm_g726          G.726 ADPCM (decoders: g726 ) (encoders: g726 )
 DEAIL. adpcm_g726le        G.726 ADPCM little-endian (decoders: g726le ) (encoders: g726le )

So it looks to be available with hevc and hevc_v4l2m2m for decode and hevc_v4l2m2m for encode. I am not so sure hevc_vaapi will get you anything unless it is just a wrapper. I am no expert but I did try using hevc instad of lib265 and it failed - but it did try with:-
Code:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Big_Buck_Bunny_1080_10s_10MB.mp4':
  Metadata:
    major_brand    : isom
    minor_version  : 512
    compatible_brands: isomiso2avc1mp41
    title          : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder        : Lavf57.63.100
    comment        : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre          : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 7986 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 7983 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id      : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_v4l2m2m))
Press [q] to stop, [?] for help
[hevc_v4l2m2m @ 0x16fb2090] Could not find a valid device
[hevc_v4l2m2m @ 0x16fb2090] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I think I have reached the limit of my knowledge.

Dunc.

business_kid 08-26-2022 08:29 AM

Thanks for the fast reply. The video was actually 4.2G. I found my AMD box had Alien Bob's libX265, so I looked up the package, and got this:
Quote:

x265: x265 (H.265/HEVC encoder)
x265:
x265: x265 is a free software library and application for encoding video
x265: streams into the H.265/MPEG-H HEVC compression format.
x265:
x265:
x265:
x265:
x265:
x265: x265 home: https://www.videolan.org/developers/x265.html
The one line I took from videolan.org was
Code:

# git clone https://bitbucket.org/multicoreware/x265_git.git
So Slackware never had libX265.
I never go too far on these timings tests. I will compile libX265 for it, but not ffmpeg. I'm ok, because I'm comparing myself with myself. Otherwise,these timing comparisons usually deteriorate into a little boy's "Whose willy is biggest?" competion:rolleyes:

business_kid 08-26-2022 10:52 AM

Edit: Unnecessary Post - ignore

business_kid 08-26-2022 12:10 PM

OK this thread is finished from my POV for the moment. Not sorted, but finished.

I'm using a binary image from around the time of the 15.0 release with a slightly updated kernel. But it's light on development stuff. I tried building, but cmake puked thusly
Code:

-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - broken
CMake Error at /usr/share/cmake-3.21/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/usr/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/dec/x265_git/build/CMakeFiles/CMakeTmp
   
    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_f8755/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_f8755.dir/build.make CMakeFiles/cmTC_f8755.dir/build
    gmake[1]: Entering directory '/home/dec/x265_git/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_f8755.dir/testCXXCompiler.cxx.o
    /usr/bin/clang++    -MD -MT CMakeFiles/cmTC_f8755.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_f8755.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_f8755.dir/testCXXCompiler.cxx.o -c /home/dec/x265_git/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_f8755
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f8755.dir/link.txt --verbose=1
    /usr/bin/clang++ -rdynamic CMakeFiles/cmTC_f8755.dir/testCXXCompiler.cxx.o -o cmTC_f8755
    /usr/bin/ld: cannot find -lstdc++
    clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_f8755.dir/build.make:100: cmTC_f8755] Error 1
    gmake[1]: Leaving directory '/home/dec/x265_git/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_f8755/fast] Error 2
 
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:19 (project)

-- Configuring incomplete, errors occurred!
See also "/home/dec/x265_git/build/CMakeFiles/CMakeOutput.log".
See also "/home/dec/x265_git/build/CMakeFiles/CMakeError.log".

It seems the binary image was a bit light on development stuff. I had to install cmake, nasm & yasm to get off the ground, now I'm light on gcc-g++ & clang++. It seems the logical thing to do is mirror the 15.0-aarch64 packages from slackware.uk and run a mass 'upgradepkg --install-new' when I get time. I have a backup as it stands so I can always revert. I have 6.8G spare on my 20G / & 42G spare on my /home so I'll have the space. But timing tests are very low on the priorities.

sndwvs 08-26-2022 01:56 PM

build script, x265-3.5-aarch64-1mara.txz

business_kid 08-27-2022 11:34 AM

Quote:

Originally Posted by sndwvs (Post 6376334)

Thanks for the reply - you seem to have an impressively huge repo there of packages.

To business, though: This command
Code:

time ffmpeg -i New.Tricks.S09E07.Dead.Poets.1080p.WEB-DL.DDP2.0.H.264-squalor.mkv -c:v libx265 -vtag hvc1 New.Tricks.S09E07.Dead.Poets.1080p.WEB-DL.DDP2.0.H.265-squalor.mp4
still returns this error
Code:

Unknown encoder 'libx265'
I did the usual stuff - running ldconfig, and a reboot, but the error remains. I even ssh'ed in to my x86_64 box and checked the libraries were identically named, which they are.

Does this mean I have to recompile ffmpeg?

sndwvs 08-27-2022 12:12 PM

Quote:

Originally Posted by business_kid (Post 6376542)
Does this mean I have to recompile ffmpeg?

yes.

business_kid 08-27-2022 12:35 PM

Quote:

Originally Posted by sndwvs (Post 6376558)
yes.

OK. I won't because it's not worth the bother for an unimportant timing test. Better Arm systems are here and will come. If it was handy, I would have tested conversion speed.

Thanks for your help, nevertheless. Maybe add that option to whatever ffmpeg script you use?

sndwvs 08-27-2022 12:51 PM

all slarm64 uses original slackware64 scripts.

business_kid 08-27-2022 02:38 PM

Quote:

Originally Posted by sndwvs (Post 6376561)
all slarm64 uses original slackware64 scripts.

I hear you. My x86_64 ffmpeg is one of Alien Bob's 'unrestricted' builds as Europe isn't so Nazi on copyright as the Excited States. Perhaps that's where the difference is.

Anyhow, we have the answer. I could just add libx265 to the unrestricted ffmpeg build on x86_64 and ffmpeg picked it up, whereas yours didn't. I gather it's the restricted build for the U.S. It's your choice what you distribute, of course. The other items to get restricted/unrestricted treatment were vlc and iirc some of the gst plugins. Alien does _a_lot_ of audio stuff so there could be others.

You may be able to farm out doing alternative builds to whoever maintains the 'slackware.uk/slarm64' mirror site? None of the codecs are restricted there, but they are copyrighted in the US.

sndwvs 08-27-2022 03:12 PM

Quote:

Originally Posted by business_kid (Post 6376578)
I hear you. My x86_64 ffmpeg is one of Alien Bob's 'unrestricted' builds as Europe isn't so Nazi on copyright as the Excited States. Perhaps that's where the difference is.

Anyhow, we have the answer. I could just add libx265 to the unrestricted ffmpeg build on x86_64 and ffmpeg picked it up, whereas yours didn't. I gather it's the restricted build for the U.S. It's your choice what you distribute, of course. The other items to get restricted/unrestricted treatment were vlc and iirc some of the gst plugins. Alien does _a_lot_ of audio stuff so there could be others.

You may be able to farm out doing alternative builds to whoever maintains the 'slackware.uk/slarm64' mirror site? None of the codecs are restricted there, but they are copyrighted in the US.

there are no restrictions.

pchristy 08-28-2022 03:32 AM

I always build (or re-build) ffmpeg to include x264, x265, xvidcore, and a whole host of other video related stuff.

SBo builds are available for most of these libraries, and are simple to modify for aarch64 architecture, though in the past I've also modified standard Slackware build scripts for my purpose.

The standard Slackware build script has options to re-build ffmpeg in localities where things are less restrictive. It is not difficult to do. However, build times on a Pi are quite long compared to even modest x86_64 systems!

If you build these things yourself, you will know that they are optimised for your hardware. Generic builds are OK, but can be "over-engineered". For example, AlienBob's VLC is a monster, though it does cover all bases on x86_64!

--
Pete

business_kid 08-28-2022 04:09 AM

Quote:

Originally Posted by pchristy (Post 6376671)
I always build (or re-build) ffmpeg to include x264, x265, xvidcore, and a whole host of other video related stuff.

SBo builds are available for most of these libraries, and are simple to modify for aarch64 architecture, though in the past I've also modified standard Slackware build scripts for my purpose.

The standard Slackware build script has options to re-build ffmpeg in localities where things are less restrictive. It is not difficult to do. However, build times on a Pi are quite long compared to even modest x86_64 systems!

If you build these things yourself, you will know that they are optimised for your hardware. Generic builds are OK, but can be "over-engineered". For example, AlienBob's VLC is a monster, though it does cover all bases on x86_64!

--
Pete

Not me.
I'd build for needs, and this is not a need. I think I built Quartus fpga software, which was a 15G download. But to be fair, most of that was chip data. My install was a 15.0 binary image which has to be upgraded to include the rest of 15.0. I'll pass on the timing test. I built ffmpeg before, and while not difficult, it was work

On my standard AMD box (Ryzen 5 5600 6 cores/12 threads@3.5Ghz with 16G & nvme) it took over 20 minutes to convert a particular video from h264 to h265. The space saving was 4.0GB --> ~400Megs. I just wondered how long the Pi would take to do it, but I'm not building ffmpeg for that.

EDIT: Yes, Alien's unrestricted build is huge. But it's a Swiss Army knife. His unrestricted ffmpeg is the same - hence it's attractiveness.

Now that I have you, it's possible the slarm64 vlc won't play h265 videos. That's my media box. So I might have to switch them to something else. I'll have to find a good alternative that the Pi handles.

pchristy 08-28-2022 04:38 AM

My Pi 400 plays x265 just fine - with one proviso: It struggles with 4K! That has nothing to do with the media player or x265, but is a problem with the graphics driver. Even 1080 videos on mine have all four cores running at 80%+ simply because the hardware acceleration is not working yet. I don't think its working on any of the 64-bit distros, not even Pi's own! Slarm64 at least tries to play 4K, although it is VERY jittery.

SLackwareaarch64 can't even play 1080 on my system, and struggles with 720!

We are promised better hardware graphics support in kernel 5.20/6 which is due in a month or so's time.

The problem seems to be the Broadcom graphics chip. Although it is (allegedly) 4K capable, they have been slow/reluctant to release drivers for it. I'm not sure if the promised kernel drivers are reverse engineered or official releases. I guess we won't know if they work until they land...

--
Pete


All times are GMT -5. The time now is 04:31 PM.