patch video-oct to use newer
Hanspeter Niederstrasser <[email protected]>
| Newsgroups | gmane.os.apple.fink.devel |
|---|---|
| Organization | Snaggled Works |
| Message-ID | <[email protected]> |
Attached are .info/.patch files to update video-oct to use newer versions of ffmpeg and not the really old libavcodec53 library. The patch is primarily from here (unreleased upstream): https://sourceforge.net/p/octave/video/ci/7caa40bb8a47ba943d63f16896b4771854ebfd68/ But I also added the chunk around line 124 from here: https://github.com/tufei/octave-forge-video/commit/19119e2ec936285c6e7e4fc903d97d7f3efc8648#diff-ee390d07771903074cab05b278a4bf4aL123 because av_set_parameters no longer exists and I couldn't find a replacement for that function I also removed -D__STDC_CONSTANT_MACROS from CXXFLAGS because it was giving a lot of "__STDC_CONSTANT_MACROS macro redefined" warnings. There are still UINT64_C redefined issues which might be taken care of with https://sourceforge.net/p/octave/video/ci/c341586726c96ca5aa5821b38792b1bf7fe8adc0/#diff-8 from a later commit, but I didn't test it in order to minimize the cherry picking. This built with ffmpeg-1.2, -2.0, and -2.4, but I have no way of knowing if the resulting build actually works and doesn't cause total protonic reversal. Hanspeter ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Fink-devel mailing list [email protected] List archive: http://news.gmane.org/gmane.os.apple.fink.devel Subscription management: https://lists.sourceforge.net/lists/listinfo/fink-devel
video-oct.info
(text/plain, 2.7 KB)
Info2: << Package: video-oct%type_pkg[oct] Version: 1.0.2 Type: oct (3.0.5 3.2.4 3.4.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4), forge (video), gcc (4.9) Revision: 6 Distribution: (%type_pkg[oct] << 364) 10.7, (%type_pkg[oct] << 364) 10.8 Maintainer: Alexander Hansen <[email protected]> Homepage: http://octave.sourceforge.net/video/index.html Description: FFmpeg interface for Octave DescDetail: << Implements addframe, avifile, aviinfo, and aviread, using ffmpeg. (and approximately conforms to the Matlab interface) This package provides the following functions: addframe avifile aviinfo aviread << License: BSD # reported to have issues with ffmpeg suite newer than avcodec53 # possible fixes: # https://github.com/tufei/octave-forge-video # http://lists.gnu.org/archive/html/help-octave/2011-12/msg00405.html BuildDepends: << ( %type_pkg[oct] << 360 ) liboctave%type_pkg[oct]-gcc%type_pkg[gcc]-dev, ( %type_pkg[oct] >= 360 ) liboctave%type_pkg[oct]-dev, fftw3, ( %type_pkg[oct] = 305 ) hdf5.9-oldapi, ( %type_pkg[oct] != 305 ) hdf5.9, libavcodec56-2.4-dev, libavformat56-2.4-dev, libavutil54-2.4-dev, libswscale3-2.4-dev, pkgconfig, fink-octave-scripts (>= 0.3.0-1) << Depends: << octave%type_pkg[oct]-interpreter, libavcodec56-2.4-shlibs, libavformat56-2.4-shlibs, libavutil54-2.4-shlibs, libswscale3-2.4-shlibs, ( %type_pkg[oct] << 360 ) gcc%type_pkg[gcc]-shlibs << Conflicts: octave-forge Source: mirror:sourceforge:octave/Octave%%20Forge%%20Packages/R2009-05-08/%type_raw[forge]-%v.tar.gz Source-MD5: e45e827ce5f409191aa9e9a61058e4ce PatchFile: %{ni}.patch PatchFile-MD5: b50739043be90e99f33ae10de3b8c7be PatchScript: << %{default_script} << NoSetCPPFLAGS: true NoSetLDFLAGS: true UseMaxBuildJobs: false BuildAsNobody: false CompileScript: << #!/bin/sh -ev pkgsrc=%type_raw[forge]-%v ##### Invariant stuff begins here ##### %p/share/fink-octave-scripts/octave-forge-patch.sh %type_raw[forge] %v %type_raw[oct] %b %i $pkgsrc export PKG_CONFIG_PATH=%p/lib/ffmpeg-2.4/lib/pkgconfig:$PKG_CONFIG_PATH ./octave-forge-compile.sh << InstallScript: ./octave-forge-install.sh PostInstScript: %p/share/octave/%type_raw[oct]/%type_raw[forge]/octave-forge-postinst.sh PreRmScript: %p/share/octave/%type_raw[oct]/%type_raw[forge]/octave-forge-prerm.sh DescPackaging: << For this package: Numerous patches to use ffmpeg-0.8.4. Common for all octave-forge packages: Preinst and postinst scripts are dynamically set up via %p/share/fink-octave-scripts/octave-forge-patch.sh because Octave's package manager can't cope with non-literal arguments. The Type: forge (pkgname) is used to minimize what needs to be changed when using this .info file as a template, or when the package name contains underscores. << <<
video-oct.patch
(text/plain, 8.4 KB)
diff -Nurd video-1.0.2/src/AVHandler.cc video-1.0.2.patched/src/AVHandler.cc
--- video-1.0.2/src/AVHandler.cc 2009-05-08 08:17:36.000000000 -0500
+++ video-1.0.2.patched/src/AVHandler.cc 2015-02-14 05:56:20.000000000 -0600
@@ -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);
@@ -78,7 +78,7 @@
}
if (av_input) {
- av_close_input_file(av_input);
+ avformat_close_input(&av_input);
} else {
// close output stream
if (vstream) av_freep(&vstream);
@@ -94,8 +94,8 @@
AVHandler::setup_write() {
av_register_all();
- AVOutputFormat *avifmt;
- for (avifmt = first_oformat; avifmt != NULL; avifmt = avifmt->next) {
+ AVOutputFormat *avifmt = NULL;
+ while (NULL != (avifmt = av_oformat_next(avifmt))) {
if (std::string(avifmt->name) == "avi") {
break;
}
@@ -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;
@@ -120,18 +120,12 @@
if (add_video_stream() != 0) return -1;
}
- /* av_set_parameters is mandatory */
- if (av_set_parameters(av_output, NULL) < 0) {
- (*out) << "AVHandler: Error setting output format parameters" << std::endl;
- return -1;
- }
-
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(), AVIO_FLAG_WRITE) < 0) {
(*out) << "AVHandler: Could not open \"" << filename << "\" for output" << std::endl;
return -1;
}
@@ -141,8 +135,8 @@
frame = create_frame(vstream->codec->pix_fmt);
rgbframe = create_frame(PIX_FMT_RGB24);
if (!frame || !rgbframe) return -1;
-
- av_write_header(av_output);
+
+ avformat_write_header(av_output, NULL);
return 0;
}
@@ -151,18 +145,18 @@
AVHandler::setup_read() {
av_register_all();
- if (av_open_input_file(&av_input, filename.c_str(), NULL, 0, NULL) != 0) {
+ if (avformat_open_input(&av_input, filename.c_str(), NULL, NULL) != 0) {
(*out) << "AVHandler: Could not open \"" << filename << "\" for reading" << std::endl;
return -1;
}
- if (av_find_stream_info(av_input) < 0) {
+ if (avformat_find_stream_info(av_input, NULL) < 0) {
(*out) << "AVHandler: No stream information available" << std::endl;
return -1;
}
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 +167,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;
}
@@ -192,7 +186,7 @@
if (codec->capabilities & CODEC_CAP_TRUNCATED)
vstream->codec->flags |= CODEC_FLAG_TRUNCATED;
- if (avcodec_open(vstream->codec, codec) < 0) {
+ if (avcodec_open2(vstream->codec, codec, NULL) < 0) {
(*out) << "AVHandler: Cannot open codec " << codec_name << std::endl;
vstream->codec->codec = NULL;
return -1;
@@ -204,9 +198,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 +252,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 +290,7 @@
(*out) << "AVHandler: Error seeking to " << target_timestamp << std::endl;
return -1;
}
- cc->hurry_up = 1;
+ cc->skip_frame;
// Flush stream buffers after seek
avcodec_flush_buffers(cc);
@@ -324,14 +318,18 @@
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) {
+
+ // HACK for CorePNG to decode as normal PNG by default
+ packet.flags = AV_PKT_FLAG_KEY;
+
+ 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,7 +340,9 @@
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 maybe use: cc->skip_frame;
+// cc->hurry_up = 0;
SwsContext *sc = sws_getContext(cc->width, cc->height, cc->pix_fmt,
cc->width, cc->height, PIX_FMT_BGR24,
@@ -361,9 +361,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,8 +375,8 @@
AVCodec *codec;
for (codec = av_codec_next(0); codec != NULL; codec = av_codec_next(codec)) {
- if ((codec->type == CODEC_TYPE_VIDEO) &&
- (codec->encode)) {
+ if ((codec->type == AVMEDIA_TYPE_VIDEO) &&
+ (codec->encode2)) {
(*out) << codec->name << " ";
}
}
@@ -386,8 +386,9 @@
int
AVHandler::add_video_stream() {
AVCodecContext *cc;
-
- vstream = av_new_stream(av_output, 0);
+
+ // FIXME: vstream = avformat_new_stream(av_output, av_find_default_stream_index(av_output));
+ vstream = avformat_new_stream(av_output, NULL);
if (!vstream) {
(*out) << "AVHandler: error opening video output stream" << std::endl;
return -1;
@@ -395,8 +396,8 @@
cc = vstream->codec;
- cc->codec_type = CODEC_TYPE_VIDEO;
-
+ cc->codec_type = AVMEDIA_TYPE_VIDEO;
+
cc->bit_rate = bitrate;
cc->width = width;
cc->height = height;
@@ -426,7 +427,7 @@
return -1;
}
- if (avcodec_open(cc, codec) < 0) {
+ if (avcodec_open2(cc, codec, NULL) < 0) {
(*out) << "AVHandler: cannot open codec" << std::endl;
cc->codec = NULL;
return -1;
diff -Nurd video-1.0.2/src/AVHandler.h video-1.0.2.patched/src/AVHandler.h
--- video-1.0.2/src/AVHandler.h 2009-05-08 08:17:36.000000000 -0500
+++ video-1.0.2.patched/src/AVHandler.h 2015-02-14 05:34:02.000000000 -0600
@@ -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)
@@ -165,7 +168,7 @@
unsigned int get_total_frames() const {
if (vstream) {
- return (unsigned int)((double)framerate * vstream->duration / AV_TIME_BASE);
+ return (unsigned int) vstream->nb_frames;
} else {
return 0;
}
@@ -173,7 +176,7 @@
unsigned int get_filesize() const {
if (av_input) {
- return av_input->file_size;
+ return avio_size(av_input->pb);
} else {
return 0;
}