[devel] Re: ffmpeg-20050406
Grigory Batalov
bga на altlinux.ru
Чт Апр 14 15:11:43 MSD 2005
On Wed, 13 Apr 2005 14:35:17 +0400
Grigory Batalov <bga на altlinux.ru> wrote:
> > > Я вижу, свежий ffmpeg (0.4.9-alt1cvs20050406) уже добрался
> > > до Сизифа, давайте смотреть, не сломалось ли чего =).
> > > > xvidcap-1.1.3-alt0.2
> >
> > "Не пригодилось". Бишь не собрался:
> >
> > if i586-alt-linux-gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/X11R6/include -DVERSION=\"1.1.3\" -pipe -Wall -O2 -march=i586 -mcpu=i686 -MT xvidcap-xtoffmpeg.o -MD -MP -MF ".deps/xvidcap-xtoffmpeg.Tpo" \
> > -c -o xvidcap-xtoffmpeg.o `test -f 'xtoffmpeg.c' || echo './'`xtoffmpeg.c; \
> > then mv ".deps/xvidcap-xtoffmpeg.Tpo" ".deps/xvidcap-xtoffmpeg.Po"; \
> > else rm -f ".deps/xvidcap-xtoffmpeg.Tpo"; exit 1; \
> > fi
> ...
> > make[2]: *** [xvidcap-xtoffmpeg.o] Error 1
> > make[2]: Leaving directory `/usr/src/RPM/BUILD/xvidcap-1.1.3/src'
> >
> > Попробовать, что ли, 1.1.4pre2 собрать...
>
> Тоже не собирается... Поковыряю немного, может, разберусь.
1.1.4pre2 не собирается из-за своих собственных тараканов =).
А к ffmpeg-0.4.9 эта версия уже готова. Для 1.1.3, рассчитанной
на 0.4.8, можно применить прилагаемый патчик.
Правда, я так и не понял, работает ли теперь xvidcap =).
Кто им уже пользовался, проверьте?
----------- следущая часть -----------
diff -ruN xvidcap-1.1.3.orig/src/xtoffmpeg.c xvidcap-1.1.3/src/xtoffmpeg.c
--- xvidcap-1.1.3.orig/src/xtoffmpeg.c 2004-02-15 22:00:54 +0300
+++ xvidcap-1.1.3/src/xtoffmpeg.c 2005-04-14 13:56:57 +0400
@@ -186,24 +186,33 @@
frame_bytes = enc->frame_size * 2 * enc->channels;
while (fifo_read (&ost->fifo, audio_buf, frame_bytes,
&ost->fifo.rptr) == 0) {
- ret = avcodec_encode_audio (enc, audio_out, audio_out_size,
- (short *)audio_buf);
-// audio_pts = (double)au_out_st->st->pts.val * output_file->pts_num / output_file->pts_den;
-// video_pts = (double)out_st->pts.val * output_file->pts_num / output_file->pts_den;
+ AVPacket pkt;
+
+ // initialize audio output packet
+ av_init_packet(&pkt);
+
+ pkt.size = avcodec_encode_audio (enc, audio_out, audio_out_size, (short *)audio_buf);
+ pkt.stream_index= ost->st->index;
+ if (enc->coded_frame) {
+ pkt.pts = enc->coded_frame->pts;
+ }
+ pkt.flags |= PKT_FLAG_KEY;
+ pkt.data = audio_out;
-// if ( audio_pts < video_pts && pthread_mutex_trylock (&mp) == 0 ) {
if ( pthread_mutex_trylock (&mp) == 0 ) {
/* write the compressed frame in the media file */
- if (av_write_frame (s, ost->st->index, audio_out, ret) != 0) {
+ if (av_write_frame (s, &pkt) != 0) {
fprintf (stderr, "Error while writing audio frame\n");
exit (1);
}
+
if ( pthread_mutex_unlock (&mp) > 0 ) {
fprintf (stderr, "Couldn't unlock mutex lock for writing audio frame\n");
}
+
} /* else {
fprintf (stderr, "Can't lock mutex for writing audio frame\n");
} */
@@ -239,6 +247,7 @@
}
+
void cleanup_thread_when_stopped () {
int retval = 0;
@@ -371,6 +380,27 @@
#endif // HAVE_FFMPEG_AUDIO
+static void do_video_out (AVFormatContext *s, AVStream *ost, unsigned char *buf, int size) {
+ AVCodecContext *enc;
+ AVPacket pkt;
+
+ enc = &(ost->codec);
+
+ // initialize video output packet
+ av_init_packet(&pkt);
+ pkt.size = size;
+ if (enc->coded_frame) pkt.pts = enc->coded_frame->pts;
+ if (enc->coded_frame && enc->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY;
+ pkt.stream_index= ost->index;
+ pkt.data= buf;
+
+ if (av_write_frame (s, &pkt) != 0) {
+ fprintf (stderr, "Error while writing audio frame\n");
+ exit (1);
+ }
+}
+
+
#ifdef DEBUG
/*
* dump info about XImage - for debugging purposes
@@ -1117,7 +1147,7 @@
}
#endif // HAVE_FFMPEG_AUDIO
/* write frame to file */
- av_write_frame (output_file, out_st->index, outbuf, out_size);
+ do_video_out (output_file, out_st, outbuf, out_size);
#ifdef HAVE_FFMPEG_AUDIO
/* release the mutex */
if (job->flags & FLG_AUDIO_WANTED) {
Подробная информация о списке рассылки Devel