VoCore2 + ffmpeg + h.264 encoding?

noblepepper
 
Posts: 240
Joined: Sat Nov 29, 2014 3:22 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Wed Jan 04, 2017 7:03 am

Wow, it worked!

Try this-
In the base of your OpenWrt build dir:
Code: Select all
rm -rf tmp
mkdir feeds/packages/libs/libx264
cd feeds/packages/libs/libx264
wget https://raw.githubusercontent.com/openwrt/packages/master/libs/libx264/Makefile
cd -
./scripts/feeds/update -a
./scripts/feeds/install -a
make menuconfig


You should find libx264 available in the libraries section now.

It built for me but I have no idea if it will actually work.

GinDiamond
 
Posts: 48
Joined: Thu Mar 31, 2016 11:02 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Wed Jan 04, 2017 8:44 pm

It works!

Well, at least compiling openwrt with libx264 enabled works.

When I add the --enable-libx264 to the FFMPEG_CONFIG section of the ffmpeg makefile, I get a different error:

Code: Select all
install -d -m0755 /home/patrick/openwrt-chaoscalmer/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/ffmpeg-full/ffmpeg-2.6.9/ipkg-ramips_24kec/libffmpeg-full/usr/lib
cp -fpR /home/patrick/openwrt-chaoscalmer/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/ffmpeg-full/ffmpeg-2.6.9/ipkg-install/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.so.* /home/patrick/openwrt-chaoscalmer/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/ffmpeg-full/ffmpeg-2.6.9/ipkg-ramips_24kec/libffmpeg-full/usr/lib/
find /home/patrick/openwrt-chaoscalmer/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/ffmpeg-full/ffmpeg-2.6.9/ipkg-ramips_24kec/libffmpeg-full -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
Package libffmpeg-full is missing dependencies for the following libraries:
libx264.so.148


How do I fix these for the vocore?

noblepepper
 
Posts: 240
Joined: Sat Nov 29, 2014 3:22 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Wed Jan 04, 2017 11:21 pm

I think you got to where openwrt is putting ipks together one of the last steps.

I'm on the mobile now, drinking a beer, I'll take a look in the morning.

GinDiamond
 
Posts: 48
Joined: Thu Mar 31, 2016 11:02 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Thu Jan 05, 2017 2:00 pm

An interesting thing to note (possibly):

If I just enable libx264 in make menuconfig, it compiles fine.

If I enable libx264 in make menuconfig AND do --enable-libx264 in the FFMPEG_CONFIGURE AND enable ffmpeg-mini in make menuconfig, it compiles.

If I do the above and enable ffmpeg-full in make menuconfig (ffmpeg is still not enabled) it fails.

noblepepper
 
Posts: 240
Joined: Sat Nov 29, 2014 3:22 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Thu Jan 05, 2017 8:33 pm

I was trying to figure out how to get ffmpeg to use x264 when it occurred to me to look at how ffmpeg in trunk does, which led to the thought we just need to use the ffmpeg from trunk. So here's how you do this:

Get the files from trunk:

Code: Select all
cd feeds/packages/multimedia/ffmpeg/
rm Makefile Config.in
wget https://raw.githubusercontent.com/openwrt/packages/master/multimedia/ffmpeg/Makefile
wget https://raw.githubusercontent.com/openwrt/packages/master/multimedia/ffmpeg/Config.in

If you try to compile now a patch the old ffmpeg needs won't work so dump it:
Code: Select all
rm patches/050-Correctly_map_multichannel_ADTS-AAC.patch

Now do the same routine to get make menuconfig find the changes
Code: Select all
rm -rf tmp
./scripts/feeds/update -a
./scripts/feeds/install -a
make menuconfig

You'll need to set up extroot to have enough space to load it. It gets less than 1 fps but:

Code: Select all
root@OpenWrt:~# ffmpeg -i /tmp/gstreamer_sample_sorenson.mov -vcodec h264 -acodec aac -strict -2 {output}.mp4
ffmpeg version 2.8.8 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r49404)
  configuration: --enable-cross-compile --cross-prefix=mipsel-openwrt-linux-uclibc- --arch=mipsel --target-os=linux --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-static --enable-small --enable-pthreads --enable-zlib --disable-doc --disable-debug --enable-gpl --enable-version3 --disable-dxva2 --disable-lzma --disable-vaapi --disable-vda --disable-vdpau --disable-outdevs --disable-altivec --disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-mmxext --disable-sse --disable-sse2 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-avx --disable-xop --disable-fma3 --disable-fma4 --disable-avx2 --disable-inline-asm --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu --disable-runtime-cpudetect --disable-yasm --enable-libopus --enable-decoder=libopus --enable-libspeex --enable-decoder=libspeex --enable-libx264
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/gstreamer_sample_sorenson.mov':
  Metadata:
    creation_time   : 2001-02-19 16:45:54
    title           : QuickTime Sample Movie
    title-eng       : QuickTime Sample Movie
    copyright       : © Apple Computer, Inc. 2001
    copyright-eng   : © Apple Computer, Inc. 2001
  Duration: 00:00:05.00, start: 0.000000, bitrate: 131 kb/s
    Stream #0:0(eng): Video: svq1 (SVQ1 / 0x31515653), yuv410p, 190x240, 97 kb/s, 12 fps, 12 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2001-02-19 16:45:54
      handler_name    : Apple Alias Data Handler
      encoder         : Sorenson Video
    Stream #0:1(eng): Audio: qdm2 (QDM2 / 0x324D4451), 22050 Hz, stereo, s16, 32 kb/s (default)
    Metadata:
      creation_time   : 2001-02-19 16:45:54
      handler_name    : Apple Alias Data Handler
[libx264 @ 0xb2e940] using cpu capabilities: none!
[libx264 @ 0xb2e940] profile High, level 1.1
[libx264 @ 0xb2e940] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=12 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '{output}.mp4':
  Metadata:
    copyright-eng   : © Apple Computer, Inc. 2001
    title           : QuickTime Sample Movie
    title-eng       : QuickTime Sample Movie
    copyright       : © Apple Computer, Inc. 2001
    encoder         : Lavf56.40.101
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 190x240, q=-1--1, 12 fps, 12288 tbn, 12 tbc (default)
    Metadata:
      creation_time   : 2001-02-19 16:45:54
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc56.60.100 libx264
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 22050 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2001-02-19 16:45:54
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc56.60.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (svq1 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (qdm2 (native) -> aac (native))
Press [q] to stop, [?] for help
frame=   60 fps=1.0 q=26.0 Lsize=     119kB time=00:00:04.92 bitrate= 197.3kbits/s   
video:36kB audio:79kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.749397%
[libx264 @ 0xb2e940] frame I:2     Avg QP: 7.02  size:   145
[libx264 @ 0xb2e940] frame P:27    Avg QP:19.44  size:  1014
[libx264 @ 0xb2e940] frame B:31    Avg QP:18.65  size:   284
[libx264 @ 0xb2e940] consecutive B-frames: 23.3% 16.7% 20.0% 40.0%
[libx264 @ 0xb2e940] mb I  I16..4: 98.6%  0.6%  0.8%
[libx264 @ 0xb2e940] mb P  I16..4:  1.4%  2.8%  2.7%  P16..4:  9.5%  5.7%  4.3%  0.0%  0.0%    skip:73.6%
[libx264 @ 0xb2e940] mb B  I16..4:  0.1%  0.4%  0.2%  B16..8:  8.8%  5.0%  1.5%  direct: 1.9%  skip:82.1%  L0:36.9% L1:38.7% BI:24.4%
[libx264 @ 0xb2e940] 8x8 transform intra:21.6% inter:30.4%
[libx264 @ 0xb2e940] coded y,uvDC,uvAC intra: 28.1% 25.0% 24.3% inter: 6.9% 7.7% 4.3%
[libx264 @ 0xb2e940] i16 v,h,dc,p: 84%  6%  8%  2%
[libx264 @ 0xb2e940] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 23% 28%  3%  4%  7%  7%  7%  6%
[libx264 @ 0xb2e940] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 15% 24%  6%  9%  8%  6%  5%  5%
[libx264 @ 0xb2e940] i8c dc,h,v,p: 82%  8%  7%  4%
[libx264 @ 0xb2e940] Weighted P-Frames: Y:7.4% UV:0.0%
[libx264 @ 0xb2e940] ref P L0: 71.4% 10.5% 10.5%  6.5%  1.1%
[libx264 @ 0xb2e940] ref B L0: 91.7%  6.6%  1.7%
[libx264 @ 0xb2e940] ref B L1: 99.1%  0.9%
[libx264 @ 0xb2e940] kb/s:58.36
root@OpenWrt:~#

GinDiamond
 
Posts: 48
Joined: Thu Mar 31, 2016 11:02 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Thu Jan 05, 2017 9:31 pm

Thanks! I'll try this when I get home from work.

Looks promising!

GinDiamond
 
Posts: 48
Joined: Thu Mar 31, 2016 11:02 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Fri Jan 06, 2017 12:59 am

Hey! It works!

Thanks so much for all your help. Is there a way to get this out beyond the forum, like on the vocore wiki or something in case someone else wants to do this?


Also one more thing.


I couldn't help but notice one line in the ffmpeg makefile:

Code: Select all
--disable-mips32r2 \


After looking at /proc/cpuinfo and whatnot, I think that the vocore2 cpu supports this feature/instruction set/thing.

If enabled and configured, would this boost ffmpeg encoding/decoding speeds?

noblepepper
 
Posts: 240
Joined: Sat Nov 29, 2014 3:22 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Fri Jan 06, 2017 12:06 pm

I have no idea if mips32r2 works, you're breaking new ground, give it a try. If you want to be on the bleeding edge you can give my Lede repo a try, I try to keep it fairly close to the upstream Lede, just with addtitions for VoCore2. Before you compile it, check the WiFi speed on one of the precompiled images I have seen wide variation board to board, ranging from decent to abysmal. This is because it uses a still ongoing effort to use an open source driver.

To publish you are more than welcome to add to my WiKi. I started it for the VoCore1, I have just begun splitting it into two sections for the Vocore1 and VoCore2. But if anyone wants to post instructions there it could get moved but if it doesn't break other peoples toys, isn't offensive or blatantly commercial it is welcome.

I hoped it become a place that responses to new posts here about old problems could just a simple look at this page but saw few addtions. I totally understand why Vonger's WiKi isn't open to public editing, an active Wiki requires time to maintain.

There are many threads here that I plan to use to build more howto's on my WiKi but it just hasn't risen high enough on the priority list to get done.

GinDiamond
 
Posts: 48
Joined: Thu Mar 31, 2016 11:02 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Fri Jan 06, 2017 3:29 pm

Sure thing, I'll add this process to the wiki.

Another small thing. When you say I have to enable extroot, I have to add swap space, correct? With fstab? I already have a usb key mounted to / for lots of space. Do I need to add another partition for ram swapping?

noblepepper
 
Posts: 240
Joined: Sat Nov 29, 2014 3:22 pm

Re: VoCore2 + ffmpeg + h.264 encoding?

Fri Jan 06, 2017 4:44 pm

With 128m of ram I doubt you'll need swap and it wears out flash quickly. I can compile a gnu gcc toolchain with 128m ram, I had to set up swap for a device with 64m to get it to compile.

You can mount external storage anywhere you like but there are issues to deal with. As I understand it, parts of OpenWrt deal with the mtds directly and you can end up with really strange problems.

Extroot is the recommended way to get more storage.

PreviousNext
Return to VoCore2/Lite/Ultimate

Who is online

Users browsing this forum: No registered users and 45 guests