An audio encoding method and apparatus for electronic shock protection (ESP) function in an audio player. A method of generating a frame structure for an electronic shock protection function of an audio player, includes: encoding original data of a frame and locating the encoded data in a first area that is a start part of the frame structure; and encoding frame length information indicating a size of the encoded data in the frame, and locating the encoded frame length information in a second area that is an end part of the frame structure. |