Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (21:26:09) kriegerod: i have problem when transcoding audio from ac3 to aac. i have it playing twice faster. i tried to multiply pts&dts&duration by two, but it does not help. writing the frame to output file TWICE helps to have normal speed, but sound is robotic...
- (21:26:45) kriegerod: the sound is stereo
- (21:27:07) ruggles: what is the sample rate?
- (21:29:20) kriegerod: 48k
- (21:29:27) kriegerod: both in and out
- (21:30:21) kriegerod: forgot to say that currently i use ffmpeg libs :(
- (21:32:21) bgmarete вышел из комнаты (quit: Read error: Connection reset by peer).
- (21:32:35) bgmarete [~bgmarete@41.81.210.225] вошёл в комнату.
- (21:32:59) ruggles: kriegerod: are you using the native aac encoder or libfaac wrapper?
- (21:33:16) kriegerod: libfaac
- (21:35:02) bgmarete_ [~bgmarete@41.90.251.148] вошёл в комнату.
- (21:35:32) ruggles: kriegerod: resulting file reports 48kHz?
- (21:36:24) bgmarete вышел из комнаты (quit: Read error: Connection reset by peer).
- (21:36:33) kriegerod: yes
- (21:38:46) elenril: sbr at work?
- (21:38:50) ruggles: kriegerod: looking at your app, you're not handling decoding/encoding loop correctly
- (21:38:54) silverfilain вышел из комнаты (quit: Remote host closed the connection).
- (21:39:21) ruggles: kriegerod: you have to send AVCodecContext.frame_size samples to the encoder
- (21:40:08) ruggles: ac3 decoder outputs 1536 samples, but aac encoder frame_size is only 1024
- (21:40:58) ruggles: well, at least i think aac frame_size is 1024. faac might be different.
- (21:41:30) ruggles: at any rate, they don't necessarily match, so you need to buffer the decoded samples that the encoder isn't using.
- (21:41:46) kriegerod: input frame_size 1536
- (21:41:46) kriegerod: output frame_size 1024
- (21:41:46) kriegerod: you're right
- (21:41:49) kriegerod: thanks a lot!
- (21:41:54) ruggles: np
- (21:43:21) ruggles: kriegerod: note that the decoder doesn't always set frame_size, so you have to look at decbuf_size after decoding a packet to see how much data it returned.
- (21:44:02) kriegerod: so i should decode the AVPacket, do audio_decode(), having now 1536 * 2 bytes of s16 raw audio, then feed audio_encode with only 1024 * 2 bytes, leaving the rest for next call, right?
- (21:44:52) kriegerod: is it ok to audio_encode remaining 512 *2 bytes of remainings, or should i catenate it with results of next audio_decode()?
- (21:45:53) ruggles: basically
- (21:46:05) ruggles: but it's not 1024 * 2 bytes
- (21:46:17) ruggles: it's 1024 samples
- (21:46:48) ruggles: libfaac takes 16-bit samples, and you have 2 channels
- (21:46:54) ruggles: so it's 1024 * 2 * 2 bytes
- (21:47:34) kriegerod: thanks for correcting
- (21:48:42) ruggles: kriegerod: also the decoder can consume only part of the packet, so you have to check that as well. and keep sending the packet until it's consumed (updating pkt.data and pkt.size each time).
- (21:48:51) ruggles: ac3 doesn't do that, but many do
- (21:49:05) kriegerod: decode_audio returns me 6144 bytes, that's exactly 1536 * 2 * 2
- (21:49:31) kriegerod: so i can send 1024 * 2 * 2 first time, and remaining 512 * 2 * 2 second time, right?
- (21:50:00) kriegerod: i am not obliged to decode next portion to send exactly 1024 * 2 * 2 to encoder?
- (21:50:08) ruggles: yes, you are
- (21:50:11) kriegerod: thanks
- (21:50:18) kriegerod: oh
- (21:50:27) kriegerod: you are = you are obliged?
- (21:50:41) kriegerod: or yes = you can send a non-full frame-size?
- (21:50:42) ruggles: the encoder needs frame_size samples
- (21:51:29) ruggles: the only exception is the last frame
- (21:52:31) ruggles: if the encoder has the CODEC_CAP_SMALL_LAST_FRAME flag set (libfaac does), then for the last frame you can change frame_size before sending the data to the encoder
- (21:54:47) ruggles: kriegerod: you can use libavutil/fifo.h to make the buffering easier
- (21:54:53) ruggles: that's what avconv/ffmpeg do
- (21:57:03) kriegerod: can i use CODEC_CAP_SMALL_LAST_FRAME feature for non-last frames?
- (21:57:29) kriegerod: i would like to preserve my loop scheme if possible
- (21:57:58) ruggles: well, for libfaac it happens to work, but that's not part of the API. i don't know of any other encoders that work that way.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement