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.
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:
- A maximum width of 1920px.
- YUV 4:2:0 pixel format.
- A maximum H264 profile of 'High'
- A maximum H264 level of 4.2
- 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.