VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. Hello up till now i have used Megui to encode my avisynth scripts but after writing a few scripts in Vapoursynth i don't know how to start the process of encoding. i have the x265.exe file ready but where do i place it and where am i supposed to put the x265 parameters. i am not familiar with command line encoding. do i use powershell,cmd,vsedit to encode using vapoursynth?. also how would i encode the audio with the video and mux them in mkv?. thanks sorry if these are noob questions.
    Quote Quote  
  2. Originally Posted by ProWo View Post
    try another GUI: StaxRip.
    if possible i would like to encode without gui now, directly. Would appreciate any help in doing so.
    Quote Quote  
  3. Member stax76's Avatar
    Join Date
    Nov 2009
    Location
    On thin ice
    Search PM
    Using and scripting the terminal is not exactly easy, it took me twenty years to master...


    Recommendations:

    PowerShell, Windows Terminal, VS Code
    Quote Quote  
  4. example:
    Code:
    import vapoursynth as vs
    from vapoursynth import core
    clip = core.lsmas.LibavSMASHSource(r"G:/my_file.mp4")
    clip = core.resize.Spline36(clip, width=1280, height=720)
    clip.set_output(0)
    save that script with some name , example as: C:\my_scrit.vpy

    Then you proceed to command prompt in windows and apply those three command lines:
    Code:
    "vspipe.exe"  --y4m  "C:\my_scrit.vpy"  -  | "x265.exe"  --frames 26540 --input-csp i420  --y4m  --input-depth 8 --output-depth 10  --input-res 1280x720 --fps 30000/10001 --crf 23 --output  "out.265" -
    "ffmpeg.exe"  -i "G:\my_file.mp4"  -vn -f wav -  | "neroAacEnc.exe"  -ignorelength -lc -cbr 256000 -if - -of "C:\my_audio.m4a"
    "mp4box.exe" -add "C:\out.265:fps=29.970" -add "C:\my_audio.m4a" -new "C:\my_output.mp4"
    some arguments you do not need for x265, because y4m header is passed to x265 , I put them all in there, but --fps, --frames, and some others maybe,
    if not frames x265 might not report status of encoding , how far it is in , at least x264 behavess like that

    Vapoursynth does not pass audio in official version, right now they final touch it and test to include it in and hopefully incoming version, right now there are testing builds only to pass audio.
    Last edited by _Al_; 19th Apr 2020 at 17:03.
    Quote Quote  
  5. you can encode h265 right in your script itself. Python is a programming language so you can use its subprocess module.
    Like example in here:
    https://forum.videohelp.com/threads/392480-Easy-way-to-encode-vpy-scripts#post2544851
    Quote Quote  
  6. Member stax76's Avatar
    Join Date
    Nov 2009
    Location
    On thin ice
    Search PM
    That reads as you do much manual work that could be avoided with more powerful tools and specialized builds.
    Quote Quote  
  7. It does not have to be punched manually all the time. Scripts could be used from basic batch scripts to elaborate UI or your GUI sure.
    Not sure if anyone types it like that all the time, it is prone to create mistakes. That is just basic that can be tweaked to something else.
    Vapoursynth uses Python so all those commands could be performed in that script as well, making audio and muxing.
    Last edited by _Al_; 19th Apr 2020 at 17:13.
    Quote Quote  
  8. Originally Posted by _Al_ View Post
    you can encode h265 right in your script itself. Python is a programming language so you can use its subprocess module.
    Like example in here:
    https://forum.videohelp.com/threads/392480-Easy-way-to-encode-vpy-scripts#post2544851
    Could you elaborate pls and where would place x265 parameters?
    Quote Quote  
  9. Originally Posted by ACKR View Post
    Originally Posted by _Al_ View Post
    you can encode h265 right in your script itself. Python is a programming language so you can use its subprocess module.
    Like example in here:
    https://forum.videohelp.com/threads/392480-Easy-way-to-encode-vpy-scripts#post2544851
    Could you elaborate pls and where would place x265 parameters?
    Parameters are set in that script. You run that script and you encode h265 video. Name that script *.py, not *.vpy. then to use any Python script editor. Module subprocess.Popen is Python module that comes with Python. Calling that function (subprocess.Popen with your arguments) encodes H265 video.
    And stdin (standard input) for that subprocess is vapoursynth clip. It is all done within that script.
    Define paths for x265, output, then
    Code:
    x265_cmd = [x265, '--frames', f'{len(clip)}',
                 '--y4m',
                 '--input-depth', f'{clip.format.bits_per_sample}',
                 '--output-depth', '10',
                 '--input-res', f'{clip.width}x{clip.height}',
                 '--fps', f'{clip.fps_num}/{clip.fps_den}',
                 '--crf',    '23',
                 '--output', output,
                 '-']  
    process = subprocess.Popen(x265_cmd, stdin=subprocess.PIPE)
    clip.output(process.stdin, y4m = True)
    process.communicate()
    because of that --y4m header passing from vapoursynth this might be enough:
    Code:
    x265_cmd = [x265,
                 '--y4m',
                 '--input-depth', f'{clip.format.bits_per_sample}',
                 '--output-depth', '10',
                 '--crf',    '23',
                 '--output', output,
                 '-']  
    process = subprocess.Popen(x265_cmd, stdin=subprocess.PIPE)
    clip.output(process.stdin, y4m = True)
    process.communicate()
    but as I said --frames + argument usually gives x265 idea how much is going to be encoded, so you have progress report in % how much is already encoded.
    You can use ffmpeg instead of x265, it does not matter, subprocess does not work only with x265. It works with anything that accepts stdin.

    But I'd recommend using vspipe route, it sort of make things more simple. Just make a script and then use vspipe to pipe it into encoder that accepts stdin. (x264, x265, ffmpeg)
    Last edited by _Al_; 19th Apr 2020 at 22:53.
    Quote Quote  
  10. example how you can run mp4box in python script:
    Code:
    MP4BOX= r'C:\tools\Mp4box.exe'
    output = r'C:\destination\output.mp4'
    #temp_output is defined somewhere above, for example your temp 265 video
    #also fps
    mp4box_cmd = [MP4BOX,
                     '-add' , temp_output+f':fps={fps}',
                     '-par', '1=1:1',
                     '-new',  output]
    process = subprocess.Popen(mp4box_cmd)
    process.communicate()
    Quote Quote  
  11. Originally Posted by _Al_ View Post
    example how you can run mp4box in python script:
    Code:
    MP4BOX= r'C:\tools\Mp4box.exe'
    output = r'C:\destination\output.mp4'
    #temp_output is defined somewhere above, for example your temp 265 video
    #also fps
    mp4box_cmd = [MP4BOX,
                     '-add' , temp_output+f':fps={fps}',
                     '-par', '1=1:1',
                     '-new',  output]
    process = subprocess.Popen(mp4box_cmd)
    process.communicate()
    thanks for this
    Quote Quote  



Similar Threads

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