Log in

View Full Version : ffmpeg command to pipe a mkv/mp4 file into x265 in realtime as a yuv


H2sixty
6th October 2020, 08:12
[for windows add .exe to ffmpeg and x265, ffmpeg.exe x265.exe]
(i do not have windows to test these, i replaced it with debian linux)


8bit input--\/
ffmpeg -i "input.file" -f yuv4mpegpipe - | x265 --y4m - -o "outputfile.265"



10bit input--\/
ffmpeg -i "input.file" -f yuv4mpegpipe -strict -1 - | x265 --y4m - -o "outputfile.265"

(use -strict -1 or else y4m will want to interpret the input as 8-bit 420)



12bit input--\/
ffmpeg -i "input.file" -f -pix_fmt yuv420p12le yuv4mpegpipe -strict -1 - | x265 --y4m - -o "outputfile.265"



ffmpeg can automatically detect pixel format from input file. so -pix_fmt "pixel format (yuv420p etc)" input option isn't needed unless input is rawvideo... but if needed use -pix_fmt with a choosen pixel format from below...

other inputs/pix_fmt--\/

yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p gbrp yuv420p10le yuv422p10le yuv444p10le gbrp10le yuv420p12le yuv422p12le yuv444p12le gbrp12le gray gray10le gray12le

(use with -strict 1 to force/allow choosen pix_fmt)
-
-
-
for a list of x265 {not ffmpeg} supported pixel formats use command below
ffmpeg -h encoder=libx265 2>/dev/null | grep pixel
{for ffmpeg see selurs post}

-

-------------------------------------------
-------------------------------------------
-------------------------------------------
thanks to excellentswordfight for info.
"ffmpeg.exe" -i "input" -f yuv4mpegpipe -strict -1 - | "x265.exe"

In some scenarios you will need to change the format before piping (-pix_fmt)

Selur
6th October 2020, 08:24
ffmpeg can automatically detect pixel format from input file. so -pix_fmt "pixel format (yuv420p etc)" input option isn't needed unless input is rawvideo...
.. or you want/need a color conversion

ffmpeg -h encoder=libx265 2>/dev/null | grep pixel
that lists the pixel formats supported by libx265 not the pixel formats supported by ffmpeg to get those use:
ffmpeg -pix_fmts

Cu Selur

H2sixty
6th October 2020, 08:51
got this from https://gist.github.com/tayvano/6e2d456a9897f55025e25035478a3a50
to clarify the -strict command.
its not very clear, doesn't give the numbers...

-strict ED.VA… how strictly to follow the standards (from INT_MIN to INT_MAX) (default 0)
very ED.V…. strictly conform to a older more strict version of the spec or reference software
strict ED.V…. strictly conform to all the things in the spec no matter what the consequences
normal ED.V….
unofficial ED.V…. allow unofficial extensions
experimental ED.V…. allow non-standardized experimental things

H2sixty
6th October 2020, 08:56
thank you Selur. i wanted to gather up the info on piping in one place.

Selur
6th October 2020, 09:36
got this from https://gist.github.com/tayvano/6e2d456a9897f55025e25035478a3a50
just to be sure here's a reference to the ffmpeg source:
2531 /**
2532 * strictly follow the standard (MPEG4, ...).
2533 * - encoding: Set by user.
2534 * - decoding: Set by user.
2535 * Setting this to STRICT or higher means the encoder and decoder will
2536 * generally do stupid things, whereas setting it to unofficial or lower
2537 * will mean the encoder might produce output that is not supported by all
2538 * spec-compliant decoders. Decoders don't differentiate between normal,
2539 * unofficial and experimental (that is, they always try to decode things
2540 * when they can) unless they are explicitly asked to behave stupidly
2541 * (=strictly conform to the specs)
2542 */
2543 int strict_std_compliance;
2544 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2545 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2546 #define FF_COMPLIANCE_NORMAL 0
2547 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2548 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. source: https://ffmpeg.org/doxygen/2.7/libavcodec_2avcodec_8h_source.html

Cu Selur