Why is my Plex transcoding to play on Chromecast?

Hi, everyone! I’m using a Raspberry Pi 2 as my Plex Media Server, casting using the Android app to my Chromecast Ultra. Most of my media streams directly, and that works perfectly well. However, sometimes it insists on transcoding; the Pi can’t keep up with the playback, and

I’ve been working around this by using the ‘optimized versions’ feature, but I’d prefer not to have to. Why is this transcoding, what’s wrong with my input files, and is this a bug in what Plex Media Server will or won’t send to a Chromecast?

Relevant avprobe output, before transcoding:

Input #0, matroska,webm, from '[video].mkv':
[...]
Stream #0.0: Video: h264 (Main), yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 fps, 1k tbn, 47.95 tbc (default)
Stream #0.1: Audio: aac, 44100 Hz, stereo, fltp (default)

After transcoding to ‘Optimized for TV’:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '[video].mp4':
Stream #0.0(und): Video: h264 (Main), yuv420p, 1280x720, 2594 kb/s, PAR 1:1 DAR 16:9, 23.98 fps, 16k tbn, 47.95 tbc (default)
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, fltp, 95 kb/s (default)

On the Pi, I looked at the transcoder process that was using all the CPU, and this was the full command line:

/usr/lib/plexmediaserver/Plex Transcoder -codec:0 h264 -i /mnt/TANK/[input].mkv \
  -filter_complex [0:0]scale=w=1280:h=720[0];[0]format=pix_fmts=yuv420p|nv12[1] \
  -map [1] -codec:0 libx264 -crf:0 16 -maxrate:0 4038k -bufsize:0 8076k -r:0 \
  23.975999999999999 -preset:0 veryfast -level:0 5.1 -x264opts:0 \
  subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none \
  -map 0:1 -codec:1 copy -copypriorss:1 0 -f segment -segment_format matroska \
  -segment_format_options live=1 -segment_time 1 -segment_header_filename header \
  -segment_start_number 0 -segment_list \
  http://127.0.0.1:32400/video/:/transcode/session/wuxca1uksklgvrk6o7lt1jhl/b4fb12a8-eb1e-4da6-895c-fbc0c9ebb6ae/seglist \
  -segment_list_type csv -segment_list_size 2147483647 \
  -segment_list_separate_stream_times 1 -avoid_negative_ts disabled -map_metadata \
  -1 -map_chapters -1 chunk-%05d -start_at_zero -copyts -y  -nostats -loglevel quiet \
  -loglevel_plex error -progressurl \
  http://127.0.0.1:32400/video/:/transcode/session/wuxca1uksklgvrk6o7lt1jhl/b4fb12a8-eb1e-4da6-895c-fbc0c9ebb6ae/progress

When you play a file you can go to now playing and hover over the playing item to show why it’s transcoding.

You can also search or grep for I believe MD in the log file to show you the full details of why it’s transcoding.

Ah, it’s sometimes converting AC3 audio to AAC audio (generally doable in realtime, since it’s just audio), and I’ll see if I can figure out what the other reason usually is. From the logs:

no direct play video profile exists for http/mkv/h264
no direct play video profile exists for http/mkv/h264/aac

I guess MKV isn’t covered by Chromecast supporting WebM files? That should be trivial to reencode, though; it’s just a new container, not a new codec.

I’ll update once I can reproduce the problem and dig into it more. Thank you for being so quick and helpful!

“Transcoding MPEG4 to H264”.

From the logs:

no direct play video profile exists for http/avi/mpeg4
no direct play video profile exists for http/avi/mpeg4/mp3
avoiding video remux due to potentially unsafe container/codec combination
no remuxable profile found, so video stream will be transcoded

It doesn’t even support MPEG4?! Gah.

Yeah I have a few Chromecast and they don’t have that great of codec support…

https://developers.google.com/cast/docs/media