Package: motion Version: 3.2.12-3.4 Followup-For: Bug #720814 Hi, I have made a couple patches that fix this problem. Please apply both of them, in any order.
I've done a non-thorough test (motion -n -d3) that it works as expected, but with ffmpeg from d-m.o. The current (unpatched) motion fails silently (unless you use -d) at runtime with the existing libraries, again from d-m.o. X -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.10-3-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages motion depends on: ii adduser 3.113+nmu3 ii debconf [debconf-2.0] 1.5.52 ii libavcodec55 10:2.1.4-dmo1 ii libavformat55 10:2.1.4-dmo1 ii libavutil52 10:2.1.4-dmo1 ii libc6 2.18-4 ii libjpeg8 8d-2 ii libmysqlclient18 5.5.35+dfsg-2 ii libpq5 9.3.3-1 Versions of packages motion recommends: ii ffmpeg 10:2.1.4-dmo1 Versions of packages motion suggests: pn mysql-client <none> pn postgresql-client <none> -- Configuration Files: /etc/default/motion changed [not included] /etc/motion/motion.conf changed [not included] -- debconf information excluded
Description: Fix build for newer ffmpeg/libav API Upgrade to the newer ffmpeg/libav API in current unstable Debian/DMO. This is a cut-down version of https://github.com/sackmotion/motion/commit/0fb31d#diff-3 which is a more proper fix (it detects versions correctly) but it does not apply to the orig tarball in Debian. Author: Ximin Luo <infini...@pwned.gg> Forwarded: not-needed --- a/ffmpeg.c +++ b/ffmpeg.c @@ -89,9 +89,9 @@ filename = colon + 1; - if (flags & URL_RDWR) { + if (flags & AVIO_FLAG_READ_WRITE) { access_flags = O_CREAT | O_APPEND | O_RDWR; - } else if (flags & URL_WRONLY) { + } else if (flags & AVIO_FLAG_WRITE) { access_flags = O_CREAT | O_APPEND | O_WRONLY; } else { access_flags = O_RDONLY; @@ -106,10 +106,10 @@ } /* URLProtocol entry for the append file protocol, which we use for mpeg1 videos - * in order to get append behavior with url_fopen. + * in order to get append behavior with avio_open. * * Libavformat uses protocols for achieving flexibility when handling files - * and other resources. A call to url_fopen will eventually be redirected to + * and other resources. A call to avio_open will eventually be redirected to * a protocol-specific open function. * * The remaining functions (for writing, seeking etc.) are set in ffmpeg_init. @@ -139,9 +139,9 @@ av_strstart(filename, "file:", &filename); - if (flags & URL_RDWR) { + if (flags & AVIO_FLAG_READ_WRITE) { access_flags = O_CREAT | O_TRUNC | O_RDWR; - } else if (flags & URL_WRONLY) { + } else if (flags & AVIO_FLAG_WRITE) { access_flags = O_CREAT | O_TRUNC | O_WRONLY; } else { access_flags = O_RDONLY; @@ -204,11 +204,11 @@ static int mpeg1_write_trailer(AVFormatContext *s) { #if LIBAVFORMAT_BUILD >= (52<<16) - put_buffer(s->pb, mpeg1_trailer, 4); - put_flush_packet(s->pb); + avio_write(s->pb, mpeg1_trailer, 4); + avio_flush(s->pb); #else - put_buffer(&s->pb, mpeg1_trailer, 4); - put_flush_packet(&s->pb); + avio_write(&s->pb, mpeg1_trailer, 4); + avio_flush(&s->pb); #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ return 0; /* success */ @@ -461,13 +461,6 @@ c->flags |= CODEC_FLAG_GLOBAL_HEADER; } - /* set the output parameters (must be done even if no parameters). */ - if (av_set_parameters(ffmpeg->oc, NULL) < 0) { - motion_log(LOG_ERR, 0, "ffmpeg av_set_parameters error: Invalid output format parameters"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - /* Dump the format settings. This shows how the various streams relate to each other */ //dump_format(ffmpeg->oc, 0, filename, 1); @@ -488,7 +481,7 @@ pthread_mutex_lock(&global_lock); /* open the codec */ - if (avcodec_open(c, codec) < 0) { + if (avcodec_open2(c, codec, NULL) < 0) { /* Release the lock. */ pthread_mutex_unlock(&global_lock); motion_log(LOG_ERR, 1, "avcodec_open - could not open codec"); @@ -535,7 +528,7 @@ char file_proto[256]; /* Use append file protocol for mpeg1, to get the append behavior from - * url_fopen, but no protocol (=> default) for other codecs. + * avio_open, but no protocol (=> default) for other codecs. */ if (is_mpeg1) snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); @@ -543,7 +536,7 @@ snprintf(file_proto, sizeof(file_proto), "%s", filename); - if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { + if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { /* path did not exist? */ if (errno == ENOENT) { /* create path for file (don't use file_proto)... */ @@ -553,15 +546,15 @@ } /* and retry opening the file (use file_proto) */ - if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { - motion_log(LOG_ERR, 1, "url_fopen - error opening file %s",filename); + if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { + motion_log(LOG_ERR, 1, "avio_open - error opening file %s",filename); ffmpeg_cleanups(ffmpeg); return NULL; } /* Permission denied */ } else if (errno == EACCES) { motion_log(LOG_ERR, 1, - "url_fopen - error opening file %s" + "avio_open - error opening file %s" " ... check access rights to target directory", filename); ffmpeg_cleanups(ffmpeg); return NULL; @@ -574,7 +567,7 @@ } /* write the stream header, if any */ - av_write_header(ffmpeg->oc); + avformat_write_header(ffmpeg->oc, NULL); return ffmpeg; } @@ -605,7 +598,7 @@ /* if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { // close the output file - if (ffmpeg->oc->pb) url_fclose(&ffmpeg->oc->pb); + if (ffmpeg->oc->pb) avio_close(&ffmpeg->oc->pb); } */ /* free the stream */ @@ -641,9 +634,9 @@ if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { /* close the output file */ #if LIBAVFORMAT_BUILD >= (52<<16) - url_fclose(ffmpeg->oc->pb); + avio_close(ffmpeg->oc->pb); #else - url_fclose(&ffmpeg->oc->pb); + avio_close(&ffmpeg->oc->pb); #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ }
Description: Copy old API items we still depend on As per doc/APIchanges in libav/ffmpeg, URLContext/URLProtocol were dropped from the public API of libavformat since 52.107.0. Pending a better solution from motion upstream, we copy the definitions here. Author: Ximin Luo <infini...@pwned.gg> Bug: https://github.com/sackmotion/motion/issues/15 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -15,6 +15,66 @@ #include "ffmpeg.h" #include "motion.h" +#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(52,107,0) +/* + * URLContext, URLProtocol have been removed from avio.h + * + */ + +typedef struct URLContext { + const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ + struct URLProtocol *prot; + void *priv_data; + char *filename; /**< specified URL */ + int flags; + int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ + int is_streamed; /**< true if streamed (no seek possible), default = false */ + int is_connected; + AVIOInterruptCB interrupt_callback; + int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ +} URLContext; + +typedef struct URLProtocol { + const char *name; + int (*url_open)( URLContext *h, const char *url, int flags); + /** + * This callback is to be used by protocols which open further nested + * protocols. options are then to be passed to ffurl_open()/ffurl_connect() + * for those nested protocols. + */ + int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); + + /** + * Read data from the protocol. + * If data is immediately available (even less than size), EOF is + * reached or an error occurs (including EINTR), return immediately. + * Otherwise: + * In non-blocking mode, return AVERROR(EAGAIN) immediately. + * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), + * and return AVERROR(EAGAIN) on timeout. + * Checking interrupt_callback, looping on EINTR and EAGAIN and until + * enough data has been read is left to the calling function; see + * retry_transfer_wrapper in avio.c. + */ + int (*url_read)( URLContext *h, unsigned char *buf, int size); + int (*url_write)(URLContext *h, const unsigned char *buf, int size); + int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); + int (*url_close)(URLContext *h); + struct URLProtocol *next; + int (*url_read_pause)(URLContext *h, int pause); + int64_t (*url_read_seek)(URLContext *h, int stream_index, + int64_t timestamp, int flags); + int (*url_get_file_handle)(URLContext *h); + int (*url_get_multi_file_handle)(URLContext *h, int **handles, + int *numhandles); + int (*url_shutdown)(URLContext *h, int flags); + int priv_data_size; + const AVClass *priv_data_class; + int flags; + int (*url_check)(URLContext *h, int mask); +} URLProtocol; +#endif + #if LIBAVCODEC_BUILD > 4680 /* FFmpeg after build 4680 doesn't have support for mpeg1 videos with * non-standard framerates. Previous builds contained a broken hack