When using a bridge rectifier :
V dc peak = sqrt(2) x Vac - 2 x Vdiode (Vdiode = voltage drop in a diode inside the bridge rectifier at the current desired)
Idc = ~ 0.62 x Iac (0.62 is an approximation that usually works well for 50-200VA range transformers)
ex a 9v AC 50VA transformer will have :
Iac = 50 VA / 9 = 5.5 A
Idc = ~ 0.62 x 5.5A = 3.41A
Vdc peak = 1.414 x 9 - 2 x 0.8v = ~12.75v - 1.6v = ~ 11.15v
(so 11.15v x 3.41A = 38w .. maybe a bit more ... 0.8v x 2 x 4A = 6.5w lost in the bridge rectifier)
Keep in mind that most transformers (but esp. the low VA ones) will have a higher output voltage at low load... for example at 50-100mA the 50VA transformer may output 10..11v AC instead of 9v AC
Also keep in mind that your AC voltage may fluctuate depending on network load, time of day etc ... in a 230v country, at 2-3 AM I often see 245v AC at my outlet. So, account for these fluctuations on the primary side, which will affect the output on the secondary side.
For example, in the example above the formula says 10.75v, but in all further calculations it would be smart to consider 10v or 10.25v as minimum voltage, and around 12-14v as peak DC voltage (+1-2v at low load, ~+1v if your AC input is high)
Not applicable to you, as it would be too expensive (this would be useful for 20A+ rectification and higher voltages) but it's worth mentioning:
Instead of a bridge rectifier, you can use ideal diode controller and four mosfets :
https://www.analog.com/media/en/technical-documentation/data-sheets/4320fb.pdfThis way you have less heat produced.. in your example, at 4A of current, the bridge rectifier would produce approx. 2 x 1v x 4A = 8w of heat.
The ideal diode controller would cause a voltage drop of a few tenths of a volt and maybe just 1w of heat (it really depends on the mosfets chosen)
Anyway... the size of capacitor can be estimated with formula : Capacitance (in Farads) = Current / [ 2 x AC frequency x (Vdc peak - Vdc min)]
So for example, let's say your "safe" Vdc peak is 10v and Vdc min is 7v (to have 2v above the linear regulator's output voltage) and you're in a country with 60 Hz mains frequency
C = 4A / [2 x 60 x (10-7)] = 4 / 360 = 0.011111 Farads or 11000 uF ... that's the minimum estimated. So, I'd say 2 x 6800uF 25v caps in parallel would work, or 3 4700uF capacitors.
You can use more capacitance, but too much will cause a very high current when you plug the power supply (capacitors act as black holes sucking loads of energy when they're empty) and that can cause the fuse in front of your transformer to blow up, if you don't calculate the right value for it.
There are better linear regulators than the classic 7805, for example LM1084 is a good example:
https://www.digikey.com/products/en?keywords=lm1084It's also available in packages easy to heatsink, and also adjustable (use 2 resistors - or resistor + potentiometer - to configure output voltage):
https://www.digikey.com/product-detail/en/texas-instruments/LM1084IT-ADJ-NOPB/LM1084IT-ADJ-NOPB-ND/363557See the datasheet on the page for example circuits and detailed description of what components to use.