How can I output Handbrake output to both the screen and to a file?

后端 未结 2 1720
[愿得一人]
[愿得一人] 2021-01-21 16:03

So I\'ve been using Handbrake command line to encode my video collection to store on my NAS so I can use it on my HTPC. I was looking for a way to output both to the screen so I

相关标签:
2条回答
  • 2021-01-21 16:33

    I would use Tee-Object for this:

    ./HandbrakeCLI.exe -i infile -o outfile ... 2>&1 | Tee-Object -File movie.log
    

    Added in the 2>&1 to capture errors to the log as well as the screen.

    0 讨论(0)
  • 2021-01-21 16:34

    What you really want to do is to grab the tail.exe binary from the UnxUtils package and run it as follows:

    tail -f D:\Conversions\Completed\Movies\9.29.1010.log
    

    Unfortunately you will need to do that in a second command prompt (or PowerShell) window, but it will "follow" that file and display the lines from the log as they are added.

    If you really want to keep that in a single window, you will need PowerShell v2 and you can start the encoding as a job (allowing it to run in the background) and then follow that command with a call to tail for displaying the results:

    Start-Job -ScriptBlock { ./HandbrakeCLI.exe -i "in" -o "out" "params" > log.txt }
    tail -f log.txt
    
    0 讨论(0)
提交回复
热议问题