Jump to content

Odroid C2 and hardware x265 decoding/transcoding


johnvick

Recommended Posts

johnvick

Hi all,

 

I have Emby running nicely on an Odroid XU4 with most media playing by direct streaming from a QNAP. I sometimes send video to an ipad mini which needs transcoding and this can max out the XU4.

 

My question is, if I run Emby from an Odroid C2 which has hardware x265 decoding will Emby's transcoding engine use the hardware to do some of the work?

 

Thanks, John 

Link to comment
Share on other sites

Hi @@johnvick, I am guessing you will want to select the "VA API" hardware transcoding method in server transcoding settings.

 

Let us know if this helps. Thanks !

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
nwcatalyst

Another admin (hurricane hernandez?) mentioned that VA-API does not work on ARM devices. I can confirm that I could not get this to work on my C2. He suggested Open Max, which was also not a viable option after further research. See here: http://forum.odroid.com/viewtopic.php?f=136&t=24293

Someone in the hardkernel forums created a simple transcoding program that we might be able to utilize...

Team Emby, can you guys create a way for us C2 users to get this running? I feel like this little board would be the ultimate budget Emby box if we could tap into the decent GPU it has... http://forum.odroid.com/viewtopic.php?f=136&t=24293

Thanks!
 

Link to comment
Share on other sites

nwcatalyst

Sorry, I should have been more clear.

I have emby up and running on my ODROID C2 running a variant of Debian 8 (DietPi). Emby works fine, except for transcoding support on this Amlogic ARM device. This is critical for me as I have low upstream bandwidth for remote streaming and a few devices which will not natively play mkv. 

You've suggested VA-API which as I understand is not avail for ARM, and Open Max (from Hernandez suggestion) is not avail on this Amlogic board... Can you guys look into an option for us?

I posted a while back that team Kodi is able to tap into the hardware video chip for transcoding, and I would be super stoked if the emby team could get transcoding to work on this little thing. I think it has enough to transcode a single 1080p stream at 4-5Mbps, which is plenty for my taste, and would make this a really epic $40 emby server that you guys could promote...

Link to comment
Share on other sites

nwcatalyst

Kodi only does decoding and render. It doesn't encode, hence it doesn't transcode. Render is also a Amlogic black box: http://forum.kodi.tv/showthread.php?tid=258707&pid=2309750#pid2309750

Thanks for clarifying that. Perhaps it goes without saying that this is not my day job and is quite a new hobby :)

 

Do you have any insight as to whether this will *ever* be possible?

Link to comment
Share on other sites

We'd have to look at what the GPU transcoding options are for that device, and whether ffmpeg supports any of them.

Link to comment
Share on other sites

nwcatalyst

This is what has been done over at hardkernel: 

Is this enough? 
 

The following program takes NV12 data on stdin and outputs H264 on stdout. This allows the hardware encoding capabilities to be used with FFMpeg.

https://github.com/OtherCrashOverride/c2enc

The following mandatory parameters are accepted by c2enc:
-w, --width = the width of the NV12 image
-h, --height = the height of the NV12 image
-f, --fps = the frame rate of the video (Only used for maintaining bitrate. It does not need to be exact.)

The following optional parameters are accepted by c2enc:
-b, --bitrate = the desired bitrate of the H264 stream
-g, --gop = the Group Of Pictures setting of the H264 stream

 

Link to comment
Share on other sites

Andy777

This is what has been done over at hardkernel: 

 

 

Nice. AMlogic and/or HK has provided the decoding part in their own ffmpeg fork, and the guy in the forums has the first implementation of the hw-encoding.

 

What is needed now, is somebody that have skills and will to take all that upstream to official ffmpeg and most likely also willing to maintain that part of ffmpeg.

 

Do I see it likely to happen? Well, it took years to get hw-transcoding to RasPi with a way larger community. It'll take months even with a skilled and willing maintainer to get Odroid code included to ffmpeg.

 

No-one knows. Currently there is no person willing and capable of doing that, but in the end, it only takes one. 

BR,

A

  • Like 1
Link to comment
Share on other sites

nwcatalyst

Got it. Thank you for the info. I am starting to understand the world of open source development a bit better with each of these threads.

I will plug the crew over there to see if anyone has the capacity/willingness to get this started.

Do bounties ever help for projects like this? Or are those more fitting for other types of dev work?

Link to comment
Share on other sites

nwcatalyst

Ok, so apparently this should be a lot simpler than going upstream to ffmpeg. From this thread:

 

 

 

Its going to be a lot simpler, cheaper, and faster to just add support to emby. This is likely the place to start:
https://github.com/MediaBrowser/Emby/blob/master/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs

The goal is to add c2enc to the command line the code generates. The program already constructs a ffmpeg command line. All that is needed is to "extend" it to pipe the video through c2enc as described in this topic. An experienced emby developer should be able to do it in a few minutes should they desire.

Is this accurate?

@@Luke would love to get someone to plug this in especially if it is only a few mins for a team member.

Thanks,

Link to comment
Share on other sites

nwcatalyst

.. I think so? This is the sample code from the developer:
 

ffmpeg -i YourMediaFile.mkv -an -f rawvideo -pix_fmt nv12 - | ./c2enc -w 1280 -h 720 -f 30 > test.h264
Link to comment
Share on other sites

Ok, so, that's not really a quick thing. It's doable but it will take some work. Unless I'm mistaken, it looks like c2enc is outputting just the h264 video? so that means we have to then feed that output back into ffmpeg in order to package it into whatever output container is being requested by client device. Unless I'm misunderstanding.

Link to comment
Share on other sites

nwcatalyst

@@Luke ok, well, I've asked the developer to confirm if it indeed is just the h264 video output. 

As an emby premiere lifetime supporter I would love to see this added to the roadmap for inclusion. Not sure how much coding time this requires, but I suppose this is my biggest request and if I were ever going to cash in on that purchase with a unique request, this is it :) 

Thanks al,

Link to comment
Share on other sites

I am guessing it is based on his sample having an output extension of .h264. It's probably better that way to be honest.

Link to comment
Share on other sites

nwcatalyst

@@Luke sounds like you are right. Here is the developer's reply:

 

 

 

It depends on what you want to do with the video stream. For transcoding, it should be fed into ffmpeg or any other mux of your choice.

Re-post from earlier in this thread:
CODE: SELECT ALL ffmpeg -i big_buck_bunny_720p_stereo.avi -an -f rawvideo -pix_fmt nv21 - | c2enc -w 1280 -h 720 -f 24 -b 2000000 | ffmpeg -r 24 -i - -i big_buck_bunny_720p_stereo.avi -c:v copy -map 0:v:0 -map 1:a:0 -acodec copy bbb.mp4
1) ffmpeg decodes the video bit stream to NV21
2) c2enc encodes the NV21 to H264.
3) ffmpeg muxes the H264 and the original audio stream into a mp4 file.

I stated it is trivial because all that is required is to replace "big_buck_bunny_720p_stereo.avi" in the above command line with the file you wish to transcode. The only additional information needed is the video size and frame rate from ffmpeg:
CODE: SELECT ALL ffmpeg -i %1 -an -f rawvideo -pix_fmt nv21 - | c2enc -w %3 -h %4 -f %2 -b 2000000 | ffmpeg -r %2 -i - -i %1 -c:v copy -map 0:v:0 -map 1:a:0 -acodec copy %1.mp4
In the above example:
%1 = filename
%2 = FPS
%3 = Width
%4 = Height

You can also change "-b 2000000" to the H264 bitrate of your preference.

So.. can we add this to the roadmap? 

Link to comment
Share on other sites

Please open a new topic in the feature requests section and that will help us get an idea of what the demand is for it. Thanks !

Link to comment
Share on other sites

  • 3 weeks later...
memeka

I wonder if this can actually be done very simple by just adding a new encoder, and in the encoder options just adding the pipe to c2enc.

 

E.g. just like libx264 encoder adds

 

param = "-pix_fmt yuv420p " + param;

 

then would it work for the c2encoder to add

 

param = "-pix_fmt nv21 - | c2enc -w %3 -h %4 -f %2 -b 2000000 | ffmpeg -r %2 -i - -i %1 -c:v copy -map 0:v:0 -map 1:a:0 -acodec copy " + param;

 

?

 

Just a thought. (I know it's not a nice solution :P)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...