So I'm having problem with AAC encoding. I'm trying to encode some synthetic sound waves, but it does not work as expected. The file I get gives just a super short sound when played in VLC. When I play is in ffplay is plays like I expect, but it says "duration: 00:00:00.05" which I suppose says 5 ms. But I encode a lot more than that, and it played more. So VLC plays a super short sound, ffplay plays a longer file (the expected length), but displays it with super short duration, what's going on?
Source: http://pastebin.com/M5MKkEL3
One of the things that looks wrong to me is this: If you look for the variable "audio_time", if you breakpoint it and read it every encode frame, you will get this:
..
Encode frame 8: 0.00010416666666666666
Encode frame 9: 0.00012500000000000000
(and so on)
The diff is: ~0.00002085, which is a 1/1000 of a the diff I expected from ~47 samples frames per second, which is what the encoder wants with 48k sample rate (48k / 1024 = ~47).
So why do I get a thousand of the expected data encoded?
Feel free to point anything suspicious out!
Thanks in advance!
So I found it, in line 75, this was missing:
per_frame_audio_samples = 1024 in my case.