View previous topic :: View next topic |
Author |
Message |
Ottre Tux's lil' helper
Joined: 23 Dec 2012 Posts: 129
|
Posted: Thu Mar 21, 2013 5:33 pm Post subject: MPD with Libav |
|
|
You might have noticed that MPD has stopped working with new versions of Libav.
Here's how to fix it:
1. Tell portage you want to upgrade to an unstable version of MPD. Version 0.16.8 is way out of date.
Quote: | # echo "media-sound/mpd" > /etc/portage/package.accept_keywords/mpd |
2. Mask all versions of MPD in the gentoo tree.
Quote: | # echo "media-sound/mpd::gentoo" > /etc/portage/package.mask/mpd |
3. Copy all versions of MPD in the gentoo tree to your local portage overlay. See this page for instructions on setting up an overlay. I'm installing MPD version 0.17.3, but you don't have to use that.
Quote: | # mkdir -p /usr/layman-local/portage-custom/media-sound
# cp -r /usr/portage/media-sound/mpd /usr/layman-local/portage-custom/media-sound/ |
4. Create the following patch.
Quote: | # nano /usr/layman-local/portage-custom/media-sound/mpd/files/mpd-0.17.3-libav.patch |
with the contents:
Quote: | --- mpd-0.17.3/src/decoder/ffmpeg_decoder_plugin.c
+++ mpd-0.17.3/src/decoder/ffmpeg_decoder_plugin.c
@@ -270,7 +270,8 @@
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
const AVPacket *packet,
AVCodecContext *codec_context,
- const AVRational *time_base)
+ const AVRational *time_base,
+ AVFrame *frame)
{
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE)
decoder_timestamp(decoder,
@@ -293,14 +294,13 @@
cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
- AVFrame frame;
int got_frame = 0;
int len = avcodec_decode_audio4(codec_context,
- &frame, &got_frame,
+ frame, &got_frame,
&packet2);
if (len >= 0 && got_frame) {
audio_size = copy_interleave_frame(codec_context,
- &frame,
+ frame,
aligned_buffer,
buffer_size);
if (audio_size < 0)
@@ -528,6 +528,18 @@
decoder_initialized(decoder, &audio_format,
input->seekable, total_time);
+ AVFrame *frame = avcodec_alloc_frame();
+ if (!frame) {
+ g_warning("Could not allocate frame\n");
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
+ avformat_close_input(&format_context);
+#else
+ av_close_input_stream(format_context);
+#endif
+ mpd_ffmpeg_stream_close(stream);
+ return;
+ }
+
enum decoder_command cmd;
do {
AVPacket packet;
@@ -538,7 +550,8 @@
if (packet.stream_index == audio_stream)
cmd = ffmpeg_send_packet(decoder, input,
&packet, codec_context,
- &av_stream->time_base);
+ &av_stream->time_base,
+ frame);
else
cmd = decoder_get_command(decoder);
@@ -559,6 +572,12 @@
}
} while (cmd != DECODE_COMMAND_STOP);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
+ avcodec_free_frame(&frame);
+#else
+ av_freep(&frame);
+#endif
+
avcodec_close(codec_context);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); |
5. Adjust the ebuild to apply the patch.
Quote: | # nano /usr/layman-local/portage-custom/media-sound/mpd/mpd-0.17.3.ebuild |
Search for this paragraph:
Quote: | src_prepare() {
DOC_CONTENTS="If you will be starting mpd via /etc/init.d/mpd, please make
sure that MPD's pid_file is unset."
cp -f doc/mpdconf.example doc/mpdconf.dist || die "cp failed"
epatch "${FILESDIR}"/${PN}-0.16.conf.patch
|
And add this line below:
Quote: | epatch "${FILESDIR}"/${PN}-0.17.3-libav.patch |
6. Generate checksums for the patch and the modified ebuild.
Quote: | # ebuild /usr/layman-local/portage-custom/media-sound/mpd/mpd-0.17.3.ebuild digest |
7. Ensure you have enabled the "ffmpeg" USE flag for MPD.
Quote: | $ equery uses media-sound/mpd | grep ffmpeg |
You should see "+ffmpeg".
8. Emerge.
Quote: | # emerge --ask media-sound/mpd |
|
|
Back to top |
|
|
GFCCAE6xF Apprentice
Joined: 06 Aug 2012 Posts: 295
|
Posted: Thu Mar 21, 2013 5:49 pm Post subject: |
|
|
What versions of these packages are you using?
What is the specific breakage?
I am using:
media-sound/mpd-0.17.3 (+ffmpeg)
media-video/libav-9.3
and I have not come across any breakages... |
|
Back to top |
|
|
Ottre Tux's lil' helper
Joined: 23 Dec 2012 Posts: 129
|
Posted: Fri Mar 22, 2013 7:09 pm Post subject: |
|
|
rorgoroth wrote: | What versions of these packages are you using? |
libav-9.3 and mpd-0.17.3
rorgoroth wrote: | What is the specific breakage? |
The patch allows the FFMPEG plugin of MPD to work with recent versions of Libav (version 9.x) that provide libavcodec.so.54.
MPD was constantly segfaulting when I tried to play a song.
mpd.log showed a lot of these messages:
Quote: | Mar 22 01:11 : ffmpeg: Unsupported libavcodec SampleFormat | . |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|