You are not logged in.
bangkok_manouel wrote:what can be done:
rebuild ffmpeg with swscaler disabled
patch vlc wih this patch (otherwise build will fail with this version of ffmpeg)
rebuild vlcet voila (but no swscaler)
for those of us unaccustom to applying these patches and such.. might you be able to offer a "how-to"
that is a little more in depth?
Well, you may have solved your problem in the meantime but anyhow...
0. Make sure you have abs and patch installed
pacman -Sy abs patch
1. sync your abs tree by running abs in terminal as root
2. go to /var/abs/extra/multimedia
3. select and copy the ffmpeg folder to a place where you have rw permissions
4. edit the PKGBUILD inside that ffmpeg folder and change line 37 to be:
--disable-swscaler \
Your PKGBUILD should look like this:
# $Id: PKGBUILD,v 1.30 2007/12/05 02:47:18 paul Exp $
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>
# Maintainer: Paul Mattal <paul@archlinux.org>
pkgname=ffmpeg
pkgver=20071204
pkgrel=1
pkgdesc="Complete and free Internet live audio and video broadcasting solution for Linux/Unix"
arch=(i686 x86_64)
license=('LGPL')
depends=('lame' 'sdl' 'libvorbis' 'a52dec' 'faad2' 'faac' 'xvidcore' 'zlib' 'imlib2' 'x264>=20071201' 'libtheora')
source=(http://gerolde.archlinux.org/~paul/ffmpeg-$pkgver.tar.gz )
md5sums=('3d34e511d0466de6feabed85dddbb2a8')
url="http://ffmpeg.mplayerhq.hu/"
build() {
cd $startdir/src/$pkgname || return 1
# configure
./configure \
--prefix=/usr \
--enable-gpl \
--enable-libmp3lame \
--enable-libvorbis \
--enable-pp \
--enable-libfaac \
--enable-libfaad \
--enable-liba52 \
--enable-libxvid \
--enable-libx264 \
--enable-libtheora \
--disable-libamr-nb \
--enable-pp \
--enable-shared \
--enable-pthreads \
--enable-x11grab \
--disable-swscaler \
|| return 1
# build
make -j 2 || return 1
# install
mkdir -p $startdir/pkg/usr/{bin,include,lib} || return 1
make DESTDIR=$startdir/pkg install || return 1
}
5. open a terminal "in" that folder and run:
makepkg -c
6. Build of ffmpeg will start
7. Once it's finished, install ffmpeg
pacman -U ffmpeg-20071204-1-i686.pkg.tar.gz
8. go to /var/abs/extra/multimedia
9. select and copy the vlc folder to a place where you have rw permissions
10. copy/paste this patch to a blank file and name it vlc.patch
--- a/modules/codec/ffmpeg/mux.c
+++ b/modules/codec/ffmpeg/mux.c
@@ -133,7 +133,11 @@ int E_(OpenMux)( vlc_object_t *p_this )
return VLC_EGENERIC;
}
+#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(0<<8)+0)
+ p_sys->oc->pb = &p_sys->io;
+#else
p_sys->oc->pb = p_sys->io;
+#endif
p_sys->oc->nb_streams = 0;
p_sys->b_write_header = VLC_TRUE;
11. move this vlc.patch file to your vlc folder
12. edit the PKGBUILD inside that vlc folder and add the following line:
patch -Np1 -i ../vlc.patch || return 1
Add vlc.patch to your source array in your VLC PKGBUILD:
source=(http://download.videolan.org/pub/videolan/vlc/${pkgver}/${pkgname}-${pkgver}.tar.bz2 vlc.patch)
I was too lazy to generate the md5sum so I just removed the md5 line (this is not a good idea).
Here's the PKGBUILD:
# $Id $
# Maintainer:
# Contributor: Sarah Hay <sarahhay@mb.sympatico.ca>
pkgname=vlc
pkgver=0.8.6d
pkgrel=1
pkgdesc="A multi-platform MPEG, VCD/DVD, and DivX player"
depends=('libmad>=0.15.1b-2' 'libmpeg2>=0.4.0b-3' 'ffmpeg>=20070131'
'wxgtk-2.6>=2.6.4' 'hal>=0.5.9.1' 'libid3tag>=0.15.1b-2' 'bash>=3.1'
'libdvbpsi4>=0.1.5' 'fribidi>=0.10.7' 'sysfsutils>=2.0.0'
'libdvdnav>=0.1.10-2' 'libdvdread>=0.9.4-3' 'xvidcore>=1.1.0-2'
'libmatroska>=0.8.0' 'libxv>=1.0.1' 'libcdio>=0.78.2' 'desktop-file-utils')
arch=(i686 x86_64)
license=('GPL')
url="http://www.videolan.org/vlc/"
#Note: These build plugins, so I guess they'd be runtime depends
makedepends=('live-media' 'gnome-vfs' 'mesa' 'sdl_image' 'libmpcdec' 'speex'
'libnotify' 'libmodplug' 'lirc-utils')
install=${pkgname}.install
source=(http://download.videolan.org/pub/videolan/vlc/${pkgver}/${pkgname}-${pkgver}.tar.bz2 vlc.patch)
build() {
cd $startdir/src/${pkgname}-${pkgver}
sed -i -e 's:#include <vlc\/vlc.h>:#include <vlc/vlc.h> \n #include <locale.h>: ' src/misc/charset.c
sed -i -e 's:/truetype/freefont/FreeSerifBold.ttf:/TTF/VeraBd.ttf:' modules/misc/freetype.c
patch -Np1 -i ../vlc.patch || return 1
# features that won't build on x86_64
[ "${CARCH}" = "i686" ] && EXTRAFEATURES="--enable-loader"
./configure --prefix=/usr --enable-dvdread --enable-dvdnav --enable-madi \
--enable-ffmpeg --disable-rpath --enable-wxwidgets --enable-faad \
--enable-alsa --enable-skins2 --enable-livedotcom --enable-dvb --enable-theora \
--enable-dmo --with-livedotcom-tree=/usr/lib/live-media \
--with-ffmpeg-faac --with-ffmpeg-vorbis --with-ffmpeg-dts \
--with-ffmpeg-ogg --with-ffmpeg-theora --enable-v4l \
--enable-lirc \
--with-wx-config=wx-config-2.6 ${EXTRAFEATURES}
make || return 1
make DESTDIR=${startdir}/pkg install || return 1
for res in 16 32 48; do
install -D -m644 share/vlc${res}x${res}.png \
${startdir}/pkg/usr/share/icons/hicolor/${res}x${res}/apps/vlc.png || return 1
done
rm -rf ${startdir}/pkg/usr/lib/mozilla
}
13. open a terminal "in" that folder and run:
makepkg -c
14. Build of vlc will start
15. Once it's finished, install vlc
pacman -U vlc-0.8.6d-1-i686.pkg.tar.gz
That's it.
HTH
edit: typos + added #0 + modified #12
Last edited by bangkok_manouel (2008-01-23 03:50:22)
Offline
md5sums=() #generate with 'makepkg -g'
Wow better get building :-)
Mr Green
Offline
You may want to bump the pkgver line higher so that pacman doesn't overwrite your working copy of VLC on subtle changes.
By the way, as I mentioned months ago here, VLC has become hyper-sensitive to little changes in other packages. After rebuilding it for the 20th or so time, I dropped it completely.
Offline
@bangkok_manouel Thank you so very kindly for your quick and comprehensive response. I appreciate the effort it took you to type that out and just wanted to let you know i am thrilled not only at a possible solution but at having learned something new.
All the best.. and thanks again.
thewayofzen!
Offline
great how-to bangkok_manouel, vlc works great again. Thanks ... lets hope it won't break again!
Offline
Put this in your X config:
Section "Extensions"
Option "MIT-SHM" "no"
EndSection
Bugfix thanks to lapino (friend of mine).
My coding blog (or an attempt at it)
Archer start page (or an attempt at it)
Offline
I get:
patch: **** Can't open patch file ../vlc.patch : No such file or directory
I checked to make sure I spelled it right and that it was in the right place. What should I do at this point?
BTW, I tried the XConfig fix first, and that didn't do anything.
Offline
I get:
patch: **** Can't open patch file ../vlc.patch : No such file or directory
I checked to make sure I spelled it right and that it was in the right place. What should I do at this point?
BTW, I tried the XConfig fix first, and that didn't do anything.
add vlc.patch to your source array in your VLC PKGBUILD:
source=(http://download.videolan.org/pub/videolan/vlc/${pkgver}/${pkgname}-${pkgver}.tar.bz2 vlc.patch)
Last edited by bangkok_manouel (2008-01-23 02:36:31)
Offline
add vlc.patch to your source array in your VLC PKGBUILD:
source=(http://download.videolan.org/pub/videolan/vlc/${pkgver}/${pkgname}-${pkgver}.tar.bz2 vlc.patch)
Thanks for clarifying that. Obviously, I didn't read through the entire code there.
Offline
OK, I just copied your whole PKGBUILD this time, and now I get this:
patching file modules/codec/ffmpeg/mux.c
Hunk #1 FAILED at 133.
1 out of 1 hunk FAILED -- saving rejects to file modules/codec/ffmpeg/mux.c.rej
==> ERROR: Build Failed
Aborting...
What now?
Offline
OK, I just copied your whole PKGBUILD this time, and now I get this:
patching file modules/codec/ffmpeg/mux.c
Hunk #1 FAILED at 133.
1 out of 1 hunk FAILED -- saving rejects to file modules/codec/ffmpeg/mux.c.rej
==> ERROR: Build Failed
Aborting...What now
add the first 5 characters to the patch, or just copy and paste this code below into the patch file overwriting whats there. Its a typo
--- a/modules/codec/ffmpeg/mux.c
+++ b/modules/codec/ffmpeg/mux.c
@@ -133,7 +133,11 @@ int E_(OpenMux)( vlc_object_t *p_this )
return VLC_EGENERIC;
}+#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(0<<8)+0)
+ p_sys->oc->pb = &p_sys->io;
+#else
p_sys->oc->pb = p_sys->io;
+#endif
p_sys->oc->nb_streams = 0;p_sys->b_write_header = VLC_TRUE;
edit: I think, that's the only reason why a patch would fail, its not the command being issued to apply the patch in the package build
Last edited by jacko (2008-01-23 03:29:16)
Offline
OK, I just copied your whole PKGBUILD this time, and now I get this:
patching file modules/codec/ffmpeg/mux.c
Hunk #1 FAILED at 133.
1 out of 1 hunk FAILED -- saving rejects to file modules/codec/ffmpeg/mux.c.rej
==> ERROR: Build Failed
Aborting...What now
add the first 5 characters to the patch, or just copy and paste this code below into the patch file overwriting whats there. Its a typo
--- a/modules/codec/ffmpeg/mux.c
+++ b/modules/codec/ffmpeg/mux.c
@@ -133,7 +133,11 @@ int E_(OpenMux)( vlc_object_t *p_this )
return VLC_EGENERIC;
}+#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(0<<8)+0)
+ p_sys->oc->pb = &p_sys->io;
+#else
p_sys->oc->pb = p_sys->io;
+#endif
p_sys->oc->nb_streams = 0;p_sys->b_write_header = VLC_TRUE;
Already tried that. Same outcome.
Offline
post your mux.c file.
Offline
/*****************************************************************************
* mux.c: muxer using ffmpeg (libavformat).
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: mux.c 16603 2006-09-10 20:40:21Z sam $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h>
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVFORMAT_H
# include <ffmpeg/avformat.h>
#else
# include <avformat.h>
#endif
#include "ffmpeg.h"
//#define AVFORMAT_DEBUG 1
/* Version checking */
#if (LIBAVFORMAT_BUILD >= 4687) && (defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE))
/*****************************************************************************
* mux_sys_t: mux descriptor
*****************************************************************************/
struct sout_mux_sys_t
{
ByteIOContext io;
int io_buffer_size;
uint8_t *io_buffer;
AVFormatContext *oc;
URLContext url;
URLProtocol prot;
vlc_bool_t b_write_header;
vlc_bool_t b_error;
int64_t i_initial_dts;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Control ( sout_mux_t *, int, va_list );
static int AddStream( sout_mux_t *, sout_input_t * );
static int DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
static int IOWrite( void *opaque, uint8_t *buf, int buf_size );
static offset_t IOSeek( void *opaque, offset_t offset, int whence );
/*****************************************************************************
* Open
*****************************************************************************/
int E_(OpenMux)( vlc_object_t *p_this )
{
AVOutputFormat *file_oformat;
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys;
AVFormatParameters params, *ap = ¶ms;
/* Should we call it only once ? */
av_register_all();
/* Find the requested muxer */
file_oformat =
guess_format(NULL, p_mux->p_access->psz_name, NULL);
if (!file_oformat)
{
msg_Err( p_mux, "unable for find a suitable output format" );
return VLC_EGENERIC;
}
/* Fill p_mux fields */
p_mux->pf_control = Control;
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
p_sys->oc = av_alloc_format_context();
p_sys->oc->oformat = file_oformat;
/* Create I/O wrapper */
p_sys->io_buffer_size = 32768; /* FIXME */
p_sys->io_buffer = malloc( p_sys->io_buffer_size );
p_sys->url.priv_data = p_mux;
p_sys->url.prot = &p_sys->prot;
p_sys->url.prot->name = "VLC I/O wrapper";
p_sys->url.prot->url_open = 0;
p_sys->url.prot->url_read = 0;
p_sys->url.prot->url_write =
(int (*) (URLContext *, unsigned char *, int))IOWrite;
p_sys->url.prot->url_seek =
(offset_t (*) (URLContext *, offset_t, int))IOSeek;
p_sys->url.prot->url_close = 0;
p_sys->url.prot->next = 0;
init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size,
1, &p_sys->url, NULL, IOWrite, IOSeek );
memset( ap, 0, sizeof(*ap) );
if( av_set_parameters( p_sys->oc, ap ) < 0 )
{
msg_Err( p_mux, "invalid encoding parameters" );
av_free( p_sys->oc );
free( p_sys->io_buffer );
free( p_sys );
return VLC_EGENERIC;
}
p_sys->oc->pb = p_sys->io;
p_sys->oc->nb_streams = 0;
p_sys->b_write_header = VLC_TRUE;
p_sys->b_error = VLC_FALSE;
p_sys->i_initial_dts = 0;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close
*****************************************************************************/
void E_(CloseMux)( vlc_object_t *p_this )
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
int i;
if( av_write_trailer( p_sys->oc ) < 0 )
{
msg_Err( p_mux, "could not write trailer" );
}
for( i = 0 ; i < p_sys->oc->nb_streams; i++ )
{
if( p_sys->oc->streams[i]->codec->extradata )
av_free( p_sys->oc->streams[i]->codec->extradata );
av_free( p_sys->oc->streams[i]->codec );
av_free( p_sys->oc->streams[i] );
}
av_free( p_sys->oc );
free( p_sys->io_buffer );
free( p_sys );
}
/*****************************************************************************
* AddStream
*****************************************************************************/
static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
AVCodecContext *codec;
AVStream *stream;
int i_codec_id, i_aspect_num, i_aspect_den;
msg_Dbg( p_mux, "adding input" );
if( !E_(GetFfmpegCodec)( p_input->p_fmt->i_codec, 0, &i_codec_id, 0 ) )
{
msg_Dbg( p_mux, "couldn't find codec for fourcc '%4.4s'",
(char *)&p_input->p_fmt->i_codec );
return VLC_EGENERIC;
}
p_input->p_sys = malloc( sizeof( int ) );
*((int *)p_input->p_sys) = p_sys->oc->nb_streams;
stream = av_new_stream( p_sys->oc, p_sys->oc->nb_streams);
if( !stream )
{
free( p_input->p_sys );
return VLC_EGENERIC;
}
codec = stream->codec;
switch( p_input->p_fmt->i_cat )
{
case AUDIO_ES:
codec->codec_type = CODEC_TYPE_AUDIO;
codec->channels = p_input->p_fmt->audio.i_channels;
codec->sample_rate = p_input->p_fmt->audio.i_rate;
codec->time_base = (AVRational){1, codec->sample_rate};
break;
case VIDEO_ES:
if( !p_input->p_fmt->video.i_frame_rate ||
!p_input->p_fmt->video.i_frame_rate_base )
{
msg_Warn( p_mux, "Missing frame rate, assuming 25fps" );
p_input->p_fmt->video.i_frame_rate = 25;
p_input->p_fmt->video.i_frame_rate_base = 1;
}
codec->codec_type = CODEC_TYPE_VIDEO;
codec->width = p_input->p_fmt->video.i_width;
codec->height = p_input->p_fmt->video.i_height;
av_reduce( &i_aspect_num, &i_aspect_den,
p_input->p_fmt->video.i_aspect,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
av_reduce( &codec->sample_aspect_ratio.num,
&codec->sample_aspect_ratio.den,
i_aspect_num * (int64_t)codec->height,
i_aspect_den * (int64_t)codec->width, 1 << 30 );
codec->time_base.den = p_input->p_fmt->video.i_frame_rate;
codec->time_base.num = p_input->p_fmt->video.i_frame_rate_base;
break;
}
codec->bit_rate = p_input->p_fmt->i_bitrate;
codec->codec_tag = p_input->p_fmt->i_codec;
codec->codec_id = i_codec_id;
if( p_input->p_fmt->i_extra )
{
codec->extradata_size = p_input->p_fmt->i_extra;
codec->extradata = av_malloc( p_input->p_fmt->i_extra );
memcpy( codec->extradata, p_input->p_fmt->p_extra,
p_input->p_fmt->i_extra );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* DelStream
*****************************************************************************/
static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
msg_Dbg( p_mux, "removing input" );
free( p_input->p_sys );
return VLC_SUCCESS;
}
/*
* TODO move this function to src/stream_output.c (used by nearly all muxers)
*/
static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
{
mtime_t i_dts;
int i_stream, i;
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{
block_fifo_t *p_fifo;
p_fifo = p_mux->pp_inputs[i]->p_fifo;
/* We don't really need to have anything in the SPU fifo */
if( p_mux->pp_inputs[i]->p_fmt->i_cat == SPU_ES &&
p_fifo->i_depth == 0 ) continue;
if( p_fifo->i_depth )
{
block_t *p_buf;
p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts )
{
i_dts = p_buf->i_dts;
i_stream = i;
}
}
else return -1;
}
if( pi_stream ) *pi_stream = i_stream;
if( pi_dts ) *pi_dts = i_dts;
if( !p_mux->p_sys->i_initial_dts ) p_mux->p_sys->i_initial_dts = i_dts;
return i_stream;
}
static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
block_t *p_data = block_FifoGet( p_input->p_fifo );
int i_stream = *((int *)p_input->p_sys);
AVStream *p_stream = p_sys->oc->streams[i_stream];
AVPacket pkt = {0};
av_init_packet(&pkt);
pkt.data = p_data->p_buffer;
pkt.size = p_data->i_buffer;
pkt.stream_index = i_stream;
if( p_data->i_flags & BLOCK_FLAG_TYPE_I ) pkt.flags |= PKT_FLAG_KEY;
/* avformat expects pts/dts which start from 0 */
p_data->i_dts -= p_mux->p_sys->i_initial_dts;
p_data->i_pts -= p_mux->p_sys->i_initial_dts;
if( p_data->i_pts > 0 )
pkt.pts = p_data->i_pts * p_stream->time_base.den /
I64C(1000000) / p_stream->time_base.num;
if( p_data->i_dts > 0 )
pkt.dts = p_data->i_dts * p_stream->time_base.den /
I64C(1000000) / p_stream->time_base.num;
if( av_write_frame( p_sys->oc, &pkt ) < 0 )
{
msg_Err( p_mux, "could not write frame (pts: "I64Fd", dts: "I64Fd") "
"(pkt pts: "I64Fd", dts: "I64Fd")",
p_data->i_pts, p_data->i_dts, pkt.pts, pkt.dts );
block_Release( p_data );
return VLC_EGENERIC;
}
block_Release( p_data );
return VLC_SUCCESS;
}
/*****************************************************************************
* Mux: multiplex available data in input fifos
*****************************************************************************/
static int Mux( sout_mux_t *p_mux )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
int i_stream;
if( p_sys->b_error ) return VLC_EGENERIC;
if( p_sys->b_write_header )
{
msg_Dbg( p_mux, "writing header" );
p_sys->b_write_header = VLC_FALSE;
if( av_write_header( p_sys->oc ) < 0 )
{
msg_Err( p_mux, "could not write header" );
p_sys->b_error = VLC_TRUE;
return VLC_EGENERIC;
}
}
for( ;; )
{
if( MuxGetStream( p_mux, &i_stream, 0 ) < 0 ) return VLC_SUCCESS;
MuxBlock( p_mux, p_mux->pp_inputs[i_stream] );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( sout_mux_t *p_mux, int i_query, va_list args )
{
vlc_bool_t *pb_bool;
switch( i_query )
{
case MUX_CAN_ADD_STREAM_WHILE_MUXING:
pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
*pb_bool = VLC_FALSE;
return VLC_SUCCESS;
case MUX_GET_ADD_STREAM_WAIT:
pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
*pb_bool = VLC_TRUE;
return VLC_SUCCESS;
case MUX_GET_MIME:
default:
return VLC_EGENERIC;
}
}
/*****************************************************************************
* I/O wrappers for libavformat
*****************************************************************************/
static int IOWrite( void *opaque, uint8_t *buf, int buf_size )
{
URLContext *p_url = opaque;
sout_mux_t *p_mux = p_url->priv_data;
int i_ret;
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_mux, "IOWrite %i bytes", buf_size );
#endif
block_t *p_buf = block_New( p_mux->p_sout, buf_size );
if( buf_size > 0 ) memcpy( p_buf->p_buffer, buf, buf_size );
i_ret = sout_AccessOutWrite( p_mux->p_access, p_buf );
return i_ret ? i_ret : -1;
}
static offset_t IOSeek( void *opaque, offset_t offset, int whence )
{
URLContext *p_url = opaque;
sout_mux_t *p_mux = p_url->priv_data;
int64_t i_absolute;
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_mux, "IOSeek offset: "I64Fd", whence: %i", offset, whence );
#endif
switch( whence )
{
case SEEK_SET:
i_absolute = offset;
break;
case SEEK_CUR:
case SEEK_END:
default:
return -1;
}
if( sout_AccessOutSeek( p_mux->p_access, i_absolute ) )
{
return -1;
}
return 0;
}
#else /* LIBAVFORMAT_BUILD >= 4687 */
int E_(OpenMux)( vlc_object_t *p_this )
{
return VLC_EGENERIC;
}
void E_(CloseMux)( vlc_object_t *p_this )
{
}
#endif /* LIBAVFORMAT_BUILD >= 4687 */
Offline
Save this as mux.c in src/modules/codec/ffmpeg. Then U can remove the patch elements from the PKGBUILD and run
makepkg -e
The -e switch stop the tarball from extracting the source again and overwriting your files.
/*****************************************************************************
* mux.c: muxer using ffmpeg (libavformat).
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: mux.c 16603 2006-09-10 20:40:21Z sam $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h>
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVFORMAT_H
# include <ffmpeg/avformat.h>
#else
# include <avformat.h>
#endif
#include "ffmpeg.h"
//#define AVFORMAT_DEBUG 1
/* Version checking */
#if (LIBAVFORMAT_BUILD >= 4687) && (defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE))
/*****************************************************************************
* mux_sys_t: mux descriptor
*****************************************************************************/
struct sout_mux_sys_t
{
ByteIOContext io;
int io_buffer_size;
uint8_t *io_buffer;
AVFormatContext *oc;
URLContext url;
URLProtocol prot;
vlc_bool_t b_write_header;
vlc_bool_t b_error;
int64_t i_initial_dts;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Control ( sout_mux_t *, int, va_list );
static int AddStream( sout_mux_t *, sout_input_t * );
static int DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
static int IOWrite( void *opaque, uint8_t *buf, int buf_size );
static offset_t IOSeek( void *opaque, offset_t offset, int whence );
/*****************************************************************************
* Open
*****************************************************************************/
int E_(OpenMux)( vlc_object_t *p_this )
{
AVOutputFormat *file_oformat;
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys;
AVFormatParameters params, *ap = ¶ms;
/* Should we call it only once ? */
av_register_all();
/* Find the requested muxer */
file_oformat =
guess_format(NULL, p_mux->p_access->psz_name, NULL);
if (!file_oformat)
{
msg_Err( p_mux, "unable for find a suitable output format" );
return VLC_EGENERIC;
}
/* Fill p_mux fields */
p_mux->pf_control = Control;
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
p_sys->oc = av_alloc_format_context();
p_sys->oc->oformat = file_oformat;
/* Create I/O wrapper */
p_sys->io_buffer_size = 32768; /* FIXME */
p_sys->io_buffer = malloc( p_sys->io_buffer_size );
p_sys->url.priv_data = p_mux;
p_sys->url.prot = &p_sys->prot;
p_sys->url.prot->name = "VLC I/O wrapper";
p_sys->url.prot->url_open = 0;
p_sys->url.prot->url_read = 0;
p_sys->url.prot->url_write =
(int (*) (URLContext *, unsigned char *, int))IOWrite;
p_sys->url.prot->url_seek =
(offset_t (*) (URLContext *, offset_t, int))IOSeek;
p_sys->url.prot->url_close = 0;
p_sys->url.prot->next = 0;
init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size,
1, &p_sys->url, NULL, IOWrite, IOSeek );
memset( ap, 0, sizeof(*ap) );
if( av_set_parameters( p_sys->oc, ap ) < 0 )
{
msg_Err( p_mux, "invalid encoding parameters" );
av_free( p_sys->oc );
free( p_sys->io_buffer );
free( p_sys );
return VLC_EGENERIC;
}
#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(0<<8)+0)
p_sys->oc->pb = &p_sys->io;
#else
p_sys->oc->pb = p_sys->io;
#endif
p_sys->oc->nb_streams = 0;
p_sys->b_write_header = VLC_TRUE;
p_sys->b_error = VLC_FALSE;
p_sys->i_initial_dts = 0;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close
*****************************************************************************/
void E_(CloseMux)( vlc_object_t *p_this )
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
int i;
if( av_write_trailer( p_sys->oc ) < 0 )
{
msg_Err( p_mux, "could not write trailer" );
}
for( i = 0 ; i < p_sys->oc->nb_streams; i++ )
{
if( p_sys->oc->streams[i]->codec->extradata )
av_free( p_sys->oc->streams[i]->codec->extradata );
av_free( p_sys->oc->streams[i]->codec );
av_free( p_sys->oc->streams[i] );
}
av_free( p_sys->oc );
free( p_sys->io_buffer );
free( p_sys );
}
/*****************************************************************************
* AddStream
*****************************************************************************/
static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
AVCodecContext *codec;
AVStream *stream;
int i_codec_id, i_aspect_num, i_aspect_den;
msg_Dbg( p_mux, "adding input" );
if( !E_(GetFfmpegCodec)( p_input->p_fmt->i_codec, 0, &i_codec_id, 0 ) )
{
msg_Dbg( p_mux, "couldn't find codec for fourcc '%4.4s'",
(char *)&p_input->p_fmt->i_codec );
return VLC_EGENERIC;
}
p_input->p_sys = malloc( sizeof( int ) );
*((int *)p_input->p_sys) = p_sys->oc->nb_streams;
stream = av_new_stream( p_sys->oc, p_sys->oc->nb_streams);
if( !stream )
{
free( p_input->p_sys );
return VLC_EGENERIC;
}
codec = stream->codec;
switch( p_input->p_fmt->i_cat )
{
case AUDIO_ES:
codec->codec_type = CODEC_TYPE_AUDIO;
codec->channels = p_input->p_fmt->audio.i_channels;
codec->sample_rate = p_input->p_fmt->audio.i_rate;
codec->time_base = (AVRational){1, codec->sample_rate};
break;
case VIDEO_ES:
if( !p_input->p_fmt->video.i_frame_rate ||
!p_input->p_fmt->video.i_frame_rate_base )
{
msg_Warn( p_mux, "Missing frame rate, assuming 25fps" );
p_input->p_fmt->video.i_frame_rate = 25;
p_input->p_fmt->video.i_frame_rate_base = 1;
}
codec->codec_type = CODEC_TYPE_VIDEO;
codec->width = p_input->p_fmt->video.i_width;
codec->height = p_input->p_fmt->video.i_height;
av_reduce( &i_aspect_num, &i_aspect_den,
p_input->p_fmt->video.i_aspect,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
av_reduce( &codec->sample_aspect_ratio.num,
&codec->sample_aspect_ratio.den,
i_aspect_num * (int64_t)codec->height,
i_aspect_den * (int64_t)codec->width, 1 << 30 );
codec->time_base.den = p_input->p_fmt->video.i_frame_rate;
codec->time_base.num = p_input->p_fmt->video.i_frame_rate_base;
break;
}
codec->bit_rate = p_input->p_fmt->i_bitrate;
codec->codec_tag = p_input->p_fmt->i_codec;
codec->codec_id = i_codec_id;
if( p_input->p_fmt->i_extra )
{
codec->extradata_size = p_input->p_fmt->i_extra;
codec->extradata = av_malloc( p_input->p_fmt->i_extra );
memcpy( codec->extradata, p_input->p_fmt->p_extra,
p_input->p_fmt->i_extra );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* DelStream
*****************************************************************************/
static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
msg_Dbg( p_mux, "removing input" );
free( p_input->p_sys );
return VLC_SUCCESS;
}
/*
* TODO move this function to src/stream_output.c (used by nearly all muxers)
*/
static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
{
mtime_t i_dts;
int i_stream, i;
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{
block_fifo_t *p_fifo;
p_fifo = p_mux->pp_inputs[i]->p_fifo;
/* We don't really need to have anything in the SPU fifo */
if( p_mux->pp_inputs[i]->p_fmt->i_cat == SPU_ES &&
p_fifo->i_depth == 0 ) continue;
if( p_fifo->i_depth )
{
block_t *p_buf;
p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts )
{
i_dts = p_buf->i_dts;
i_stream = i;
}
}
else return -1;
}
if( pi_stream ) *pi_stream = i_stream;
if( pi_dts ) *pi_dts = i_dts;
if( !p_mux->p_sys->i_initial_dts ) p_mux->p_sys->i_initial_dts = i_dts;
return i_stream;
}
static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
block_t *p_data = block_FifoGet( p_input->p_fifo );
int i_stream = *((int *)p_input->p_sys);
AVStream *p_stream = p_sys->oc->streams[i_stream];
AVPacket pkt = {0};
av_init_packet(&pkt);
pkt.data = p_data->p_buffer;
pkt.size = p_data->i_buffer;
pkt.stream_index = i_stream;
if( p_data->i_flags & BLOCK_FLAG_TYPE_I ) pkt.flags |= PKT_FLAG_KEY;
/* avformat expects pts/dts which start from 0 */
p_data->i_dts -= p_mux->p_sys->i_initial_dts;
p_data->i_pts -= p_mux->p_sys->i_initial_dts;
if( p_data->i_pts > 0 )
pkt.pts = p_data->i_pts * p_stream->time_base.den /
I64C(1000000) / p_stream->time_base.num;
if( p_data->i_dts > 0 )
pkt.dts = p_data->i_dts * p_stream->time_base.den /
I64C(1000000) / p_stream->time_base.num;
if( av_write_frame( p_sys->oc, &pkt ) < 0 )
{
msg_Err( p_mux, "could not write frame (pts: "I64Fd", dts: "I64Fd") "
"(pkt pts: "I64Fd", dts: "I64Fd")",
p_data->i_pts, p_data->i_dts, pkt.pts, pkt.dts );
block_Release( p_data );
return VLC_EGENERIC;
}
block_Release( p_data );
return VLC_SUCCESS;
}
/*****************************************************************************
* Mux: multiplex available data in input fifos
*****************************************************************************/
static int Mux( sout_mux_t *p_mux )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
int i_stream;
if( p_sys->b_error ) return VLC_EGENERIC;
if( p_sys->b_write_header )
{
msg_Dbg( p_mux, "writing header" );
p_sys->b_write_header = VLC_FALSE;
if( av_write_header( p_sys->oc ) < 0 )
{
msg_Err( p_mux, "could not write header" );
p_sys->b_error = VLC_TRUE;
return VLC_EGENERIC;
}
}
for( ;; )
{
if( MuxGetStream( p_mux, &i_stream, 0 ) < 0 ) return VLC_SUCCESS;
MuxBlock( p_mux, p_mux->pp_inputs[i_stream] );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( sout_mux_t *p_mux, int i_query, va_list args )
{
vlc_bool_t *pb_bool;
switch( i_query )
{
case MUX_CAN_ADD_STREAM_WHILE_MUXING:
pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
*pb_bool = VLC_FALSE;
return VLC_SUCCESS;
case MUX_GET_ADD_STREAM_WAIT:
pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
*pb_bool = VLC_TRUE;
return VLC_SUCCESS;
case MUX_GET_MIME:
default:
return VLC_EGENERIC;
}
}
/*****************************************************************************
* I/O wrappers for libavformat
*****************************************************************************/
static int IOWrite( void *opaque, uint8_t *buf, int buf_size )
{
URLContext *p_url = opaque;
sout_mux_t *p_mux = p_url->priv_data;
int i_ret;
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_mux, "IOWrite %i bytes", buf_size );
#endif
block_t *p_buf = block_New( p_mux->p_sout, buf_size );
if( buf_size > 0 ) memcpy( p_buf->p_buffer, buf, buf_size );
i_ret = sout_AccessOutWrite( p_mux->p_access, p_buf );
return i_ret ? i_ret : -1;
}
static offset_t IOSeek( void *opaque, offset_t offset, int whence )
{
URLContext *p_url = opaque;
sout_mux_t *p_mux = p_url->priv_data;
int64_t i_absolute;
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_mux, "IOSeek offset: "I64Fd", whence: %i", offset, whence );
#endif
switch( whence )
{
case SEEK_SET:
i_absolute = offset;
break;
case SEEK_CUR:
case SEEK_END:
default:
return -1;
}
if( sout_AccessOutSeek( p_mux->p_access, i_absolute ) )
{
return -1;
}
return 0;
}
#else /* LIBAVFORMAT_BUILD >= 4687 */
int E_(OpenMux)( vlc_object_t *p_this )
{
return VLC_EGENERIC;
}
void E_(CloseMux)( vlc_object_t *p_this )
{
}
#endif /* LIBAVFORMAT_BUILD >= 4687 */
here is the new PKGBUILD to use, once u saved and updated mux.c
# $Id $
# Maintainer:
# Contributor: Sarah Hay <sarahhay@mb.sympatico.ca>
pkgname=vlc
pkgver=0.8.6d
pkgrel=1
pkgdesc="A multi-platform MPEG, VCD/DVD, and DivX player"
depends=('libmad>=0.15.1b-2' 'libmpeg2>=0.4.0b-3' 'ffmpeg>=20070131'
'wxgtk-2.6>=2.6.4' 'hal>=0.5.9.1' 'libid3tag>=0.15.1b-2' 'bash>=3.1'
'libdvbpsi4>=0.1.5' 'fribidi>=0.10.7' 'sysfsutils>=2.0.0'
'libdvdnav>=0.1.10-2' 'libdvdread>=0.9.4-3' 'xvidcore>=1.1.0-2'
'libmatroska>=0.8.0' 'libxv>=1.0.1' 'libcdio>=0.78.2' 'desktop-file-utils')
arch=(i686 x86_64)
license=('GPL')
url="http://www.videolan.org/vlc/"
#Note: These build plugins, so I guess they'd be runtime depends
makedepends=('live-media' 'gnome-vfs' 'mesa' 'sdl_image' 'libmpcdec' 'speex'
'libnotify' 'libmodplug' 'lirc-utils')
install=${pkgname}.install
source=(http://download.videolan.org/pub/videolan/vlc/${pkgver}/${pkgname}-${pkgver}.tar.bz2)
build() {
cd $startdir/src/${pkgname}-${pkgver}
sed -i -e 's:#include <vlc\/vlc.h>:#include <vlc/vlc.h> \n #include <locale.h>: ' src/misc/charset.c
sed -i -e 's:/truetype/freefont/FreeSerifBold.ttf:/TTF/VeraBd.ttf:' modules/misc/freetype.c
# features that won't build on x86_64
[ "${CARCH}" = "i686" ] && EXTRAFEATURES="--enable-loader"
./configure --prefix=/usr --enable-dvdread --enable-dvdnav --enable-madi \
--enable-ffmpeg --disable-rpath --enable-wxwidgets --enable-faad \
--enable-alsa --enable-skins2 --enable-livedotcom --enable-dvb --enable-theora \
--enable-dmo --with-livedotcom-tree=/usr/lib/live-media \
--with-ffmpeg-faac --with-ffmpeg-vorbis --with-ffmpeg-dts \
--with-ffmpeg-ogg --with-ffmpeg-theora --enable-v4l \
--enable-lirc \
--with-wx-config=wx-config-2.6 ${EXTRAFEATURES}
make || return 1
make DESTDIR=${startdir}/pkg install || return 1
for res in 16 32 48; do
install -D -m644 share/vlc${res}x${res}.png \
${startdir}/pkg/usr/share/icons/hicolor/${res}x${res}/apps/vlc.png || return 1
done
rm -rf ${startdir}/pkg/usr/lib/mozilla
}
Offline
Thanks a lot! It's building now.
Offline
Thanks a lot! It's building now.
did ffmpeg compile ok with the swscaler disabled? I hope u did ffmpeg package first, I think u have to and have it installed so that vlc can compile against it.
If so, this will fix your problem, did mine.
Offline
jmetal88 wrote:Thanks a lot! It's building now.
did ffmpeg compile ok with the swscaler disabled? I hope u did ffmpeg package first, I think u have to and have it installed so that vlc can compile against it.
If so, this will fix your problem, did mine.
Yeah I did the ffmpeg first. It didn't have any problems.
Offline
@jacko: thanks for pointing at the typos in the patch. edited.
Offline
Put this in your X config:
Section "Extensions" Option "MIT-SHM" "no" EndSection
Bugfix thanks to lapino (friend of mine).
This worked when vlc broke after upgrading to xserver 1.4.0.90-4.
Then xserver upgraded to -5 and vlc was ok, didn't need the above addition in xorg.conf but then again ffmpeg and x264 upgraded and vlc broke again. So recompiling ffmpeg and after that vlc made it work again. (until next time!)
I think that's the storyline so far, right?
Offline
... hence I don't give a toss until a new version of VCL fix this. No other program as far as I can see is in any way affected.
Offline
Hi when I write: makepkg -c to vlc folder I get:
-> Found vlc.patch in build dir
==> WARNING: Integrity checks (md5) are missing or incomplete.
==> Extracting Sources...
-> bsdtar -x -f vlc-0.8.6d.tar.bz2
==> Entering fakeroot environment...
==> Starting build()...
patching file modules/codec/ffmpeg/mux.c
patch: **** malformed patch at line 11: +#endif
==> ERROR: Build Failed.
Aborting...
How to fix it?
Thanks
Last edited by k3rn31 (2008-01-28 13:51:01)
~k3rn31
Offline
==> ERROR: Build Failed. Aborting...
How to fix it?
Thanks
I've used
--- modules/codec/ffmpeg/mux.c
+++ modules/codec/ffmpeg/mux.c@@ -133,7 +133,11 @@ int E_(OpenMux)( vlc_object_t *p_this )
return VLC_EGENERIC;
}+#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(0<<8)+0)
+ p_sys->oc->pb = &p_sys->io;
+#else
p_sys->oc->pb = p_sys->io;
+#endif
p_sys->oc->nb_streams = 0;
p_sys->b_write_header = VLC_TRUE;
with the following inside the PKGBUILD
patch -Np0 < $startdir/src/vlc.patch
Offline
Thank you. I'll try these.
I get again an error:
make: *** [all] Error 2
==> ERROR: Build Failed.
Aborting...
Last edited by k3rn31 (2008-01-28 14:55:35)
~k3rn31
Offline
Thank you. I'll try these.
I get again an error:
make: *** [all] Error 2
==> ERROR: Build Failed.
Aborting...
please include the lines before the error (so the actual error) so we can see what is happening
Offline