VideoHelp Forum




+ Reply to Thread
Results 1 to 19 of 19
  1. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    hello everyone!

    I have a problem to do a 2pass encoding with ffmpeg (latest zeranoe build).

    those are my command lines:

    1st pass

    Code:
    "H:\Project\Suite HEVC\bin\Release\data\bin64\ffmpeg.exe" -hwaccel auto -i "H:\video\Interstellar IMAX.mkv" -map 0:v:0 -c:v libx265 -pass 1 -b:v 5000k -preset 5 -x265-params level=0:profile=undefined:pmode:no-pme:pme:no-high-tier:ref=3:bframes=4:open-gop:keyint=250:min-keyint=25:b-adapt=2:bframe-bias=0:rc-lookahead=20:no-scenecut:b-pyramid:me=hex:subme=2:merange=57:temporal-mvp:weightp:no-weightb:max-merge=2:no-weightb:no-rect:no-amp:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.9:no-slow-firstpass:no-strict-cbr:qcomp=0.6:qstep=4:aq-mode=1:aq-strength=1.0:cutree:no-early-skip:ctu=64:no-fast-cfb:ipratio=1.4:pbratio=1.3:cbqpoffs=0:crqpoffs=0:rd=3:psy-rd=0.3:psy-rdoq=1:b-intra:no-fast-intra:rdoq-level=1:no-tskip:no-tskip-fast:cu-lossless:tu-intra-depth=1:tu-inter-depth=1:strong-intra-smoothing:no-constrained-intra:nr-intra=0:nr-inter=0:qblur=0.5:cplxblur=20:signhide:sar=16:stats="H:\video\Interstellar IMAX.stats" -f null -
    2nd pass

    Code:
    "H:\Project\Suite HEVC\bin\Release\data\bin64\ffmpeg.exe" -hwaccel auto -i "H:\video\Interstellar IMAX.mkv" -map 0:v:0 -c:v libx265 -pass 2 -b:v 5000k -preset 5 -x265-params level=0:profile=undefined:pmode:no-pme:pme:no-high-tier:ref=3:bframes=4:open-gop:keyint=250:min-keyint=25:b-adapt=2:bframe-bias=0:rc-lookahead=20:no-scenecut:b-pyramid:me=hex:subme=2:merange=57:temporal-mvp:weightp:no-weightb:max-merge=2:no-weightb:no-rect:no-amp:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.9:no-slow-firstpass:no-strict-cbr:qcomp=0.6:qstep=4:aq-mode=1:aq-strength=1.0:cutree:no-early-skip:ctu=64:no-fast-cfb:ipratio=1.4:pbratio=1.3:cbqpoffs=0:crqpoffs=0:rd=3:psy-rd=0.3:psy-rdoq=1:b-intra:no-fast-intra:rdoq-level=1:no-tskip:no-tskip-fast:cu-lossless:tu-intra-depth=1:tu-inter-depth=1:strong-intra-smoothing:no-constrained-intra:nr-intra=0:nr-inter=0:qblur=0.5:cplxblur=20:signhide:sar=16:stats="H:\video\Interstellar IMAX.stats" -map 0:a:0 -c:a copy -map 0:a:1 -c:a copy -map 0:a:2 -c:a copy -map 0:s:0 -c:s copy -map 0:s:1 -c:s copy "H:\video\outputtest.mkv"
    i have 2 question:

    1. Will declaring a preset cause problem if overrided with params?
    2. With those command line there is no output of the .stats file in the first pass. the encode works fine but it's live a ABR mode. how can i correctly declare output path for stats?

    can someone please help me to get first and second pass working correcly?

    thanks to everyone who will reply!

    P.S.

    I'm very happy if someone has even suggestions/improvements for this code
    Last edited by z-machine95; 30th Apr 2015 at 05:02.
    Quote Quote  
  2. Will declaring a preset cause problem if overrided with params?
    There is no problem overriding a preset, but if you overwrite all of it's settings why use it in the first place.

    About the stats file are you sure ffmpeg even supports the stats option the way you use it?
    shouldn't you use:
    Code:
    -passlogfile "path to log file"
    and even then I'm not sure that ffmpeg does support 2pass x265 encoding at all
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  3. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    Originally Posted by Selur View Post
    Will declaring a preset cause problem if overrided with params?
    There is no problem overriding a preset, but if you overwrite all of it's settings why use it in the first place.

    About the stats file are you sure ffmpeg even supports the stats option the way you use it?
    shouldn't you use:
    Code:
    -passlogfile "path to log file"
    and even then I'm not sure that ffmpeg does support 2pass x265 encoding at all
    Yes i have Tried even with passlogfile... But The .log file when The encoding is ended is empty
    Quote Quote  
  4. Like I wrote, I suspect that ffmpeg doesn't support 2pass encoding using libx265.
    -> I would recommend to post into their bug tracker https://trac.ffmpeg.org/ (or ask inside their IRC channel over at FreeNode IRC #ffmpeg)
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  5. Why don't you just use the x265 cli encoder?
    Quote Quote  
  6. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    Originally Posted by jagabo View Post
    Why don't you just use the x265 cli encoder?
    I would like to use only ffmpeg (I'm making a GUI)... there is a reason of course... if it's not possible I will try to generate command line for a pipe ffmpeg and x265..
    Quote Quote  
  7. Perhaps putting the 'pass' parameters into the -x265-params section?
    I might be wrong here but.. why do you use 'no-slow-firstpass' in the second pass too?

    ffmpeg -h encoder=libx265
    -crf <float> E..V.... set the x265 crf (from -1 to FLT_MAX) (default -1)
    -preset <string> E..V.... set the x265 preset
    -tune <string> E..V.... set the x265 tune parameter
    -x265-params <string> E..V.... set the x265 configuration using a eparated list of key=value parameters
    Quote Quote  
  8. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    When I implemented 2pass encoding i FFQueue I learned that using "null" target (no output file) in the first pass caused the encoding to fail. Try to avoid null target and specify a file name instead.
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  9. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    I've just run a test encode using 2pass and x265 - no problemo!

    First pass:
    Code:
    -hide_banner -i "Dummy.mp4" -map 0:0 -c:v libx265 -b:v 1000k -pass 1 -passlogfile "C:\Temp\ffqueue_ffmpeg_multipass" -an -y "Dummy_x265.mp4"
    Second pass:
    Code:
    -hide_banner -i "Dummy.mp4" -map 0:0 -map 0:1 -c:v libx265 -b:v 1000k -c:a copy -pass 2 -passlogfile "C:\Temp\ffqueue_ffmpeg_multipass" -y "Dummy_x265.mp4"
    EDIT: Try to replace the last "-" in your first pass command with "NUL". By doing this it also works for me with null file:

    Code:
    "H:\Project\Suite HEVC\bin\Release\data\bin64\ffmpeg.exe" -hwaccel auto -i "H:\video\Interstellar IMAX.mkv" -map 0:v:0 -c:v libx265 -pass 1 -b:v 5000k -preset 5 -x265-params level=0:profile=undefined:pmode:no-pme:pme:no-high-tier:ref=3:bframes=4:open-gop:keyint=250:min-keyint=25:b-adapt=2:bframe-bias=0:rc-lookahead=20:no-scenecut:b-pyramid:me=hex:subme=2:merange=57:temporal-mvp:weightp:no-weightb:max-merge=2:no-weightb:no-rect:no-amp:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.9:no-slow-firstpass:no-strict-cbr:qcomp=0.6:qstep=4:aq-mode=1:aq-strength=1.0:cutree:no-early-skip:ctu=64:no-fast-cfb:ipratio=1.4:pbratio=1.3:cbqpoffs=0:crqpoffs=0:rd=3:psy-rd=0.3:psy-rdoq=1:b-intra:no-fast-intra:rdoq-level=1:no-tskip:no-tskip-fast:cu-lossless:tu-intra-depth=1:tu-inter-depth=1:strong-intra-smoothing:no-constrained-intra:nr-intra=0:nr-inter=0:qblur=0.5:cplxblur=20:signhide:sar=16:stats="H:\video\Interstellar IMAX.stats" -f null NUL
    Last edited by TorBru; 2nd May 2015 at 10:32.
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  10. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    with -f null NUL it's created a .log file in specified path but it's empty again.... stats-0.log (0 byte) i have even remove ffmpeg.exe block (windows block every executable files downloaded from internet)

    if i declare an output same thing... I cannot run FFmpeg as administrator cause crashes at start .... if i declare C:\ as log output path ffmpeg give me a write error.. permission denied..

    but i work only in H: drive so I shouldn't have permission problems...

    maybe I will try to do a much simple commands... just to see if there is another problem

    what version do you use? i use static 64 bit latest zeranoe build... maybe that's the problem
    Last edited by z-machine95; 2nd May 2015 at 12:00.
    Quote Quote  
  11. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    I've tested again. The log file created during first pass is empty. It seems like there's absolutely no difference in running 2pass or 1pass encoding. Have you checked the "stats" file (H:\video\Interstellar IMAX.stats) after first pass? Does it exist? I'm not sure but it seems like x265 uses the stats file and not the "passlogfile" to calculate the qp..
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  12. Yes there is a difference - you need to specify the stats with x265-params . "pass 2" will not overwrite it

    e.g

    Code:
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 1 -x265-params pass=1:stats="mylog.log" -f mp4 NUL -y
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 2 -x265-params pass=2:stats="mylog.log" "output.mp4"

    You can verify because mediainfo will report the differences , and the file will be different (filesize is different between 1pass ABR)
    Quote Quote  
  13. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Yes there is a difference - you need to specify the stats with x265-params . "pass 2" will not overwrite it

    e.g

    Code:
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 1 -x265-params pass=1:stats="mylog.log" -f mp4 NUL -y
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 2 -x265-params pass=2:stats="mylog.log" "output.mp4"

    You can verify because mediainfo will report the differences , and the file will be different (filesize is different between 1pass ABR)
    first thanks guys for helping me!

    second I will try this.. my first attempt was something like that but without -f null NUL and -pass 1

    fingercrossed...

    EDIT:

    does not work even with this command line... zeranoe build works for you?
    logfile must be declared as .log with a unix style path or work good as i wrote?
    Last edited by z-machine95; 2nd May 2015 at 14:49.
    Quote Quote  
  14. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    i followed poisondeathray tips but still not produce a log file..

    maybe i have to declare path with .log extension? someone told me that log pass file path declaration must be formatted in unix style.. it's true?

    here are my command lines updated

    Code:
    1st pass
    
    "H:\Project\Suite HEVC\bin\Release\data\bin64\ffmpeg.exe" -hwaccel auto -i "H:\videotest\test.mkv" -map 0:v:0 -c:v libx265 -pass 1 -b:v 5000k -preset 5 -x265-params level=0:profile=undefined:pmode:no-pme:pme:no-high-tier:ref=3:bframes=4:open-gop:keyint=250:min-keyint=25:b-adapt=2:bframe-bias=0:rc-lookahead=20:no-scenecut:b-pyramid:me=hex:subme=2:merange=57:temporal-mvp:weightp:no-weightb:max-merge=2:no-weightb:no-rect:no-amp:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.9:no-slow-firstpass:no-strict-cbr:qcomp=0.6:qstep=4:aq-mode=1:aq-strength=1.0:cutree:no-early-skip:ctu=64:no-fast-cfb:ipratio=1.4:pbratio=1.3:cbqpoffs=0:crqpoffs=0:rd=3:psy-rd=0.3:psy-rdoq=1:b-intra:no-fast-intra:rdoq-level=1:no-tskip:no-tskip-fast:cu-lossless:tu-intra-depth=1:tu-inter-depth=1:strong-intra-smoothing:no-constrained-intra:nr-intra=0:nr-inter=0:qblur=0.5:cplxblur=20:signhide:sar=16:pass=1:stats="H:\videotest\outputtest.stats" -f null NUL
    
    2nd pass
    
    "H:\Project\Suite HEVC\bin\Release\data\bin64\ffmpeg.exe" -hwaccel auto -i "H:\videotest\test.mkv" -map 0:v:0 -c:v libx265 -pass 2 -b:v 5000k -preset 5 -x265-params level=0:profile=undefined:pmode:no-pme:pme:no-high-tier:ref=3:bframes=4:open-gop:keyint=250:min-keyint=25:b-adapt=2:bframe-bias=0:rc-lookahead=20:no-scenecut:b-pyramid:me=hex:subme=2:merange=57:temporal-mvp:weightp:no-weightb:max-merge=2:no-weightb:no-rect:no-amp:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.9:no-strict-cbr:qcomp=0.6:qstep=4:aq-mode=1:aq-strength=1.0:cutree:no-early-skip:ctu=64:no-fast-cfb:ipratio=1.4:pbratio=1.3:cbqpoffs=0:crqpoffs=0:rd=3:psy-rd=0.3:psy-rdoq=1:b-intra:no-fast-intra:rdoq-level=1:no-tskip:no-tskip-fast:cu-lossless:tu-intra-depth=1:tu-inter-depth=1:strong-intra-smoothing:no-constrained-intra:nr-intra=0:nr-inter=0:qblur=0.5:cplxblur=20:signhide:sar=16:pass=2:stats="H:\videotest\outputtest.stats" -map 0:a:0 -c:a copy -map 0:a:1 -c:a copy -map 0:s:0 -c:s copy -map 0:s:1 -c:s copy "H:\videotest\outputtest.mkv"
    there are other errors?

    thanks in advance!
    Quote Quote  
  15. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    Have you checked if the stats file is created? If not you might need to escape the path:

    https://www.ffmpeg.org/ffmpeg-utils.html#Quoting-and-escaping

    Code:
    stats="H:\\videotest\\outputtest.stats"
    FFmpeg does not care about the extension being .log or .stat or something else.
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  16. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by z-machine95 View Post
    Originally Posted by poisondeathray View Post
    Yes there is a difference - you need to specify the stats with x265-params . "pass 2" will not overwrite it

    e.g

    Code:
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 1 -x265-params pass=1:stats="mylog.log" -f mp4 NUL -y
    ffmpeg -i input.ext -an -c:v libx265 -b:v 1000k -pass 2 -x265-params pass=2:stats="mylog.log" "output.mp4"

    You can verify because mediainfo will report the differences , and the file will be different (filesize is different between 1pass ABR)
    first thanks guys for helping me!

    second I will try this.. my first attempt was something like that but without -f null NUL and -pass 1

    fingercrossed...

    EDIT:

    does not work even with this command line... zeranoe build works for you?
    logfile must be declared as .log with a unix style path or work good as i wrote?
    Although I have no desire to ever use 2-pass encoding in HEVC (or any format for that matter) I had no trouble encoding 2-pass hevc using the latest ffmpeg and PDR's script.

    Here's the test script I used:

    Code:
    SET PATH="D:\Backup\Video Apps\Video Encoders\FFmpeg\FFMpeg\64-bit"
    ffmpeg -i "Plane_1080p.mp4" -an -c:v libx265 -aspect 16:9 -pix_fmt yuv420p -b:v 1000k -x265-params pass=1:stats="mylog.log" -f NULL nul -y
    
    ffmpeg -i "Plane_1080p.mp4" -c:v libx265 -aspect 16:9 -pix_fmt yuv420p -b:v 1000k -x265-params pass=2:stats="mylog.log" -c:a aac -strict experimental -ar 48000 -ab 256k -f mp4 "Output.mp4"
    
    pause
    and here is the resulting export:
    Image Attached Files
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  17. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    ...........And just for Shit$ and Giggles, here is a comparison between 2-pass HEVC and 2-pass VP9 @ 1000 kb/s using the latest ffmpeg by Zeranoe:
    Image Attached Files
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  18. Yes, it has to do with escaping and syntax. When specifying a path for the : separated values in ffmpeg filers (such as for x265-params , x264-params, etc... or other filters that take on a similar syntax with the colon separated notation) you need to use quotes , with apostrophe

    So this

    stats="H:\videotest\outputtest.stats"

    should be

    stats="'H:\videotest\outputtest.stats'"
    Quote Quote  
  19. Member
    Join Date
    Jan 2014
    Location
    Somewhere
    Search Comp PM
    Thanks guys! It works like a charm!

    Thanks!!!!

    i have just added escape character for the entire string and get it working:

    stats="'H:\videotest\outputtest.stats'"

    now i get FILENAME.EXTENSION.cutree.tmp and FILENAME.EXTENSION.temp and they're not empty!

    thanks to @poisondeathray @racer-x @TorBru @selur @babiulep
    Last edited by z-machine95; 3rd May 2015 at 02:28.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!