This thesis work presents lifetime measurements of heavy-flavour mesons made with semileptonic $B^0$ and $B^0_s$ decays based on $3~{\rm fb}^{-1}$ of data collected with the LHCb detector in proton-proton collisions at centre-of-mass energies of 7 and 8 TeV. The study of meson lifetimes is important to constrain phenomenological models for hadronic interactions based on the Standard Model of particle physics. Better understanding of hadronic interactions is essential for making precise predictions, which can then be confronted to experimental data in order to look for signs of physics beyond the Standard Model. We measure the differences between the decay widths of the $B^0_s$ and $B^0$ mesons, $\Delta(B)$, and between that of the $D_s^-$ and $D^-$ mesons, $\Delta(D)$, by analysing approximately 410000 $B^0_s \to D_{s}^{(*)-}\mu^{+}\nu_{\mu}$ and 110000 $B^0 \to D^{(*)-}\mu^{+}\nu_{\mu}$ decays, which are partially reconstructed in the same $K^+K^-\pi^-\mu^+$ final state. We measure $$\Delta(B) = -0.0115 \pm 0.0053~{\rm(stat)} \pm 0.0041~{\rm(syst)}~{\rm ps}^{-1}$$ and $$\Delta(D) = 1.0131 \pm 0.0117~{\rm(stat)} \pm 0.0065~{\rm(syst)}~{\rm ps}^{-1}.$$ Using the obtained values of $\Delta(D)$ and $\Delta(B)$ and the $B^0$ and $D^-$ lifetimes as external inputs, we obtain a measurement of the flavour-specific $B^0_s$ lifetime, $$\tau_s^{\rm fs} = 1.547 \pm 0.013~{\rm(stat)} \pm 0.010~{\rm (syst)} \pm 0.004~{\rm(\tau_{B^0})}~{\rm ps},$$ and of the $D_s^-$ lifetime, $$\tau_{D_s^-} = 0.5064 \pm 0.0030~{\rm(stat)} \pm 0.0017~{\rm (syst)} \pm 0.0017~{\rm(\tau_{D^-})}~{\rm ps},$$ where the last uncertainties originate from the limited knowledge of the $B^0$ and $D^-$ lifetimes, respectively. Both results are compatible with, and improve upon, previous determinations. A feasibility study of a $D^0$ lifetime measurement is performed, by measuring the difference between the decay widths of the $D^0$ and $D^-$ mesons, $\Delta(D)'$. We reconstruct approximately $2.2\times 10^6$ $B^0\to D^{*-}(\to \bar{D}^0 (\to K^+\pi^-)\pi^-)\mu^+\nu_{\mu}$ and $1.6\times 10^6$ $B^0\to D^{(*)-}(\to K^+\pi^-\pi^- (X))\mu^+\nu_{\mu}$ decays. We measure $$\Delta(D)' = 1.4644 \pm 0.0043~{\rm(stat)} \pm 0.0132~{\rm(syst)}~{\rm ps}^{-1}$$ and with the $D^-$ lifetime as external input, we get an estimate of the $D^0$ lifetime, $$\tau_{D^0} = 0.4122 \pm 0.0007~{\rm(stat)} \pm 0.0022~{\rm (syst)} \pm 0.0011~{\rm(\tau_{D^-})}~{\rm ps}.$$ This result is compatible with, but less precise than, current precision and thus validates the method. We discuss possible improvements with larger simulation samples and data sets.