Go to the Settings > Power Save Settings > Set Time Until PS4 Turns Off. Select the General (Games) option and select after how much idle time your console will go off: After 1 Hour, After 2 Hours, After 3 Hours, After 4 Hours, or After 5 Hours.
Auto Shutdown Settings for Media Playback
If you would like to prevent your PlayStation 4 from shutting down while you are watching a movie, head back to Set Time Until PS4 Turns Off > Media Playback:
The auto shutdown settings for media playback can be adjusted separately.