VideoHelp Forum

+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Does anybody know if it is possible to script the addition of 1 second of black to the start of a video file whilst encoding via x264/ffmpeg?

    It would also be useful if there was a way of scripting chapter markers to the correct the right I-frame.
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Yes, create a simple AVIsynth script and encode in ffmpeg/Virtualdub2, etc. For example
    Code:
    vid=lwlibavVideosource("S:\misc film\shorts\test.mp4")
    aud=lwlibavAudiosource("S:\misc film\shorts\test.mp4")
    audiodub(vid,aud)
    bc=blankclip(last,length=24)
    bc+last
    Quote Quote  
  3. If the first frame of your video is black you can use ffmpeg's loop filter to repeat that first frame N (one second) times, and the adelay filter to delay the audio by the same amount of time (inserts silent audio). Assuming a 24 fps video:

    Code:
    ffmpeg -i input.mp4 -vf loop=loop=24:size=1:start=0 -af adelay=1000:all=1 -c:v libx264 -c:a aac output.mp4
    The first frame is repeated 24 times (1 second); 1000 milliseconds of silent audio is inserted.

    https://ffmpeg.org/ffmpeg-filters.html#loop
    https://ffmpeg.org/ffmpeg-filters.html#adelay
    Quote Quote  
  4. By the way, here's a mod of davexnet's AviSynth script which automatically generates the correct number of blank frames based on the video's frame rate (rather than manually specifying the number of frames):
    Code:
    vid=lwlibavVideosource("S:\misc film\shorts\test.mp4")
    aud=lwlibavAudiosource("S:\misc film\shorts\test.mp4")
    audiodub(vid,aud)
    BlankClip(last, length=round(framerate))+last
    If you wanted a different length of time, say 1.5 seconds, just multiply the framerate by that amount:

    Code:
    BlankClip(last, length=round(framerate*1.5))+last
    Last edited by jagabo; 9th Aug 2022 at 18:46.
    Quote Quote  
  5. Thanks for the suggestions, will give them a try out.
    Quote Quote  



Similar Threads