VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member
    Join Date
    Jun 2020
    Location
    china
    Search Comp PM
    I want to use the following script to browse pictures, pausing for 15 seconds on each picture, but it only reads the first two pictures.

    .
    .
    .
    video = core.bs.VideoSource(source=r'E:\001\%02d.jpg')
    video = core.std.AssumeFPS(video,fpsnum=1, fpsden=15)
    video = haf.ChangeFPS(video, 24000, 1001)
    audio = core.bas.Source(r'E:\audio\xxx.mp3', track=-1)
    audio.set_output(1)
    video.set_output(0)


    This is the script from avisynth, and it works great.

    .
    .
    .
    v = ImageSource("I:\001\%02d.jpg", start=0, end=17, use_DevIL=true)
    v = AssumeFPS(v, 1,16)
    video = ChangeFPS(v, 25,1)
    audio=DirectShowSource("E:\audio\xxx.mp3")
    AudioDub(video,audio)


    Can anyone help me with this problem?
    Quote Quote  
  2. I'd use imwri plugin and python code to create a list of filepaths, it is more versatile and comforting than %xxxd syntax for reading images:
    Code:
    from vapoursynth import core
    from pathlib import Path
    from havsfunc import ChangeFPS
    
    DIRECTORY = r'D:\images'
    IMAGE_DURATION = 15  # seconds
    
    if not hasattr(core, 'imwri'):
        raise AttributeError('vs-imwri plugin is needed to load images: https://github.com/vapoursynth/vs-imwri/releases')
    images = Path(DIRECTORY).glob('IMG_*.JPG')  # loading images into a list using wild cards in image name
    video = core.imwri.Read(filename=list(images))
    video = core.std.AssumeFPS(video, fpsnum=1, fpsden=int(IMAGE_DURATION))
    video = ChangeFPS(video, 24000, 1001)
    audio = core.bas.Source(r'E:\audio\xxx.mp3', track=-1)
    audio.set_output(1)
    video.set_output(0)
    In vapoursynth you have to pipe audio and video separately (preferably using vspipe) to encoders, and only then muxing video and audio. So how to cut audio length to video length would depend how you mux those streams.
    Quote Quote  
  3. so basically you do not have to use audio in vapoursynth, just muxing your audio track to that encoded vapoursynth video stream
    Quote Quote  
  4. Member
    Join Date
    Jun 2020
    Location
    china
    Search Comp PM
    Thanks for @_Al_ for help, But it returned the error: ImportError: cannot import name 'Sequence' from 'collections'.
    Quote Quote  
  5. Does it only read first 2 pictures with video only ?

    Are you using most recent bestsource plugin ?
    https://github.com/vapoursynth/bestsource/releases/
    Quote Quote  
  6. Member
    Join Date
    Jun 2020
    Location
    china
    Search Comp PM
    Thanks @poisondeathray for your attention to this issue. It does read only two images, 00.jpg and 01.jpg, and the image sizes are the same. It seems that it cannot automatically detect how many images are in the folder. Do you have any good solution?
    Quote Quote  
  7. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    A word to the wise ... if the pics have different sizes (eg HD or 4k) or different rotations in the metadata (eg portrait, landscape, 90 degrees, 180 degrees, etc) then you're in for a bit of a learning curve
    Good luck.

    PS _AI_ is brilliant at this stuff and IIRC has access to relevant code (or has my memory failed yet again).
    Quote Quote  



Similar Threads

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