Transcoding files for Playback on Playstation 4

For help and support with Universal Media Server in general
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
ps4guy69420
Posts: 2
Joined: Mon Aug 19, 2019 5:54 pm

Transcoding files for Playback on Playstation 4

Post by ps4guy69420 » Mon Aug 19, 2019 6:35 pm

Hi everyone,

I'm new here and don't know much about DLNA/UMS/media encoding, but do know my way around Linux a bit.

I am running a headless UMS server from a Raspberry pi 3b (Ubuntu 16.04), streaming to a Playstation 4 (most updated software version). I have 500+ movie files, the vast majority of which work flawlessly (much better than plex, I must say!!) with zero transcoding, as PS4 only accepts H.264 encoding and that is what most of my media is.

However, there are some .mp4 files which do not play on PS4 (mostly TV series) which are also seemingly H.264. With no transcoding, the PS4 says they do not play. When I try any of the available default transcoders (2 or so are shown on the Ps4 for every file), they still don't work. Specifically, the transcoders available by default are FFmpeg and MEncoder.

Here's an example mediainfo output of a file that does work:

General
Complete name : bad (mr robot s1e1).mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 1.87 GiB
Duration : 1 h 4 min
Overall bit rate mode : Variable
Overall bit rate : 4 131 kb/s
Encoded date : UTC 2015-07-03 23:49:20
Tagged date : UTC 2015-07-03 23:49:20
Writing application : Lavf55.47.100

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High L4.1
Format settings : CABAC / 6 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 6 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 4 min
Bit rate : 3 778 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.076
Stream size : 1.71 GiB (91%)
Writing library : x264 core 142 r2431
Encoding settings : cabac=1 / ref=6 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=18 / lookahead_threads=4 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=6 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=3778 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=24000 / vbv_bufsize=24000 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Language : English
Encoded date : UTC 2015-07-03 23:49:20
Tagged date : UTC 2015-07-03 23:49:20

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : mp4a-40-2
Duration : 1 h 4 min
Bit rate mode : Variable
Bit rate : 353 kb/s
Maximum bit rate : 384 kb/s
Channel(s) : 2 channels
Channel(s)_Original : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 161 MiB (8%)
Language : English
Default : Yes
Alternate group : 1
Encoded date : UTC 2015-07-03 23:49:20
Tagged date : UTC 2015-07-03 23:49:20


And a file that plays just fine:

General
Complete name : good (mrs doubtfire).mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/avc1)
File size : 996 MiB
Duration : 2 h 5 min
Overall bit rate mode : Variable
Overall bit rate : 1 113 kb/s
Encoded date : UTC 2014-08-12 22:02:52
Tagged date : UTC 2014-08-12 22:02:52

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High L4.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 2 h 5 min
Bit rate : 985 kb/s
Maximum bit rate : 6 175 kb/s
Width : 1 280 pixels
Height : 544 pixels
Display aspect ratio : 2.35:1
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.059
Stream size : 882 MiB (88%)
Writing library : x264 core 142 r2453 ea0ca51
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=4 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=985 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=62500 / vbv_bufsize=78125 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date : UTC 2014-08-12 22:02:52
Tagged date : UTC 2014-08-12 22:10:00

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : mp4a-40-2
Duration : 2 h 5 min
Bit rate mode : Variable
Bit rate : 124 kb/s
Maximum bit rate : 140 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 111 MiB (11%)
Language : English
Encoded date : UTC 2014-08-12 21:09:52
Tagged date : UTC 2014-08-12 22:10:00


This is kind of perplexing to me because both files are written with x264, but obviously I'm missing some thing(s). I am not sure what kind of transcoding settings I should set on my server to have the server encode the stream properly for the PS4. Does anyone have experience or expertise in doing this? Or advice for where I should start?

Thanks

Nadahar
Posts: 1479
Joined: Tue Jun 09, 2015 5:57 pm

Re: Transcoding files for Playback on Playstation 4

Post by Nadahar » Tue Aug 20, 2019 12:35 am

You need to start UMS with the "trace" command line argument, and then post the log file (debug.log) from when you try to play one of the files that don't work. This will show the decision process.

Regarding transcoding, I'm pretty sure that the RPi isn't anywhere close to have enough oomph to do that. If you want to be able to do transcoding, you'll probably have to use a "real computer" with a reasonable CPU as your server.

User avatar
SubJunk
Lead Developer
Posts: 2943
Joined: Sun May 27, 2012 4:12 pm

Re: Transcoding files for Playback on Playstation 4

Post by SubJunk » Thu Aug 22, 2019 2:40 pm

I think the PS4 only supports up to level 4.2 H.264, which means that at 1080p (see reference https://planetcalc.com/3321/), files are only allowed 4 reference frames. The "bad" file is using 6 reference frames, and the person who encoded it seems to have manually set the profile flag to "High L4.1".
In other words it really is a bad file :D

If it is a scene release it will have been nuked and a fixed version released. There are lots of other more standard files out there to choose from, I would recommend looking for the mkv filetype instead of mp4

ps4guy69420
Posts: 2
Joined: Mon Aug 19, 2019 5:54 pm

Re: Transcoding files for Playback on Playstation 4

Post by ps4guy69420 » Fri Aug 23, 2019 10:23 am

@SubJunk do you know the best way to convert it to 4 reference frames (i.e., any linux-friendly tools you use)? If it's easy enough I will just try doing that instead of redownloading/searching/etc.

Nadahar
Posts: 1479
Joined: Tue Jun 09, 2015 5:57 pm

Re: Transcoding files for Playback on Playstation 4

Post by Nadahar » Fri Aug 23, 2019 12:39 pm

You can reencode the file with FFmpeg, but you have to figure out the correct parameters. You can find tons of examples of FFmpeg parameters online. It will probably take a while though, depending on the power of your computer of course.

User avatar
SubJunk
Lead Developer
Posts: 2943
Joined: Sun May 27, 2012 4:12 pm

Re: Transcoding files for Playback on Playstation 4

Post by SubJunk » Fri Aug 23, 2019 3:03 pm

Personally I recommend using x264 https://www.videolan.org/developers/x264.html since it has good defaults - you can simply set a CRF (Constant Rate Factor) and leave everything at its default settings, and you'll get a high quality file. For 1080p I'd go with CRF 18-22, with 18 being highest quality and 22 being lowest, but still barely noticeable.
You can then use MKVToolnix to mux (muxing is when you swap streams across files without re-encoding them) the new video stream with the old audio stream, and end up with a .mkv file that will work https://mkvtoolnix.download/

I use a tool that automates those steps called MeGUI but it is Windows-only

Nadahar
Posts: 1479
Joined: Tue Jun 09, 2015 5:57 pm

Re: Transcoding files for Playback on Playstation 4

Post by Nadahar » Fri Aug 23, 2019 11:48 pm

@SubJunk I thought FFmpeg used the very same x264 encoder? Is it something I've missed, or are the defaults different when it's used standalone?

User avatar
Chuck_Arch_Ums
Posts: 13
Joined: Sun Sep 01, 2019 1:46 am

Re: Transcoding files for Playback on Playstation 4

Post by Chuck_Arch_Ums » Fri Sep 20, 2019 11:41 am

Just to clarify things, I'm using level 4.2 with 5 frames without problems, here is what can be played natively on PS4 (from Sony website)

Videos

When using a USB storage device, your video files need to be in a folder for your PS4™ system to recognize them.
You can view video recorded by a 360-degree omnidirectional camera (in equirectangular video format) on your PS VR. Press the OPTIONS button, and then select [VR Mode].

MKV
Video: H.264/MPEG-4 AVC High Profile Level 4.2
Audio: MP3, AAC LC, AC-3 (Dolby Digital)
AVI
Video: MPEG4 ASP, H.264/MPEG-4 AVC High Profile Level 4.2
Audio: MP3, AAC LC, AC-3 (Dolby Digital)
MP4
Video: H.264/MPEG-4 AVC High Profile Level 4.2, H.264/MPEG-4 AVC High Profile Level 5.2 (PlayStation®4 Pro only)
Audio: AAC LC, AC-3 (Dolby Digital), LPCM
MPEG-2 PS
Video: MPEG2 Visual
Audio: MP2 (MPEG2 Audio Layer 2), MP3, AAC LC, AC-3 (Dolby Digital), LPCM
MPEG-2 TS
Video: H.264/MPEG-4 AVC High Profile Level 4.2, MPEG2 Visual
Audio: MP2 (MPEG2 Audio Layer 2), AAC LC, AC-3 (Dolby Digital)
AVCHD (.m2ts, .mts)
XAVC S™ (.mp4)

Post Reply