Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th January 2018, 12:57   #1  |  Link
n808
Registered User
 
Join Date: May 2003
Posts: 15
x265 pipe problem

On macOS and Windows, if I pipe y4m from ffmpeg to x265, x265 runs around 4-5x slower than on Linux on the same system. If I instead use ffmpeg to decode to y4m and then run x265 as two separate steps, it runs at "full speed".

example command:
ffmpeg -loglevel verbose -y -i input.mp4 -r 30/1 -threads 4 -t 20.000000 -pix_fmt yuv420p -f yuv4mpegpipe - 2> "ffmpeg.log" | x265 --input - --y4m --input-depth=8 --keyint=60 --ref=3 --bframes=4 --profile=main --preset faster --crf 26 -o "video.hevc"

Windows and macOS on Intel Core i5:
piped: ~4-5fps (top shows ~130% x265 cpu usage)
Linux VM on same system:
+20fps

Run as separate ffmpeg, then x265 on same macOS:
+20fps (top shows ~+350% x265 cpu usage)

Separate commands:
ffmpeg -loglevel verbose -y -i input.mp4 -r 30/1 -threads 4 -t 20.000000 -pix_fmt yuv420p -f yuv4mpegpipe out.y4m
x265 --input out.y4m --y4m --input-depth=8 --keyint=60 --ref=3 --bframes=4 --profile=main --preset faster --crf 26 -o "video.hevc"

Other examples that run way too slow (4-5fps) :
cat out.y4m | x265 --input - --y4m --input-depth=8 --keyint=60 --ref=3 --bframes=4 --profile=main --preset faster --crf 26 -o "video.mkv"
cat out.yuv | x265 --input - --input-res 1920x1080 --fps 30 --input-depth=8 --keyint=60 --ref=3 --bframes=4 --profile=main --preset faster --crf 26 -o "video.mkv"

Any ideas what I should be doing differently to get the piped version to run at full speed?

EDIT: problem solved - bug in x265, patch found on this page.

Last edited by n808; 10th January 2018 at 12:46.
n808 is offline   Reply With Quote
Old 10th January 2018, 09:14   #2  |  Link
Weyoun
Registered User
 
Join Date: Jul 2017
Posts: 11
Looks like a core/thread usage issue.
Weyoun is offline   Reply With Quote
Old 10th January 2018, 09:26   #3  |  Link
Weyoun
Registered User
 
Join Date: Jul 2017
Posts: 11
Where did your binaries come from?
Weyoun is offline   Reply With Quote
Old 10th January 2018, 12:43   #4  |  Link
n808
Registered User
 
Join Date: May 2003
Posts: 15
@Weyoun: tried both self-built and pre-built from MacPorts, but in any case, that was not the problem. I have run into a similar problem with x264 in the past, but it was fixed sometime around 1.5 years ago. It turns out x265 must still have the same(?) bug. A colleague found this patch from almost a year ago that apparently has not made it into the x265 code base. It completely resolves the problem, both for raw YUV and Y4M piped inputs to x265. Highly recommended for anyone needing piped input to work for macOS and Windows.
https://bitbucket.org/multicoreware/x265/issues/341

Last edited by n808; 10th January 2018 at 12:49.
n808 is offline   Reply With Quote
Old 13th January 2018, 16:17   #5  |  Link
Ma
Registered User
 
Join Date: Feb 2015
Posts: 290
Quote:
Originally Posted by n808 View Post
[...] A colleague found this patch from almost a year ago that apparently has not made it into the x265 code base. It completely resolves the problem, both for raw YUV and Y4M piped inputs to x265.
It's my fault that it is so long, sorry for that.

New patch that applies cleanly to current tip and should resolve the problem -- 19379.

There is one difference from previous patch -- in y4m input there was 3 reads per frame (fread 'FRAME', fgetc '\n', fread 'raw data'), now there are only 2 (fread 'FRAME\n', fread 'raw data').

Could you check if it works on your system and report back?
Ma is offline   Reply With Quote
Old 18th January 2018, 19:07   #6  |  Link
n808
Registered User
 
Join Date: May 2003
Posts: 15
Sorry for the delay - I will test this out tomorrow local time.
n808 is offline   Reply With Quote
Old 19th January 2018, 11:48   #7  |  Link
n808
Registered User
 
Join Date: May 2003
Posts: 15
Updated patch verified working as well as the previous. Looking forward to this getting into the main codebase, if that is indeed the plan..?
n808 is offline   Reply With Quote
Old 19th January 2018, 14:17   #8  |  Link
Ma
Registered User
 
Join Date: Feb 2015
Posts: 290
It's already committed as ver. 2.6+31 3712d13
Thanks for confirmation!
Ma is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.