Encoding playable SDR files for the PS4

Encoding playable SDR files for the PS4

The PS4 Media Player supports a limited set of codecs and limited codec/container combinations.
Below is an approximation of what I have found succesful via experimentation and internet-searching for my Blu-Ray backups.

FFMPEG

Apart from bitrate/crf-value/tune-opt, this will create the highest possible quality video that will still play succesfully.

        ffmpeg -i "$input_file" \
          -vf zscale=w=1920:h=-2:f=lanczos \
          -pix_fmt yuv420p \
          -c:v libx264 -profile:v High -level:v 4.2 -crf $crf_value -bf 2 \
          -c:a ac3 -b:a $bitrate \
          -movflags faststart output.mp4
      
The key take-aways for the video aspect are:
  1. A maximum width of 1920px.
  2. YUV 4:2:0 pixel format.
  3. A maximum H264 profile of 'High'
  4. A maximum H264 level of 4.2
  5. A maximum of 2 B-frames
Frame-rate may possibly have restrictions, but Blu Rays are typically 24-30fps (after deinterlacing).
For audio, I have not found any particular restrictions w.r.t sample-rate, depth, channel-count + bitrate, but this is most likely because I have not used anything greater than 48KHz, 6 channels and 320k.

Caveats

MPEG-2 video, and quite possibly MPEG4-part 2 (xvid, divx, etc), are supported, but why bother.
If you are trying to limit file-size, aac-lc instead of ac3 can be used.
Matroska file format is supported.

Extras

So far, there are 2 things not mentioned up until now:
  1. HDR
  2. Subtitles
HDR will be a follow up post.
Subtitles have been a pain and I have yet to get to grips with what is possible. PGS are OK and others may be an option (but definetly not dvd_sub).