2009/1/12 Simon Schäfer <[email protected]>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm no expert but I have a similar problem like yours and in your code
> below is a thinking error, I think. The example.c encodes frames not on
> a specific time like 25times a second but as fast as it could, so the
> below method is called more than once per frame.
I can modify the scheduling time of the timer callback but the problem is
the audio.
When I play the encoded video the audio is not equal to the original
sound...
Therefore the encoding
> can be made twice once for audio and once for video, or even more often
> for both on one frame.
> Your code below encodes one audio frame then one video frame than one
> audio frame, because its called only once every 40ms. I can't give you
> the right way to do it because I am stuck on the same problem, but you
> can try to simply encode both at the same time and not caring about the
> pts value:
>
> void timerCB() {
> if (obj->GetAudioStream()){
> obj->EncodeAudioFrame();
> }
> if (obj->GetVideoStream()) {
> obj->EncodeVideoFrame();
> }
> }
>
> and hope that your number of audio samples is the same like the video
> samples, if not you are stuck on the same problem like I am (you can
> work around that by using a pcm codec (e.g. CODEC_ID_PCM_S16BE) but its
> no real solution)
And which can be a solution?
>
>
> Regards
Regards
>
> Simon
Franco
>
>
> Franco Amato schrieb:
> > Hi to all,
> > I'm encoding video and audio. For video I encode frames extracted from my
> > real-time simulation
> > and for audio I encode "what I'm listening".
> > For video I "extract and encode" a frame every 40ms to obtain 25fps.
> > The problem come when I try to also encode audio. My sound card play
> sound
> > at 48000 samples/s
> > so I set the sample_rate param of the encoder to 48000 and I do this test
> > (copied from output_example.c)
> >
> > //this routine is called 25 times/second
> > void timerCB(void *data, SoSensor *sensor)
> > {
> > MovieRecorderIv *obj = (MovieRecorderIv *)data;
> >
> > /* compute current audio and video time */
> > if ( obj->GetAudioStream() ){
> > audio_pts = (double)obj->GetAudioStream()->pts.val *
> > obj->GetAudioStream()->time_base.num /
> > obj->GetAudioStream()->time_base.den;
> > }
> > else
> > audio_pts = 0.0;
> >
> > if ( obj->GetVideoStream() )
> > video_pts = (double)obj->GetVideoStream()->pts.val *
> > obj->GetVideoStream()->time_base.num /
> obj->GetVideoStream()->time_base.den;
> > else
> > video_pts = 0.0;
> >
> > /* write interleaved audio and video frames */
> > if (!obj->GetVideoStream() || (obj->GetVideoStream() &&
> > obj->GetAudioStream() && audio_pts < video_pts)){
> > obj->EncodeAudioFrame();
> > }
> > else{
> > obj->EncodeVideoFrame();
> > }
> > }
> >
> > If I also encode audio as in the example above the created mpeg file run
> > much faster that original, instead If I only encode video
> > it run at the same fps of the original.
> > I have some problem to solve my problem, can I have a help?
> >
> > Regards,
> > Franco
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAklrMWIACgkQCT+234kh3agtXwCeNR5z8Y9jQcsWtOuTmcduhQE3
> MW4AoMBUUK7UvhEpY408LNnzwyqsk78g
> =t/Mg
> -----END PGP SIGNATURE-----
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
--
Franco Amato
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user