An online charging method based on a number portability service, comprising: when a calling user equipment, UE, in an Internet Protocol multimedia subsystem, IMS, network initiates a call to a called UE, receiving, by an application server, AS, in the IMS network, an invite message sent by a call session control function, CSCF, entity in the IMS network, wherein the invite message carries a number of the calling UE and a number of the called UE; sending, by the AS, a number portability information query request to a number portability database, NPDB, server, wherein the number portability information query request carries the number of the called UE; receiving, by the AS, a number portability information query response sent by the NPDB server, wherein the number portability information query response carries number portability information corresponding to the number of the called UE; and sending, by the AS, an initial credit control request message to an online charging system, OCS, in the IMS network, wherein the initial credit control request message carries the number portability information and the number of the calling UE, so that the OCS performs charging authentication for the calling UE according to the number portability information and the number of the calling UE, characterized in that the invite message further carries information about a codec supported by the calling UE; and after the receiving, by the AS, the number portability information query response sent by the NPDB server, the method further comprises: sending, by the AS, a codec negotiation request message to a multimedia resource function, MRF, entity in the IMS network, wherein the codec negotiation request message carries the information about the codec supported by the calling UE, so that the MRF entity determines, according to information about a codec supported by the MRF entity and the information about the codec supported by the calling UE, a codec supported by both the MRF entity and the calling UE; receiving, by the AS, a codec negotiation response message sent by the MRF entity, wherein the codec negotiation response message carries information about the codec determined by the MRF entity; and sending, by the AS, the information about the codec determined by the MRF entity to the calling UE, so that the calling UE decodes, according to the received information about the codec, an audio file sent by the MRF entity and plays the decoded audio file, wherein the audio file sent by the MRF entity comprises voice notification information indicating that the called UE has changed a subscription network. when a calling user equipment, UE, in an Internet Protocol multimedia subsystem, IMS, network initiates a call to a called UE, receiving, by an application server, AS, in the IMS network, an invite message sent by a call session control function, CSCF, entity in the IMS network, wherein the invite message carries a number of the calling UE and a number of the called UE; sending, by the AS, a number portability information query request to a number portability database, NPDB, server, wherein the number portability information query request carries the number of the called UE; receiving, by the AS, a number portability information query response sent by the NPDB server, wherein the number portability information query response carries number portability information corresponding to the number of the called UE; and sending, by the AS, an initial credit control request message to an online charging system, OCS, in the IMS network, wherein the initial credit control request message carries the number portability information and the number of the calling UE, so that the OCS performs charging authentication for the calling UE according to the number portability information and the number of the calling UE, sending, by the AS, a codec negotiation request message to a multimedia resource function, MRF, entity in the IMS network, wherein the codec negotiation request message carries the information about the codec supported by the calling UE, so that the MRF entity determines, according to information about a codec supported by the MRF entity and the information about the codec supported by the calling UE, a codec supported by both the MRF entity and the calling UE; receiving, by the AS, a codec negotiation response message sent by the MRF entity, wherein the codec negotiation response message carries information about the codec determined by the MRF entity; and sending, by the AS, the information about the codec determined by the MRF entity to the calling UE, so that the calling UE decodes, according to the received information about the codec, an audio file sent by the MRF entity and plays the decoded audio file, wherein the audio file sent by the MRF entity comprises voice notification information indicating that the called UE has changed a subscription network.