I have a folder with 35k videos, I want to replace the first 5 seconds of each video in the folder with a specific intro and place a watemark on top left for all the video. Videos have different lenght.
The resulting video should replace the previous one under the same name without any additional character to the name.
Do you guys know if this is possible with AviSynth and how to do that?
+ Reply to Thread
Results 1 to 10 of 10
You really want to reencode 35,000 videos just to add an intro (which can be done by using the playlist feature of most players) and add an ugly watermark (which can perhaps be done using a subtltle)?
And I don't suppose all 35,000 videos are of the same resolution and format? If not, I'd say 'fuggedaboutit'.
Sure it's possible with AviSynth, a batch file, and an encoder like ffmpeg. You want to REPLACE the first 5 seconds with an intro? Or pre-pend the intro. Are all the videos the same resolution, frame rate, etc.? What about audio? Keep the original audio? Replace the first 5 seconds with the intro's audio? Same watermark on all videos? Watermark over the intro too or only after the intro?
I would highly recommend you place the new videos in a separate folder and keep the old ones in case there's a problem.
- Yes I want to replace. Keeping the original audio it's fine
- Don't think they are all the same resolution and framerate, but I'm fine with forcing a resize @ specific bitrate on all of them
- Yes same watemark on all videos. Only after the intro but if this is not possible, having it over the intro would be fine as well
Here's a batch file and a script: _batch.bat and _script.avs. The batch file steps through each file in a subfolder called Source. It builds a one line script that opens the video file (_GetSource.avs). _script.avs imports that script and processes the video. The Assets subfolder should contain logo.bmp and intro.mp4 -- used by _script.avs to add the logo and replace the first part of the video file with the intro. ffmpeg is then used to encode (you may want to change the codec, preset, and other settings) _script.avs and copy the original audio from original mp4 file. Finally, the result is written to the subfolder Output. The output is the same name as the original input file.
Note that the intro video is resized to the same size and frame rate as the source video. If the aspect ratios are different the intro will be distorted. If the frame rates are different the logo may get jerky.
If you really want to replace the original videos you can render to a temporary file name, delete the original mp4, then rename the temporary file to the original name. If you do this you will want to verify that the ffmpeg encoding succeeded properly before deleting the original file.
Damn! I didn't expect to receive the actual script, you are a hero! Do you have skype/telegram/discord?
EDIT: I tried to search online and someone was saying ffmpeg could be the issue. I tried to install an old version (4.0.2) and now I get a different error, don't know if this could help
[avisynth @ 063e4340] Script error: there is no function named "LSMashVideoSource"
(_GetSource.avs, line 1)
(_script.avs, line 1)
_script.avs: Unknown error occurredthere is no function named LSMASHVideoSource
Last edited by giggioman00; 18th Oct 2022 at 12:32.
You need to install the LSMASH package for AviSynth: http://avisynth.nl/index.php/LSMASHSource
Put a copy of LSMASHsource.dll in AviSynth's plugins folder. Be sure to use the right "bitness", the one from the x86 folder for 32 bit AviSynth, and/or the one from the x64 folder for 64 bit for 64 bit AviSynth. And be sure to use put it in the correct plugins folder, plugins for 32 bit AviSynth+, plugins64+ for 64 bit AviSynth+.
I carefully followed your instruction for at least 3 times but with no success, same errors happens
EDIT: Apparently if I rename _script.avs to _script.avsi it works. I read if it is .avsi the plugins are loaded automatically.
But now I'm having problem with encoding apparently. A 200 MB file was encoded into 14 MB file. Also I need to press a key to encode the next file, it is not automatic
EDIT 2: The output files doesn't open
EDIT 3: I was able to encode the files succesfully by fixing the mmpeg command in the batch. Now I need help to pass to the next file without having to press a key please...
EDIT 4: I was wrong. The file appears in output folder after the encoding but the intro doesn't appear at the start of the video...
Last edited by giggioman00; 18th Oct 2022 at 16:10.
ffmpeg to open the AVS script. If you rename it to avsi ffmpeg will fail and the batch file will fail to produce any ouput.
I was just guessing at a lot of things like the size of your videos, the intro, and watermark. If you can't figure it out for yourself, upload a few sample videos, your logo image, and your intro video so I can tune the process.