I am running on Fedora 18 x64 and ran into the same issues. I compiled a bunch of different fixes into a patch:
diff -rupN a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp
--- a/src/zm_ffmpeg_camera.cpp 2013-05-13 12:33:58.236394833 -0400
+++ b/src/zm_ffmpeg_camera.cpp 2013-05-13 12:33:58.241394902 -0400
@@ -54,11 +54,11 @@ FfmpegCamera::~FfmpegCamera()
if ( mCodecContext )
{
avcodec_close( mCodecContext );
- mCodecContext = NULL; // Freed by av_close_input_file
+ mCodecContext = NULL; // Freed by avformat_close_input
}
if ( mFormatContext )
{
- av_close_input_file( mFormatContext );
+ avformat_close_input( &mFormatContext );
mFormatContext = NULL;
}
@@ -91,11 +91,11 @@ int FfmpegCamera::PrimeCapture()
Info( "Priming capture from %s", mPath.c_str() );
// Open the input, not necessarily a file
- if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 )
+ if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 )
Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) );
// Locate stream info from input
- if ( av_find_stream_info( mFormatContext ) < 0 )
+ if ( avformat_find_stream_info( mFormatContext, NULL ) < 0 )
Fatal( "Unable to find stream info from %s due to: %s", mPath.c_str(), strerror(errno) );
// Find first video stream present
@@ -122,7 +122,7 @@ int FfmpegCamera::PrimeCapture()
Fatal( "Can't find codec for video stream from %s", mPath.c_str() );
// Open the codec
- if ( avcodec_open( mCodecContext, mCodec ) < 0 )
+ if ( avcodec_open2( mCodecContext, mCodec, NULL ) < 0 )
Fatal( "Unable to open codec for video stream from %s", mPath.c_str() );
// Allocate space for the native video frame
diff -rupN a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h
--- a/src/zm_ffmpeg.h 2013-05-13 12:33:58.265395234 -0400
+++ b/src/zm_ffmpeg.h 2013-05-13 12:33:58.269395289 -0400
@@ -26,17 +26,17 @@
extern "C" {
#endif
#if HAVE_LIBAVUTIL_AVUTIL_H
-#include <libavutil/avutil.h>
+#include <ffmpeg/libavutil/avutil.h>
#endif
#if HAVE_LIBAVCODEC_AVCODEC_H
-#include <libavcodec/avcodec.h>
+#include <ffmpeg/libavcodec/avcodec.h>
#endif
#if HAVE_LIBAVFORMAT_AVFORMAT_H
-#include <libavformat/avformat.h>
+#include <ffmpeg/libavformat/avformat.h>
#endif
#if HAVE_LIBSWSCALE
#if HAVE_LIBSWSCALE_SWSCALE_H
-#include <libswscale/swscale.h>
+#include <ffmpeg/libswscale/swscale.h>
#endif
#endif // HAVE_LIBSWSCALE
#ifdef __cplusplus
diff -rupN a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp
--- a/src/zm_local_camera.cpp 2013-05-13 12:33:58.246394971 -0400
+++ b/src/zm_local_camera.cpp 2013-05-13 12:33:58.251395040 -0400
@@ -739,7 +739,8 @@ void LocalCamera::Terminate()
{
Debug( 3, "Terminating video stream" );
//enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- enum v4l2_buf_type type = v4l2_data.fmt.type;
+ //enum v4l2_buf_type type = v4l2_data.fmt.type;
+ enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type;
if ( vidioctl( vid_fd, VIDIOC_STREAMOFF, &type ) < 0 )
Error( "Failed to stop capture stream: %s", strerror(errno) );
@@ -1519,7 +1520,8 @@ int LocalCamera::PrimeCapture()
Debug( 3, "Starting video stream" );
//enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- enum v4l2_buf_type type = v4l2_data.fmt.type;
+ //enum v4l2_buf_type type = v4l2_data.fmt.type;
+ enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type;
if ( vidioctl( vid_fd, VIDIOC_STREAMON, &type ) < 0 )
Fatal( "Failed to start capture stream: %s", strerror(errno) );
}
diff -rupN a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp
--- a/src/zm_mpeg.cpp 2013-05-13 12:33:58.256395109 -0400
+++ b/src/zm_mpeg.cpp 2013-05-13 12:33:58.260395165 -0400
@@ -77,7 +77,8 @@ void VideoStream::SetupCodec( int colour
ost = NULL;
if (of->video_codec != CODEC_ID_NONE)
{
- ost = av_new_stream(ofc, 0);
+ ost = avformat_new_stream(ofc, NULL);
+ ost->id = 0;
if (!ost)
{
Panic( "Could not alloc stream" );
@@ -126,16 +127,6 @@ void VideoStream::SetupCodec( int colour
}
}
-void VideoStream::SetParameters()
-{
- /* set the output parameters (must be done even if no
- parameters). */
- if ( av_set_parameters(ofc, NULL) < 0 )
- {
- Panic( "Invalid output format parameters" );
- }
- //dump_format(ofc, 0, filename, 1);
-}
const char *VideoStream::MimeType() const
{
@@ -176,7 +167,7 @@ void VideoStream::OpenStream()
}
/* open the codec */
- if ( avcodec_open(c, codec) < 0 )
+ if ( avcodec_open2(c, codec, NULL) < 0 )
{
Panic( "Could not open codec" );
}
@@ -222,7 +213,7 @@ void VideoStream::OpenStream()
if ( !(of->flags & AVFMT_NOFILE) )
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
- if ( avio_open(&ofc->pb, filename, URL_WRONLY) < 0 )
+ if ( avio_open(&ofc->pb, filename, AVIO_FLAG_WRITE) < 0 )
#else
if ( url_fopen(&ofc->pb, filename, URL_WRONLY) < 0 )
#endif
@@ -241,7 +232,10 @@ void VideoStream::OpenStream()
}
/* write the stream header, if any */
- av_write_header(ofc);
+ if (avformat_write_header(ofc, NULL) < 0)
+ {
+ Panic( "Invalid output format parameters or unable to write header" );
+ }
}
VideoStream::VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height )
@@ -253,7 +247,6 @@ VideoStream::VideoStream( const char *fi
SetupFormat( filename, format );
SetupCodec( colours, width, height, bitrate, frame_rate );
- SetParameters();
}
VideoStream::~VideoStream()
diff -rupN a/src/zm_mpeg.h b/src/zm_mpeg.h
--- a/src/zm_mpeg.h 2013-05-13 12:33:58.274395358 -0400
+++ b/src/zm_mpeg.h 2013-05-13 12:33:58.279395427 -0400
@@ -55,7 +55,6 @@ protected:
void SetupFormat( const char *p_filename, const char *format );
void SetupCodec( int colours, int width, int height, int bitrate, double frame_rate );
- void SetParameters();
public:
VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height );
diff -rupN a/src/zm_thread.h b/src/zm_thread.h
--- a/src/zm_thread.h 2013-05-13 12:33:58.283395482 -0400
+++ b/src/zm_thread.h 2013-05-13 12:33:58.288395551 -0400
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
-
+#include <unistd.h>
#ifndef ZM_THREAD_H
#define ZM_THREAD_H
* Don't forget to change ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS to appropriate values