Hi,
the attached patch should fix this bug.
Note that the package now depends on libavresample.
--
Anton Khirnov
Index: fuse-emulator-utils-1.1.1/fmfconv_ff.c
===================================================================
--- fuse-emulator-utils-1.1.1.orig/fmfconv_ff.c 2013-05-16 20:32:13.000000000 +0000
+++ fuse-emulator-utils-1.1.1/fmfconv_ff.c 2014-02-28 22:21:18.241002407 +0000
@@ -60,6 +60,8 @@
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>
+#include <libavutil/opt.h>
+#include <libavresample/avresample.h>
#include <libswscale/swscale.h>
#include "libspectrum.h"
@@ -96,7 +98,7 @@
static AVFrame *ff_picture, *ff_tmp_picture, *ffmpeg_pict;
static struct SwsContext *video_resize_ctx;
-static ReSampleContext *audio_resample_ctx;
+static AVAudioResampleContext *audio_resample_ctx;
static int16_t **ffmpeg_sound;
static uint8_t *video_outbuf;
@@ -133,8 +135,7 @@
int len;
if( audio_resample_ctx && res_rte != snd_rte ) {
- audio_resample_close( audio_resample_ctx );
- audio_resample_ctx = NULL;
+ avresample_free( &audio_resample_ctx );
av_free( audio_tmp_inpbuf );
ffmpeg_sound = &sound16;
printi( 2, "ffmpeg_resample_audio(): reinit resample %dHz -> %dHz\n", snd_rte, out_rte );
@@ -145,11 +146,14 @@
out_fsz = 2 * out_chn;
}
if( !audio_resample_ctx ) {
- audio_resample_ctx = av_audio_resample_init( out_chn, snd_chn,
- out_rte, snd_rte,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_S16,
- 16, 8, 1, 1.0 );
+ audio_resample_ctx = avresample_alloc_context();
+ av_opt_set_int(audio_resample_ctx, "in_channel_layout", av_get_default_channel_layout(snd_chn), 0);
+ av_opt_set_int(audio_resample_ctx, "out_channel_layout", av_get_default_channel_layout(out_chn), 0);
+ av_opt_set_int(audio_resample_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
+ av_opt_set_int(audio_resample_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
+ av_opt_set_int(audio_resample_ctx, "in_sample_rate", snd_rte, 0);
+ av_opt_set_int(audio_resample_ctx, "out_sample_rate", out_rte, 0);
+
audio_tmp_inpbuf_size = (float)audio_outbuf_size * out_rte / snd_rte * (float)out_chn / snd_chn + 1.0;
audio_tmp_inpbuf = av_malloc( audio_tmp_inpbuf_size );
ffmpeg_sound = (void *)(&audio_tmp_inpbuf);
@@ -160,9 +164,9 @@
return 1;
}
- len = audio_resample( audio_resample_ctx,
- (short *)audio_tmp_inpbuf, (short *)sound16,
- snd_len / snd_fsz );
+ len = avresample_convert( audio_resample_ctx,
+ (uint8_t**)&audio_tmp_inpbuf, audio_tmp_inpbuf_size, audio_tmp_inpbuf_size / out_fsz,
+ (uint8_t**)&sound16, snd_len, snd_len / snd_fsz );
if( !len ) {
printe( "FFMPEG: Error during audio resampling\n" );
return 1;
@@ -224,7 +228,7 @@
*/
static int
-add_audio_stream( enum CodecID codec_id, int freq, int stereo )
+add_audio_stream( enum AVCodecID codec_id, int freq, int stereo )
{
AVCodecContext *c;
@@ -440,7 +444,7 @@
/* add a video output stream */
static int
-add_video_stream( enum CodecID codec_id, int w, int h, int timing )
+add_video_stream( enum AVCodecID codec_id, int w, int h, int timing )
{
AVCodecContext *c;
@@ -599,7 +603,7 @@
void
ffmpeg_add_frame_ffmpeg( void )
{
- int out_size, ret;
+ int got_output, ret;
AVCodecContext *c;
if( !video_st ) return;
@@ -619,22 +623,17 @@
ret = av_interleaved_write_frame( oc, &pkt );
} else {
+ AVPacket pkt = { 0 };
+
ffmpeg_pict->pts = c->frame_number;
/* encode the image */
- out_size = avcodec_encode_video( c, video_outbuf, video_outbuf_size, ffmpeg_pict );
- /* if zero size, it means the image was buffered */
- if( out_size > 0 ) {
- AVPacket pkt;
- av_init_packet( &pkt );
+ ret = avcodec_encode_video2(c, &pkt, ffmpeg_pict, &got_output);
+ if( ret >= 0 && got_output) {
+ pkt.pts = av_rescale_q( pkt.pts, c->time_base, video_st->time_base );
+ pkt.dts = av_rescale_q( pkt.dts, c->time_base, video_st->time_base );
- if( c->coded_frame->pts != AV_NOPTS_VALUE )
- pkt.pts = av_rescale_q( c->coded_frame->pts, c->time_base, video_st->time_base );
- if( c->coded_frame->key_frame )
- pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= video_st->index;
- pkt.data = video_outbuf;
- pkt.size = out_size;
/* write the compressed frame in the media file */
ret = av_interleaved_write_frame( oc, &pkt );
@@ -674,7 +673,7 @@
{
AVCodec *ac, *vc;
- enum CodecID acodec, vcodec;
+ enum AVCodecID acodec, vcodec;
ff_picture = NULL;
ff_tmp_picture = NULL;
@@ -725,7 +724,7 @@
vcodec = fmt->video_codec;
acodec = fmt->audio_codec;
- if( out_t == TYPE_FFMPEG && vcodec != CODEC_ID_NONE ) {
+ if( out_t == TYPE_FFMPEG && vcodec != AV_CODEC_ID_NONE ) {
/* Find the video encoder requested by user selection */
if( ffmpeg_vcodec != NULL && *ffmpeg_vcodec != 0 ) {
@@ -758,7 +757,7 @@
return 1;
}
- if( snd_t == TYPE_FFMPEG && acodec != CODEC_ID_NONE ) {
+ if( snd_t == TYPE_FFMPEG && acodec != AV_CODEC_ID_NONE ) {
/* Find the audio encoder requested by user selection */
if( ffmpeg_acodec != NULL && *ffmpeg_acodec != 0 ) {
Index: fuse-emulator-utils-1.1.1/configure.ac
===================================================================
--- fuse-emulator-utils-1.1.1.orig/configure.ac 2014-02-28 22:25:30.524185980 +0000
+++ fuse-emulator-utils-1.1.1/configure.ac 2014-02-28 22:25:59.813904078 +0000
@@ -85,8 +85,8 @@
AC_MSG_RESULT($ffmpeglib)
if test "$ffmpeglib" = yes; then
AC_CHECK_HEADERS(
- libavformat/avformat.h libswscale/swscale.h,
- FFMPEG_LIBS="-lavformat -lavcodec -lswscale -lavutil",
+ libavformat/avformat.h libswscale/swscale.h libavresample/avresample.h,
+ FFMPEG_LIBS="-lavformat -lavcodec -lswscale -lavresample -lavutil",
FFMPEG_LIBS=''; break
)
if test "x$FFMPEG_LIBS" != "x"