Barrel length influence in muzzle velocity I want to find out what is the muzzle velocity of a bullet. 
For that I would need to know the force applied to the bullet by the expanding gas of the exploded powder. If $P = F/A$ then $F = PA$.
I have the area (5.56mm NATO base diameter is 9.58mm $A = \pi r^2 = \pi \times 4.79^{2} = 72.07$ mm$^{2}$) now I need to know the pressure of the gas, and this is what I think that is the hard part (and what I need your help with).
Also, as the gas expands through the barrel its pressure drops so I'd need a to calculate the pressure of the gas based on it's area, right?
The length of the barrel is 508mm
I don't need the exact formulas I just need to be pointed at the right direction.
I'm trying to learn ballistics (internal and external) but there's so many things to take in consideration and the resources on the internet are a bit scarce. Thanks for your help and sorry if I made any grammar mistakes... 
 A: You have one thing working for you, pressure, but three things working against you, friction, inertia, and also conceptually negative pressure due to the bullet moving fast and creating vacuum behind it at the end of a very long barrel. The latter is probably unrealistic in common guns, so it's mostly pressure against friction, energy and momentum of the bullet. The optimal solution is not only by the barrel length, but also by the bullet mass. You need to be between the maximum momentum and the maximum energy. It is a tradeoff by the mass of the bullet.
The initial pressure depends on the type and amount of powder and therefore is unknown. You may need to treat it as an experimentally derived value from the results of your tests. Same with friction, as measuring it by pushing a bullet manually down the barrel is a bad idea.
Yes, the pressure will drop as the volume (not area) increases. However, keep in mind that the gas temperature also drops with the volume increase and this further decreases the pressure. Finally, the bullet takes away some energy from the gas. This also decreases the gas temperature and therefore pressure.
You need a device that measures the speed of the bullet, they are available. Once you create a theoretical model, you'd need to test it with different lengths of otherwise the same barrel and also with different masses of the bullet of otherwise the same ammo. A lighter bullet will typically have a higher energy, but lower momentum. In reality you want both. It is not possible to optimize both at the same time, but you can optimize to be in the middle to take advantage of being close to both optimums. 
A: Agree with Safesphere, here are some more perspectives on this.
Gun and ammunition designers know that the bullet being shot out the barrel must have positive pressure behind it at all times during its tenure inside the barrel, so a bullet designed for a certain barrel length is going to always have more than enough powder in the cartridge to ensure that this is always the case. This accounts for the flame flash seen whenever a bullet exits the muzzle of the gun. 
From a heat conduction standpoint, most gun barrels are considered "thick" on the timescale of bullet firing and since the bullet spends so little time in the barrel, you can assume for purposes of an estimate that there's no heat transfer out the walls of the barrel while the bullet is being accelerated out the barrel. Anyone who shoots rapid-fire will tell you that this is not true, but in a bull-barrel pistol shooting .22 long rifle rounds at a rate of one round per 15 seconds it is a good approximation.
Chemistry will yield the heat of the reaction and the molar volume(s) of the reaction products and therefore their temperature; thermodynamics and the gas equation of state then yields the starting pressure and the pressure as a function of volumetric expansion for all points in the bullet's path down the barrel. 
Knowing the pressure versus position and the mass and diameter of the bullet, you can then figure out the force on the bullet as it traverses the barrel, and solve for its  final velocity- ignoring friction between the bullet and the rifling cut into the inside of the barrel (I do not know how to model that friction so I omit that part of the analysis).
Some research on the web into bullet ballistics & whatnot will probably furnish you with a better analysis than this, but what I have explained here should be of some help. 
A: Ask yourself what work is done on the projectile (p, A), energy, mass conservation, burn rate law of powder of propellant, gas dynamics (isentrop vs real gas (complicated))
References:
Nato 7.62mm
Interior ballistics
