Hello,
Here is a patch for the last revision (8353) of
https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/video
the installation and use of this patck for video package have been
tested with octave 3.4.2 and ffmpeg-0.7
Regards,
--
Pierre Gronlier
Index: DESCRIPTION
===================================================================
--- DESCRIPTION (revision 8353)
+++ DESCRIPTION (working copy)
@@ -7,6 +7,6 @@
Description: Implements addframe, avifile, aviinfo, and aviread, using ffmpeg. (and approximately conforms to Matlab interface)
Depends: octave (>= 2.9.12)
Autoload: yes
-SystemRequirements: ffmpeg
+SystemRequirements: >=ffmpeg-0.7
License: BSD
Url: http://octave.sf.net
Index: src/AVHandler.cc
===================================================================
--- src/AVHandler.cc (revision 8353)
+++ src/AVHandler.cc (working copy)
@@ -64,7 +64,7 @@
if (av_output->pb->buf_ptr) {
while (write_frame() > 0) {}
av_write_trailer(av_output);
- if (url_fclose( av_output->pb ) < 0)
+ if (avio_close( av_output->pb ) < 0)
(*out) << "AVHandler: cannot close output file" << std::endl;
}
av_free(av_output);
@@ -94,11 +94,11 @@
AVHandler::setup_write() {
av_register_all();
- AVOutputFormat *avifmt;
- for (avifmt = first_oformat; avifmt != NULL; avifmt = avifmt->next) {
- if (std::string(avifmt->name) == "avi") {
- break;
- }
+ AVOutputFormat *avifmt = NULL;
+ while (NULL != (avifmt = av_oformat_next(avifmt))) {
+ if (std::string(avifmt->name) == "avi") {
+ break;
+ }
}
if (!avifmt) {
@@ -106,7 +106,7 @@
return -1;
}
- av_output = av_alloc_format_context();
+ av_output = avformat_alloc_context();
if (!av_output) {
(*out) << "AVHandler: Memory error allocating format context" << std::endl;
return -1;
@@ -127,11 +127,11 @@
}
snprintf(av_output->filename, sizeof(av_output->filename), "%s", filename.c_str());
- snprintf(av_output->title, sizeof(av_output->title), "%s", title.c_str());
- snprintf(av_output->author, sizeof(av_output->author), "%s", author.c_str());
- snprintf(av_output->comment, sizeof(av_output->comment), "%s", comment.c_str());
+ // FIXME: snprintf(av_output->title, sizeof(av_output->title), "%s", title.c_str());
+ // FIXME: snprintf(av_output->author, sizeof(av_output->author), "%s", author.c_str());
+ // FIXME: snprintf(av_output->comment, sizeof(av_output->comment), "%s", comment.c_str());
- if (url_fopen(&av_output->pb, filename.c_str(), URL_WRONLY) < 0) {
+ if (avio_open(&av_output->pb, filename.c_str(), URL_WRONLY) < 0) {
(*out) << "AVHandler: Could not open \"" << filename << "\" for output" << std::endl;
return -1;
}
@@ -162,7 +162,7 @@
}
for (int i=0; i < av_input->nb_streams; i++) {
- if (av_input->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
+ if (av_input->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
vstream = av_input->streams[i];
break;
}
@@ -173,7 +173,7 @@
}
for (int i=0; i < av_input->nb_streams; i++) {
- if (av_input->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
+ if (av_input->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
astream = av_input->streams[i];
break;
}
@@ -204,9 +204,9 @@
width = vstream->codec->width;
height = vstream->codec->height;
- title = av_input->title;
- author = av_input->author;
- comment = av_input->comment;
+ // FIXME: title = av_input->title;
+ // FIXME: author = av_input->author;
+ // FIXME: comment = av_input->comment;
rgbframe = create_frame(PIX_FMT_RGB24);
if (!rgbframe) return -1;
@@ -258,7 +258,7 @@
if (c->coded_frame)
pkt.pts = c->coded_frame->pts;
if (c->coded_frame && c->coded_frame->key_frame)
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
/// XXX FIXME XXX does this ensure that the first frame is always a key frame?
if (av_write_frame(av_output, &pkt) != 0) {
@@ -296,7 +296,8 @@
(*out) << "AVHandler: Error seeking to " << target_timestamp << std::endl;
return -1;
}
- cc->hurry_up = 1;
+ // http://ffmpeg.org/pipermail/ffmpeg-cvslog/2011-April/035933.html
+ // FIXME: deprecated: cc->hurry_up = 1;
// Flush stream buffers after seek
avcodec_flush_buffers(cc);
@@ -324,14 +325,14 @@
return -1;
}
- if (url_feof(av_input->pb)) {
+ if (av_input->pb->eof_reached) {
(*out) << "AVHandler: EOF reached" << std::endl;
}
}
// Decode the packet into a frame
int frameFinished;
- if (avcodec_decode_video(cc, frame, &frameFinished, packet.data, packet.size) < 0) {
+ if (avcodec_decode_video2(cc, frame, &frameFinished, &packet) < 0) {
(*out) << "AVHandler: Error decoding video stream" << std::endl;
av_free_packet(&packet);
av_free(frame); frame = NULL;
@@ -342,8 +343,10 @@
current_timestamp = (uint64_t)(vstream->cur_dts * AV_TIME_BASE * (long double)stream_time_base);
}
}
- cc->hurry_up = 0;
+ // http://ffmpeg.org/pipermail/ffmpeg-cvslog/2011-April/035933.html
+ // FIXME: deprecated: cc->hurry_up = 0;
+
SwsContext *sc = sws_getContext(cc->width, cc->height, cc->pix_fmt,
cc->width, cc->height, PIX_FMT_BGR24,
SWS_BICUBIC, 0, 0, 0);
@@ -361,9 +364,9 @@
(*out) << "Supported file formats:" << std::endl;
av_register_all();
- AVOutputFormat *ofmt;
- for (ofmt = first_oformat; ofmt != NULL; ofmt = ofmt->next) {
- (*out) << ofmt->name << " ";
+ AVOutputFormat *ofmt = NULL;
+ while (NULL != (ofmt = av_oformat_next(ofmt))) {
+ (*out) << ofmt->name << " ";
}
(*out) << std::endl << std::endl;
}
@@ -375,7 +378,7 @@
AVCodec *codec;
for (codec = av_codec_next(0); codec != NULL; codec = av_codec_next(codec)) {
- if ((codec->type == CODEC_TYPE_VIDEO) &&
+ if ((codec->type == AVMEDIA_TYPE_VIDEO) &&
(codec->encode)) {
(*out) << codec->name << " ";
}
@@ -395,7 +398,7 @@
cc = vstream->codec;
- cc->codec_type = CODEC_TYPE_VIDEO;
+ cc->codec_type = AVMEDIA_TYPE_VIDEO;
cc->bit_rate = bitrate;
cc->width = width;
Index: src/AVHandler.h
===================================================================
--- src/AVHandler.h (revision 8353)
+++ src/AVHandler.h (working copy)
@@ -27,8 +27,11 @@
#define VIDEO_OUTBUF_SIZE 200000
+// FIXME: should define -D__STDC_CONSTANT_MACROS instead of the following
#define INT64_C
+#define UINT64_C
#define __STDC_CONSTANT_MACROS
+
#include <errno.h>
extern "C" {
#if defined (HAVE_FFMPEG_AVFORMAT_H)
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev