All links of one day
in a single page.
<Previous day - Next day>

rss_feedDaily RSS Feed
floral_left The Daily Shaarli floral_right
——————————— November 7, 2023 - Tuesday 07, November 2023 ———————————
ai - illustration - anime - stable - diffusion - guide -

This quick guide will walk through various tips on forming anime Stable Diffusion prompts. Examples included.

ffmpeg - video - VHS - filter -

il y a 3 a

Realistic VHS Effect

Tutorial (tues only)

I've been a fan of the VHS effect for a long time, but I've noticed that most filters and presets don't look very convincing. So I decided to take it upon myself to see if I could make a decent one that didn't require any expensive paid video editing software.

Here's a clip from one of my favorite 90's movies that I used my filter on.

To keep things simple, you're going to want to download a free software called FFmpeg. It's a video conversion tool with some editing effects as well. It's very good for video editors to have in general. Once you download that, you're going to want to go inside the bin folder, and take whatever video clip you want, and paste it in the bin folder named INPUT.

After that, you're going to want to hold shift and right click in the white space of the bin folder and you should see an option "open command window here". Click that, and windows CMD will open up. Then all you have to do is to paste this code in:

ffmpeg -i INPUT.mp4 -vf "tinterlace=4, curves=m='0/0 0.5/0.9':r='0/0 0.5/0.5 1/1':g='0/0 0.5/0.5 1/1':b='0/0 0.5/0.5 1/1':, eq=saturation=1.2, scale=480:360, smartblur=lr=2:ls=-1, noise=c0s=13:c0f=t+u, gblur=sigma=3:steps=1, unsharp=luma_msize_x=15:luma_msize_y=9:luma_amount=5.0:chroma_msize_x=7:chroma_msize_y=3:chroma_amount=-2, format=yuv422p" -af "highpass=f=50, lowpass=f=5000" OUTPUT.MP4

And then hit enter and it should start rendering out your video. Once the command window stops rendering, you'll see a new file appear in the bin folder called OUTPUT.mp4. That is your converted video file. Enjoy your retro VHS look!

Now I want to go more in depth at this point, starting with how the effect works.

After studying the VHS look for a while, I noticed that most of the aspects aren't necessarily inherent to VHS at all really.

  • Blurred picture
  • Artificial sharpening with halos around edges
  • Grain
  • Chroma splitting
  • Very low resolution
  • Poor audio quality

Most people get the chroma splitting very wrong and usually split the red and blue channels apart from each other. That's very unrealistic and it shows. How it actually works is a real thing called Chroma Subsampling. Basically, in order to save space, VHS made the horizontal color resolution half of what the brightness resolution is. That's why the colors bleed through the edges. Luckily for us, chroma subsampling actually exists in digital video files as well. So in this filter I made sure that the chroma subsampling was the same as VHS had.

The low resolution isn't necessary part of VHS since it is an analog format, so it doesn't really have a resolution, but I find that it works best for that effect and makes the artificial sharpening more accurate.

How to edit my code and customize the look

  • INPUT.mp4 This is your starting file. You can change the .mp4 to whatever the video format of your file is.
  • tinterlace=4 This adds artificial interlacing. It can make the video look kind of choppy so it's best used on a 60fps video. If you don't want interlacing, delete the text and the comma afterwards.
  • curves=m='0/0 0.5/0.9':r='0/0 0.5/0.5 1/1':g='0/0 0.5/0.5 1/1':b='0/0 0.5/0.5 1/1': These control the rgb and lightness curves of the video. Think of it as a regular curves graph with 0/0 being the bottom left point, 0.5/0.5 being the middle point, and 1/1 being the top right point. The number before the slash meaning how far right it is, and the number after the slash is how far up it goes.

This preset has everything at neutral except for the lightness curve which has two points instead of three. It's set so that the whites are overexposed mimicking a low dynamic range.

  • eq=saturation=1.2 This controls your saturation you can pick a number between -3 and 3.
  • scale=480:360 This is your output resolution. It's very low because it works well for the effect with the added bonus of having smaller file sizes and smaller render times. If you want widescreen, replace 480 with -2
  • smartblur=lr=2:ls=-1 This controls the artificial sharpening. lr controls the intensity, and ls controls if the filter sharpens or blurs the picture. -1 means sharpen.
  • noise=c0s=13:c0f=t+u This controls the amount of grain you want. I think a range from 10 - 20 is the most realistic.
  • gblur=sigma=3:steps=1 This adds a gaussian blur over the picture.
  • unsharp=luma_msize_x=15:luma_msize_y=9:luma_amount=5.0:chroma_msize_x=7:chroma_msize_y=3:chroma_amount=-2 This adds additional sharpening to the picture and I wouldn't really change anything.
  • format=yuv422p This is what tells the software to enclude the VHS style chroma subsampling. This is very important in relation to the output resolution. It needs a resolution that's divisible by two.
  • "highpass=f=50, lowpass=f=5000" This controls the VHS audio filter. I have a highpass set to cut frequencies below 50hz and a low pass cutting frequencies above 5khz.
  • OUTPUT.mp4 This is your output file. You can have any name and any format you prefer. I just have it as output.mp4 for organization.

And that's really all there is to it! I hope this makes sense and I hope you enjoy it. And there's really no limitations to what you can do! You can even add overlays on the video in FFmpeg for added effect. I chose to omit that since I wanted to present a full, in software, tutorial without having to rely on extra videos and stuff like that.

Note d'alex : pour faire du chroma subsampling correspondant à de la vidéo (yuv), je conseillerais l'ajout de -pix_fmt yuv420p à la fin de la commande, parce que dans les commandes, c'est du yuv422. Ça reste discutable, vu que :

  • 4:2:2: The two chroma components are sampled at half the sample rate of luma: the horizontal chroma resolution is halved.
  • 4:2:0: The two chroma components are sampled at half the sample rate of luma both horizontally and vertically (i.e. there's one U and one V per 2x2 group of Ys).
ffmpeg - vhs - encoding -

Encoding from a VHS source

Command line

ffmpeg -i input -vf "yadif=1:1,hqdn3d=3,drawbox=y=ih-h:w=0:h=6:t=max,format=yuv420p" \
-crf 23 -preset medium -c:a aac -movflags +faststart \
-metadata title="Title" output.mp4


Encoding form a VHS input can be improved with some filters:

  • yadif is a deinterlacer. See the documentation and try out the different modes to see what looks best to you. Alternatively, you could try the w3fdif deinterlacing filter, but I haven't tested that one yet.
  • hqdn3d is a video denoiser. VHS can be noisy, so experiment with various values, and try without it too. Denoising can improve compressibility, but too much denoising will add noticeable blur.
  • drawbox in this example is is making a 6 pixel black box on the very bottom to mask any head switching noise. You may have to adjust the height, or just remove it. This is better than cropping because simply covering it up avoids changing the aspect ratio: if that is not a concern the feel free to crop instead.
  • format is added to use a widely compatible pixel format. It does not really matter with your input though since it is already yuv420p.

other options

  • -crf and -preset will allow you to adjust the output quality and encoding speed. See FFmpeg Wiki: H.264 Video Encoding Guide.
  • -movflags +faststart is useful if your viewers will watch via progressive download. After encoding it will move some info to the beginning of the file so it can begin playback quicker.

You will need to add -strict experimental if using an old ffmpeg: the native FFmpeg AAC encoder used to be considered experimental but that is now no longer the case.