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

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"

Related

How to specify how lossy/lossless a .webm conversion will be (in ffmpeg)?

I can't seem to understand how to make the conversion lossless (or at least visually lossless)? The outputs have some fast moving parts at times, and the output would become blocky; I would like to keep it as lossless as possible, while still maintaining some compression. What would I have to tweak at the command line? Thanks you~
ffmpeg -c:v libvpx-vp9 -i in.webm -c:v libvpx -vf scale=400:416,hue=h=45:s=1 -auto-alt-ref 0 out.webm
According to FFmpeg Wiki: VP9, "two-pass is the recommended encoding method for libvpx-vp9 as some quality-enhancing encoder features are only available in 2-pass mode". Example of your command:
ffmpeg -c:v libvpx-vp9 -i in.webm -c:v libvpx-vp9 -vf scale=400:416,hue=h=45:s=1 -b:v 0 -crf 30 -pass 1 -an -f null /dev/null
ffmpeg -c:v libvpx-vp9 -i in.webm -c:v libvpx-vp9 -vf scale=400:416,hue=h=45:s=1 -b:v 0 -crf 30 -pass 2 -c:a copy output.webm
The CRF value can be from 0–63. Lower values mean better quality. Recommended values range from 15–35, with 31 being recommended for 1080p HD video. For more info see Google - Getting Started with VP9.

PS4 can not play h264 video

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)

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

Seek issue of HEVC streams with ffplay

I'm attempting to perform a seek operation in an MPEG-TS stream that contains a HEVC encoded bit stream. The HEVC stream is encoded using the following command;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -x265-params crf=23:fps=30:keyint=10:min-keyint=10 -c:a copy -f mpegts testhevc.ts
The seek operation is attempted with ffplay as;
ffplay testhevc.ts -ss 5 -vf showinfo
The information shown gives multiple initial errors with missing POCs, such as;
Could not find ref with POC 126
However, everything works fine when the same operation is performed with H.264. The encoding with H.264/AVC is performed as;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -c:v libx264 -crf 23 -r 30 -keyint_min 10 -g 10 -c:a copy -f mpegts testh264.ts
Is this an issue with the ffmpeg tools for HEVC or am I missing something in these commands?.
Thanks.

encoding jpeg as h264 video

I am using the following command to encode an AVI to an H264 video for use in an HTML5 video tag:
ffmpeg -y -i "test.avi" -vcodec libx264 -vpre slow -vpre baseline -g 30 "out.mp4"
And this works just fine. But I also want to create a placeholder video (long story) from a single still image, so I do this:
ffmpeg -y -i "test.jpg" -vcodec libx264 -vpre slow -vpre baseline -g 30 "out.mp4"
And this doesn't work. What gives?
EDIT: After trying LordNeckbeards answer, here is my full output: http://pastebin.com/axhKpkLx
Example for a 10 second output:
ffmpeg -loop 1 -framerate 24 -i input.jpg -c:v libx264 -preset slow -tune stillimage -crf 24 -vf format=yuv420p -t 10 -movflags +faststart output.mp4
Same thing but with audio. The output duration will match the input audio duration:
ffmpeg -loop 1 -framerate 24 -i input.jpg -i audio.mp3 -c:v libx264 -preset slow -tune stillimage -crf 24 -vf format=yuv420p -c:a aac -shortest -movflags +faststart output.mp4
-loop 1 loops the image input.
-framerate sets the frame rate of the image input. Default is 25. Some players have issues with low frame rates so a value over 6 or so is recommended.
-i input.jpg the input.
-c:v libx264 the H.264 video encoder.
-preset x264 encoding preset. Use the slowest one you can.
-tune x264 tuning for various adjustments to fit specific situations.
-crf for quality. A lower value results in higher quality. Use the highest value that still provides an acceptable quality to you. Default is 23.
-vf format=yuv420p outputs the pixel format as yuv420p. This ensures the output uses a widely acceptable chroma sub-sampling scheme. Recommended for libx264 when encoding from images.
-c:a aac the AAC audio encoder. If your input is already AAC or M4A then use -c:a copy instead to stream copy instead of re-encode.
-t 10 (in the first example) makes a 10 second output. Needed because the image is looping indefinitely.
-shortest (in the second example) makes the output the same duration as the shortest input. In this case it is the audio since the image is looping indefinitely.
-movflags +faststart relocates the moov atom to the beginning of the file after encoding is finished. Allows playback to begin faster in progressive download playing; otherwise the whole video must be downloaded before playing.
-profile:v main (optional) some devices can't handle High profile.
See FFmpeg Wiki: H.264 for more info.

Resources