selvinEduardo / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

FFmpegFrameRecorder video frame faster than audio #404

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.     recorder.setFormat("mp4");
        recorder.setFrameRate(25);
        recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); // AV_CODEC_ID_FLV1
        recorder.setVideoOption("preset", "ultrafast");
        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
        recorder.setVideoQuality(20.0);

2.    timestamp += 1000 * 55;
       if (timestamp > recorder.getTimestamp()) { 
                recorder.setTimestamp(timestamp); 
       }
3.

What is the expected output? What do you see instead?
problem:Video playback is faster  when the video play.  (Video frame stopped 
but audio is still playing)

End video and audio simultaneously  thanks 

What version of the product are you using? On what operating system?
0.6

Please provide any additional information below.

Original issue reported on code.google.com by bladepoi...@gmail.com on 7 Jan 2014 at 12:32

GoogleCodeExporter commented 9 years ago
I've fixed something related to that for issue #398. Does it still happen with 
version 0.7?

Original comment by samuel.a...@gmail.com on 7 Jan 2014 at 12:44

GoogleCodeExporter commented 9 years ago
sorry ,do not solve my problem 
notice my code:
        timestamp += 1000 * 55;
       if (timestamp > recorder.getTimestamp()) { 
                recorder.setTimestamp(timestamp); 
       }

I add timestamp myself ?

Original comment by bladepoi...@gmail.com on 7 Jan 2014 at 2:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
FFmpegFrameRecorder get Video Frame from onPreviewFrame()  put queue  and in 
AsyncTask get From equeue  and record in this code :  timestamp += 1000 * 55;
       if (timestamp > recorder.getTimestamp()) { 
                recorder.setTimestamp(timestamp); 
       }

Is it right ? thanks

Original comment by bladepoi...@gmail.com on 7 Jan 2014 at 3:06

Attachments:

GoogleCodeExporter commented 9 years ago
Issue 405 has been merged into this issue.

Original comment by samuel.a...@gmail.com on 9 Jan 2014 at 2:07

GoogleCodeExporter commented 9 years ago
I'm not sure how, but it looks like we'd need to resynchronize audio and video 
after a seek in setTimestamp(). FFplay looks like it does that, so if you 
figure out what to fix by looking inside ffplay.c, or by asking on FFmpeg's 
mailing list or something, please post the details here and I'll fix it, thanks!

Original comment by samuel.a...@gmail.com on 9 Jan 2014 at 2:09

GoogleCodeExporter commented 9 years ago
Thank you very much ,if i find the answer will tell you!

Original comment by bladepoi...@gmail.com on 10 Jan 2014 at 3:19

GoogleCodeExporter commented 9 years ago
Wait a minute, I was under the impression that you were talking about 
FFmpegFrameGrabber for some reason.

In the case of FFmpegFrameRecorder, if the streams are not synchronized, it 
usually means that the encoding is too slow, so you should try to lower the 
bitrates, use faster codec settings, a different codecs, etc. The usual. If 
that doesn't work, then let me know, thanks.

Original comment by samuel.a...@gmail.com on 10 Jan 2014 at 3:37

GoogleCodeExporter commented 9 years ago
Moreover, please try with an unmodified version of RecordActivity.java:
http://code.google.com/p/javacv/source/browse/samples/RecordActivity.java
If that works correctly, then the problem lies in one of the things in your 
modified version.

Original comment by samuel.a...@gmail.com on 10 Jan 2014 at 3:42

GoogleCodeExporter commented 9 years ago
I user h264 codec if use unmodified version of RecordActivity.java  will lose 
some frame ,so I put frame into equeue in onPreviewFrame call back method  and 
get it from other thread,

Original comment by bladepoi...@gmail.com on 10 Jan 2014 at 4:09

GoogleCodeExporter commented 9 years ago
So, like I said, please try to lower the bitrate/quality. You could also try to 
lower the frame rate. Your CPU might just be too slow to record everything in 
real time.

Original comment by samuel.a...@gmail.com on 10 Jan 2014 at 4:14

GoogleCodeExporter commented 9 years ago
ok .let me try !

Original comment by bladepoi...@gmail.com on 10 Jan 2014 at 4:19

GoogleCodeExporter commented 9 years ago
I use setVideoBitrate method ,solve my problem ,thanks

Original comment by bladepoi...@gmail.com on 10 Jan 2014 at 8:18

GoogleCodeExporter commented 9 years ago
Ok, good! Please ask your questions on the mailing list next time if possible, 
and not here, thank you.

Original comment by samuel.a...@gmail.com on 10 Jan 2014 at 1:27

GoogleCodeExporter commented 9 years ago
ok

Original comment by bladepoi...@gmail.com on 10 Jan 2014 at 2:39

GoogleCodeExporter commented 9 years ago
hi samuel,  I want to record video in portrait window ,but how to rotation
the every frame ,thanks

2014/1/10 tong gao <bladepoint007@gmail.com>

Original comment by bladepoi...@gmail.com on 14 Jan 2014 at 11:27

GoogleCodeExporter commented 9 years ago
Take a look at issue #376

Original comment by samuel.a...@gmail.com on 15 Jan 2014 at 12:20