Plex and Chromecast

It seems that everyone has their little magic transcoding line for having Plex and Chromecast to play nice, as everyone runs an underpowered server that cannot do live transcoding. My line follows here:

ffmpeg -i big_buck_bunny_720p_surround.avi -c:v libx264 -profile:v high -level 4.2 -crf 18 -maxrate 10M -bufsize 16M -pix_fmt yuv420p -vf "scale=iw*sar:ih, scale='if(gt(iw,ih),min(1920,iw),-1)':'if(gt(iw,ih),-1,min(1080,ih))'" -x264opts bframes=3:cabac=1 -movflags faststart -c:a libfdk_aac -b:a 320k -ac 2 -y big_buck_bunny_720p_stereo.mp4

The key points here are:

  • h.264 for video.
  • AAC for audio, I use stereo as I don’t use the Chromecast for my 5.1 setup.
  • Name the output *.mp4 to get an mp4 container.
  • -movflags faststart to “optimize for streaming”.

There are a number of similar magic lines floating around on the web, including on the plex forum. There is no way to tell which is the original, so I’ll let everyone Google around instead of explicitly giving credit to the thread I found first.

Some comments from my side:

  • Despite the Chromecast docs claiming to support h.264 level 5, the Chromecast.xml shipped with Plex limits the level to 4.2. Beware. This cost me an evening of transcoding.
  • ffmpeg has its own expression language with
    if, gt and min. Bloody amazing. I wonder if it does email.

Also, I learned that Big Buck Bunny consists of 14315 frames…