PS4 can not play h264 video - ffmpeg

Summary
PS4 Media player can not play h264 mkv, avi or mp4 movies which were converted from HEVC. According the sony's [docs], the media player could be.
source
video: HEVC
audio: AC-3
converted
video: H264
audio: AC-3

Solutions
use ffmpeg in 8 bit depth.
ffmpeg -i source.mkv -c:v libx264 -crf 20 -profile:v high -level 4.2 -vf format=yuv420p output.mkv
the resolution must be less than 1080P
ffmpeg -i source.mkv -c:v libx264 -crf 20 -profile:v high -level 4.2 -vf format=yuv420p,scale=1920:-1 output.mkv //1080p (1920width × 1080height progressive scan)

Related

Mpeg1, vp9, theora and h264 intra lossless encoding strange results

I tried lossless intra coding of a few sequences including this one from xiph.org:
https://media.xiph.org/video/derf/y4m/foreman_qcif.y4m
and strangely mpeg1video wins by a great margin sizewise. I used FFmpeg with these settings:
ffmpeg -i foreman_qcif.y4m -c:v mpeg1video -qscale:v 0 -intra foreman.mpeg
ffmpeg -i foreman_qcif.y4m -c:v libx264 -crf 0 -intra foreman.mp4
ffmpeg -i foreman_qcif.y4m -c:v libvpx-vp9 -crf 0 -intra foreman.webm
ffmpeg -i foreman_qcif.y4m -c:v libtheora -qscale:v 10 -intra foreman.ogg
And the sizes I've got: mpeg1video - 2643968; theora - 2949677; vp9 - 5636841; h264 - 5743014;
So the question is: does mpeg1video really beats them all by such a margin in this mode ?
Apparently even on the max quality settings mpeg1video is far from being lossless. From ISO-IEC-11172-2_1991_MPEG1_Video:"algorithm is not lossless" and "The "quantizer size for the DC coefficients of the luminance and chrominance components is fixed at eight"

How to change audio frame rate in FFMPEG?

I am trying to change audio frame from 43.066 FPS (1024 SPF) to 23.438 FPS (2048 SPF) but no luck.
code tried :
ffmpeg -i 1.mp4 -b:v 2000k -vcodec libx264 -x265-params keyint=50:scenecut=0 -preset fast -pix_fmt yuv420p -profile:v main -level 3.1 -r 25 -s:v 1280x720 -ac 2 -c:a aac -b:a 128k -ar 48000 -aframes 23.438 HD2_500_500.mp4
Error :
Expected int64 for frames:a
You can change the audio speed using the ​atempo audio filter. The filter accepts exactly one parameter, the audio tempo. If not specified then the filter will assume nominal 1.0 tempo. Tempo must be in the [0.5, 100.0] range.
Here a simple example on how to speed down the audio by half:
ffmpeg -i 1.mp4 -filter:a "atempo=0.5" -vn HD2_500_500.mp4

How to optimize RTMP AAC transcoding with (or without) FFMPEG?

I do use NginxRTMP to generate HLS.
Problem is that HLS has not sound (since it needs AAC)
I try to trancode my RTMP sound to AAC sound with FFMPEG
exec_push ffmpeg -i rtmp://localhost/src/$name -vcodec libx264 -threads 0 -vprofile baseline -preset ultrafast -s 800x600 -acodec libfaac -ar 44100 -f flv rtmp://localhost/hls/$name
Problem: it takes 25% of CPU per stream.
Any idea on how to optimize that ?

Video codec specs through ffmpeg (not being achieved)

The specs for the video format are the following:
Aspect Ratio: 1:1
H.264 video compression, high profile, square pixels, fixed frame rate, progressive scan
.mp4 container with leading mov atom, no edit lists
Audio: Stereo AAC audio compression, 128kbps +
Reading through posts and ffmpeg documentation I came up with the following (yeah, I run it on a Windows PC):
ffmpeg.exe -r 30 -i input.webm -vf scale=iw*sar:ih -c:v libx264 -preset slow -profile:v high -c:a aac -strict experimental -ar 44100 -aspect 1:1 output.mp4
But when the video is played within the app that asks for this specification, it only displays black moving pixels, all broken, but you an hear the audio.
I don't really know what else to change on the command, and I have no idea in regards to the ...with leading mov atom specification.
Thanks.
EDIT:
I've tried #Mulvya's answer:
ffmpeg.exe -i input.webm -vf scale=iw*sar:ih,setsar=1 -c:v libx264 -preset slow -profile:v high -pix_fmt yuv420p -r 30 -c:a aac -strict experimental -ar 44100 -ac 2 -b:a 128k -movflags +faststart output.mp4
But the effect is the same once given to the app:
This is the information that ffmpeg spews about the input.webm file:
Use
ffmpeg.exe -i input.webm -vf scale=iw*sar:ih,setsar=1 -c:v libx264 -preset slow -profile:v high -pix_fmt yuv420p -r 30 -c:a aac -strict experimental -ar 44100 -ac 2 -b:a 128k -movflags +faststart output.mp4
Depending on how strict the app is, you may need to check the precise framerate. Use -r 30000/1001 for 29.97. The -movflags +faststart moves the moov atom to the front of the file.
Based on info I found elsewhere, this seems to be what Instagram requires:
ffmpeg.exe -i input.webm -vf scale=640:640,setsar=1 -c:v libx264 -preset slow -profile:v main -level 3.1 -pix_fmt yuv420p -r 30000/1001 -c:a aac -strict experimental -ar 44100 -ac 1 -b:a 64k -t 15 -movflags +faststart output.mp4

Encoding YUV to mP4 With qp to get max quality

I am trying to encode my YUV420 Raw format file into mp4. Here is the ffmpeg command
ffmpeg -f s16le -ar 44100 -ac 1 -i "0.a" -f rawvideo -pix_fmt yuv420p -s 480x480 -r 30 -i "0.v" -vcodec libx264 -profile:v baseline -preset ultrafast -qp 0 -b:v 1024k -g 30 -acodec libfdk_aac -ar 44100 -ac 1 -b:a 64k -f mp4 -movflags faststart "1438947231095.mp4"
If i remove qp = 0; it works however the quality is very low not sure why. If i put qp = 0 it doesn't work, What is wrong?
Getting this error
Error while opening encoder for output stream #0:0 - maybe incorrect parameters
The baseline profile doesn't support lossless H.264. You must use the High 4:4:4 Predictive profile instead:
-profile:v high444

Resources