RPi Transcoding

rasplex

#3

There's one CODEC combination which always fails for me in RasPlex when using 'Direct Play' setting, but works fine when I force transcoding on by selecting a bitrate setting instead of "Direct Play". Apparently that enforces transcoding for everything, which in itself is a bug (it should only enforce transcoding for material with higher bitrate). But for me this bug is fortunate, as I would otherwise be forced to play these media files encoded to some crappy bitrate, just to make transcoding kick in.
 
Anyway, this 'Direct Play' failure occurs for my collection of 'Farscape (1999)' which uses CODECs as shown below (customized "MediaInfo" list):

-- File --: Farscape s01e01 Premiere.avi
Video #0  : 50mn 20s 684ms : 776 Kbps DivX 3 Low : 512x384 (1.333) @ 23.976 fps
Audio #0  : 50mn 20s 664ms : 96.0 Kbps CBR 'MPEG-1 Audio layer 3' in 2 ch @ 48.0 KHz

I'm pretty sure that it's the "DivX 3 Low" video CODEC that causes the problem, though I don't understand exactly why.
All normal DivX and XviD media work just fine, and on my PCs I've never had any problem with this show.
I suspect that the DivX/XviD CODEC implemented for the RPi is less generic, and doesn't include compatibility to old variants like 'DivX 3 Low'.
 
Best regards: dlanor


#4

Thanks dlanor.

Here is how I plan to implement transcoding on RPi and my first trials give really nice results :

Whatever is not identified as being natively played by Rpi will be transcoded by the server.

This will allow to DirectPlay the codecs natively supported (which is the purpose of the list above).

So what i really need to identify is the video / audio codecs that are supported natively by RPi.

In the list on the first post, i'll try to updated what the findings are (Hopefully will get some feedback from users :p ).

The RasPlex build will be updated with the codec list mentionned above :)

Ths idea would be to gather the supported format in order to avoid to unecessarrily transcode natively supported medias.


#5

I still use raspbmc, planning to try plex when you make the big release.  But just a note, I use 6-channel AAC and the RPi sends it to multi-channel LPCM correctly, so no need for a channel limitation on the aac entry.  If I learn differently on rasplex, I'll reply to this topic again.


#6

VC1 and MPEG2 should leverage DirectPlay if the licenses are added to the config.txt:

decode_MPG2=0x00000000
decode_WVC1=0x00000000

Verified they're actually enabled with:

vcgencmd codec_enabled MPG2
vcgencmd codec_enabled WVC1

Perhaps always have PMS DirectPlat these, but have some intelligence on the RasPlex side to turn DirectPlay off if the above commands don't indicate support for the formats.

The other option, would probably to setup two profiles for 4 profiles for the Rasperry Pi in DirectPlay, no licenses, mpg2, wvc1 and both.


#7

Not certain I fully understand the question so at the risk of making a fool of myself...

I rip videos using Make MKV (which preserves codecs). The only codec license on my RasPi is Mpeg-2 and I have no playback issues.

Dedicated audio files (music) are mostly FLAC and play without issues.


#8

There is no stupid question :)


Actually transcoding only works on video, so the question is mostly for videos :)


I have identifies i think the most common ones, but maybe i have missed a few. Also the maximum bitrate for transcoding is something i need to settle. As of now, 20 mbits would seem like a reasonnable limit, but if you guys have experience with higher bitrates working then we could reconsider this :)


#9

I have read various reports about results of directplay with DTS / DTS-HD using obviously dca codec.

From testing over a few samples, it seems that they are playing ok with DirectPlay.

I would be interested to have you feedback on this one.

If you are having troubles with it, I would like to have maybe a video sample so that i can figure out what can make it not work in certain cases and see if we can detect this and eventually transcode.


#10

The list looks good I think.  A couple of things:

  • What output container are you specifying?  I think MKV is probably best - it definitely works and supports all video/audio combinations.

  • I can confirm that video using the "old" DivX codec (codec ID DIVX3) doesn't work and therefore needs transcoding (but more recent MPEG4 implementations, eg. codec ID DIVX or XVID are fine).

  • FLAC multi-channel audio works fine too.  Maybe we should just always directplay audio - are there any audio formats which are unsupported?

When transcoding video the audio stream is presumably passed through if possible?  So eg. if my input file is mkv/mpeg2/dts then it'll pass through the audio and end up with mkv/h264/dts rather than mkv/h264/aac?


#11

I'm not sure how you plan to implement the direct play/transcode selection, but maybe you can have a default list and have a "simple" config file in /storage/.config with which the user can customize the behavior ?


#12

Well I am not sure yet on what the final implementation will be. Though I am not sure that a configuration file is required as choosing wether the RPi should use transcoding or not does not depend really on the user.

Its more depending on RPi capabilities, so i would think that this has to be static somehow.

The only thing that could still be configuable is the remote/local playback transcoding bitrate which can depend on the user configuration. There are already configuration fields for this in current PHT and i will keep these settings for whenever RasPlex would think it has to use transcoding.


#13

I think non-configurable logic for transcoding is right, if it takes into account:

  • Whether the user has MPEG2/VC1 licences installed
  • Whether the user has an AC3/DTS capable receiver

#14

hi,

i play mostly 1080P files with h264 and dd codec. i have experimented with dts (and dts-hd ma) but they only seem to cause me worry. mostly because dts has a tendancy to push the total file bandwidth over 20mbps and then it stutters.

if possible i would have pms transcode video if over 18mbps and transcode audio if over 1.5mbps. in an ideal world audio would be transcoded to something that supports 5.1, and in my particular case DTS at 640 kbps would be perfect.

thanks for lisenting !

- scott


#15

The list looks good I think.  A couple of things:

  • What output container are you specifying?  I think MKV is probably best - it definitely works and supports all video/audio combinations.
  • I can confirm that video using the "old" DivX codec (codec ID DIVX3) doesn't work and therefore needs transcoding (but more recent MPEG4 implementations, eg. codec ID DIVX or XVID are fine).
  • FLAC multi-channel audio works fine too.  Maybe we should just always directplay audio - are there any audio formats which are unsupported?

When transcoding video the audio stream is presumably passed through if possible?  So eg. if my input file is mkv/mpeg2/dts then it'll pass through the audio and end up with mkv/h264/dts rather than mkv/h264/aac?

Seems that most other clients use mpegts as container.

Yeah i can also confirm that flac is supported natively, although as ofnow , PMS will not use transcoding for audio, at least on PHT client.

It seems possible to only transcode the video or audio stream rather than transcode it all. If so that would be the best to avoid useless transcoding on audio streams.


#16

hi,

i play mostly 1080P files with h264 and dd codec. i have experimented with dts (and dts-hd ma) but they only seem to cause me worry. mostly because dts has a tendancy to push the total file bandwidth over 20mbps and then it stutters.

if possible i would have pms transcode video if over 18mbps and transcode audio if over 1.5mbps. in an ideal world audio would be transcoded to something that supports 5.1, and in my particular case DTS at 640 kbps would be perfect.

thanks for lisenting !

- scott

Well from my investigations, it seems that we can specifiy maximum bitrates for audio transcoding as for video transcoding. The main thing is going to define the threshold.

Thanks for sharign the values which are working nicely for you that will help defining the proper values i shold use.

Also one thing i didnt mention, if you can provide me some samples video links on files that would need to be transcoded that would be helpful to build up a test set.

Feel free to PM me some links to some media samples if you can :)


#17

I use a ReadyNas NV+v2 as my server which cannot transcode anything (cpu not powerfull enough)

All of my files though play natively on rasplex absolutely fine.

The highest bitrate video I have is 17mb with 1.5mb DTS audio track (plays perfectly)

I do have a DTS capable receiver though.

Most of my videos are h264 or x264 with either DTS or DolbyDigital soundtracks but I do have a few old xvid videos that also play perfectly.

Also I have it all run through a gigabit wired network.

Thanks


#18

Can't we just create a profile configuration for rasplex and place it in the Profiles folder of the PMS ?

How does rasplex identifies itself? Would the PMS recognize it as the correct client platform and load the appropriate profile ? 

A profile looks like this and seams to be exactly what this thread is about... 



  
    
      
      
    
    
      
    
    
    
  
  
    
    
    
  
  
    
      
        
        
        
      
    
    
      
        
      
    
    
      
        
        
        
      
    
  



#19

Yes building such a file is part of the transcoding implementation, but this is not enough as when using PHT as a client it will also require some implementation on the client side.


Basically the client has to decide wether it will use transcoding or not. As of now in pht, the only thing that will trigger transcoding is the preference settings which will either directplay everything or transcode everything.


So the right way to do this is to have pht decide if it should directplay or transcode. If it decides to transcode, then we need a profile on PMS to let PMS know what we want him to do.


There will be a specific profile file for RPi that will be built according to the results of this thread :)


#20

I have problems playing back DTS-ES The audio drops out every few seconds, this is with a DTS/DTS-ES/DTS-MA receiver 


#21

If you could PM me a link with some sample, i could try to test it and see what happens with transcoding :)


#22

OK here are some news of the progress.

I ended up with a working profile and client implementation.

As of now it seems to give very good results. it has though some constraints on which i'd like to pick your thoughts :)

So here is how it works :

When a media is played, RasPlex checks for the following conditions :

  • Is the video codec known ? (h264, mpeg4)
  • Is the audio codec known (aac, ac3, mp3, dca (DTS), flac) ?
  • Is the video bitrate reasonnable ( < 20 Mbits) ? 

-> If all these conditions are met, then it will trigger DirectPlay.

-> If any of those is not met, then it will trigger Transcoding.(see below)

Here is what transcoding does.

  • Video stream : if the video stream has a known codec (list above) and bitrate < 20 mbits, then it will just forward the stream, if not stream is transcoded to H264 with a maximum bitrate of 20 mbps
  • Audio stream : if the audio stream has a known codec (list above) and bitrate < 1.5 mbits  then it will just forward the stream, if not stream is transcoded to AAC with a maximum bitrate of 1.5 mbps

This allows to handle separately both streams so that you can only transcode video if audio is supported an has a proper bitrate.

The only thing that I would have liked is to be able to dynamically specify the bitrates from PHT.

Like on RPi the limitation seems to be more around a global bandwith, that is you can play a 7 Mbps audio stream if you are running a 10 mbps video stream. it wont work if you play a 20 Mbits video stream with a 7 mbits audio because of total bandwidth limitation.

The idea would have been to define bitrates so that Audio birate + Video bitrates remain behind a threshold, but it seems that as of now you can only cap video and audio bitrates to fixed threshold when transcoding.

So maybe the best we can do is define this limit to 20 Mbits for video and 1.5 Mbit for audio. This will downgrade a bit the audio when you would have a lower bitrate video, but i guess that should be ok.

Any thought / comment  about this is welcome :)