The ratio of the top-quark branching fractions R=B(t→Wb)/B(t→Wq) , where the denominator includes the sum over all down-type quarks ( q=b,s,d ), is measured in the tt¯ dilepton final state with proton–proton collision data at s=8 TeV from an integrated luminosity of 19.7 fb −1 , collected with the CMS detector. In order to quantify the purity of the signal sample, the cross section is measured by fitting the observed jet multiplicity, thereby constraining the signal and background contributions. By counting the number of b jets per event, an unconstrained value of R=1.014±0.003(stat.)±0.032(syst.) is measured, in a good agreement with current precision measurements in electroweak and flavour sectors. A lower limit R>0.955 at the 95% confidence level is obtained after requiring R≤1 , and a lower limit on the Cabibbo–Kobayashi–Maskawa matrix element |Vtb|>0.975 is set at 95% confidence level. The result is combined with a previous CMS measurement of the t -channel single-top-quark cross section to determine the top-quark total decay width, Γt=1.36±0.0 ... mehr2(stat.)−0.11+0.14(syst.) GeV.