Guest User

Untitled

a guest
Oct 28th, 2011
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (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...
  2. (21:26:45) kriegerod: the sound is stereo
  3. (21:27:07) ruggles: what is the sample rate?
  4. (21:29:20) kriegerod: 48k
  5. (21:29:27) kriegerod: both in and out
  6. (21:30:21) kriegerod: forgot to say that currently i use ffmpeg libs :(
  7. (21:32:21) bgmarete вышел из комнаты (quit: Read error: Connection reset by peer).
  8. (21:32:35) bgmarete [~bgmarete@41.81.210.225] вошёл в комнату.
  9. (21:32:59) ruggles: kriegerod: are you using the native aac encoder or libfaac wrapper?
  10. (21:33:16) kriegerod: libfaac
  11. (21:35:02) bgmarete_ [~bgmarete@41.90.251.148] вошёл в комнату.
  12. (21:35:32) ruggles: kriegerod: resulting file reports 48kHz?
  13. (21:36:24) bgmarete вышел из комнаты (quit: Read error: Connection reset by peer).
  14. (21:36:33) kriegerod: yes
  15. (21:38:46) elenril: sbr at work?
  16. (21:38:50) ruggles: kriegerod: looking at your app, you're not handling decoding/encoding loop correctly
  17. (21:38:54) silverfilain вышел из комнаты (quit: Remote host closed the connection).
  18. (21:39:21) ruggles: kriegerod: you have to send AVCodecContext.frame_size samples to the encoder
  19. (21:40:08) ruggles: ac3 decoder outputs 1536 samples, but aac encoder frame_size is only 1024
  20. (21:40:58) ruggles: well, at least i think aac frame_size is 1024. faac might be different.
  21. (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.
  22. (21:41:46) kriegerod: input frame_size 1536
  23. (21:41:46) kriegerod: output frame_size 1024
  24. (21:41:46) kriegerod: you're right
  25. (21:41:49) kriegerod: thanks a lot!
  26. (21:41:54) ruggles: np
  27. (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.
  28. (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?
  29. (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()?
  30. (21:45:53) ruggles: basically
  31. (21:46:05) ruggles: but it's not 1024 * 2 bytes
  32. (21:46:17) ruggles: it's 1024 samples
  33. (21:46:48) ruggles: libfaac takes 16-bit samples, and you have 2 channels
  34. (21:46:54) ruggles: so it's 1024 * 2 * 2 bytes
  35. (21:47:34) kriegerod: thanks for correcting
  36. (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).
  37. (21:48:51) ruggles: ac3 doesn't do that, but many do
  38. (21:49:05) kriegerod: decode_audio returns me 6144 bytes, that's exactly 1536 * 2 * 2
  39. (21:49:31) kriegerod: so i can send 1024 * 2 * 2 first time, and remaining 512 * 2 * 2 second time, right?
  40. (21:50:00) kriegerod: i am not obliged to decode next portion to send exactly 1024 * 2 * 2 to encoder?
  41. (21:50:08) ruggles: yes, you are
  42. (21:50:11) kriegerod: thanks
  43. (21:50:18) kriegerod: oh
  44. (21:50:27) kriegerod: you are = you are obliged?
  45. (21:50:41) kriegerod: or yes = you can send a non-full frame-size?
  46. (21:50:42) ruggles: the encoder needs frame_size samples
  47. (21:51:29) ruggles: the only exception is the last frame
  48. (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
  49. (21:54:47) ruggles: kriegerod: you can use libavutil/fifo.h to make the buffering easier
  50. (21:54:53) ruggles: that's what avconv/ffmpeg do
  51. (21:57:03) kriegerod: can i use CODEC_CAP_SMALL_LAST_FRAME feature for non-last frames?
  52. (21:57:29) kriegerod: i would like to preserve my loop scheme if possible
  53. (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.
  54.  
RAW Paste Data