Closed GoogleCodeExporter closed 9 years ago
It seems like it should work if the imageWidth and imageHeight is 0 so that it
would call super.getFrameNumber(), but it is always returned 0 since it was
never incremented in super.
Original comment by wzsddtc
on 14 Jun 2013 at 4:51
(also note that audio_c.frame_number() is always much bigger than
picture.pts().. not sure which one to use. )
Original comment by wzsddtc
on 14 Jun 2013 at 5:21
The following change works. :)
private int audio_clock;
@Override
public long getTimestamp() {
if (picture == null) {
return (audio_clock * 1000000L) / sampleRate;
} else {
return Math.round(getFrameNumber() * 1000000L / getFrameRate());
}
}
boolean record(AVFrame frame) throws Exception {
int ret;
av_init_packet(audio_pkt);
audio_pkt.data(audio_outbuf);
audio_pkt.size(audio_outbuf_size);
if ((ret = avcodec_encode_audio2(audio_c, audio_pkt, frame, got_audio_packet)) < 0) {
throw new Exception("avcodec_encode_audio2() error " + ret + ": Could not encode audio packet.");
} else {
if(frame != null){
this.audio_clock += frame.nb_samples();
}
}
Original comment by wzsddtc
on 14 Jun 2013 at 6:16
Hi wzsddtc,
I have same problem that images and it is much slower than audio recording, So
would you please advice me to fix this problem, maybe some sample code(I'm very
newbie in development).
Thanks so much!
Original comment by geuma...@gmail.com
on 19 Jun 2013 at 11:10
Yes, you are right, forgot about timestamps of audio frame. Should be fixed
with this update:
http://code.google.com/p/javacv/source/detail?r=a38bec82311333d7ae7d06decdd4a2af
e7c92455
Thanks!
Original comment by samuel.a...@gmail.com
on 22 Jun 2013 at 3:59
Thanks for the update. This should be added to FFmpegFrameRecorder as well, do
you know how to set a timestamp on the audio track (to skip audio samples) in
addition to the frame number?
Original comment by wzsddtc
on 22 Jun 2013 at 5:46
Are you really talking about FFmpegFrameRecorder? I'm not sure I understand the
use case then. I'm also not sure about the technically feasible of what you are
asking. Do you have any reference about what it is exactly you are looking to
accomplish? A message thread from the FFmpeg mailing list perhaps? Thanks!
Original comment by samuel.a...@gmail.com
on 23 Jun 2013 at 12:00
This case should be closed. Audio timestamps can be grabbed by calculating how
many samples are calculated already in FFmpegFrameRecorder OR how many samples
are grabbed in FFmpegFrameGrabber. :)
Original comment by wzsddtc
on 16 Sep 2013 at 5:06
Ok, sounds good :) I was under the impression that you were trying to skip
audio frames on record(). This makes sense for video (we get variable frame
rate), but I wasn't sure how that would make sense for audio...
Original comment by samuel.a...@gmail.com
on 16 Sep 2013 at 5:24
Original issue reported on code.google.com by
wzsddtc
on 14 Jun 2013 at 4:37