Multiplicities for the semi-inclusive production of each charge state of π± and K± mesons in deep-inelastic scattering are presented as a function of the kinematic quantities x, Q2, z and Ph⊥. The multiplicities were extracted from data collected by the HERMES experiment at the HERA storage ring using 27.6 GeV electron and positron beams on a hydrogen or deuterium gas target. These results for identified hadrons constitute the most precise measurement to date, and will significantly enhance our understanding of the proton structure, as well as the fragmentation process in deep-inelastic scattering. Furthermore, the 3D binning at an unprecedented level of precision provides a handle to help disentangle the transverse momentum structure of both. The high level of precision coupled with an intermediate energy regime requires a careful study of the complex interaction between the experimental systematics, theoretical uncertainties, and the applicability of the factorization theorem within the standard framework of leading-twist collinear QCD. This is illustrated by the extraction of the valence quark ratio dv/uv at leading-order in αs. These results show a strong z-dependence below z ≈ 0.30, which could be interpreted as evidence for factorization breaking. This evidence weakens somewhat when isospin invariance of the fragmentation functions is assumed to be broken. Additionally, the multiplicities for the semi-inclusive production of π0 mesons in deep-inelastic scattering are presented as a function of z. These multiplicities were extracted from the same data sample as used for the charged meson results. The neutral pion multiplicity is the same as the average charged pion multiplicity, up to z ≈ 0.70. This is consistent with isospin invariance below z ≈ 0.70. The results at high values of z show strong signs of isospin symmetry breaking.