Bug 214896 - multimedia/mplayer2: fails to build with ffmpeg 3.x
Summary: multimedia/mplayer2: fails to build with ffmpeg 3.x
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Carlos J. Puga Medina
URL:
Keywords: patch, patch-ready
Depends on:
Blocks: 207547
  Show dependency treegraph
 
Reported: 2016-11-28 06:54 UTC by Jan Beich
Modified: 2016-12-09 15:12 UTC (History)
5 users (show)

See Also:
cpm: maintainer-feedback+
cpm: merge-quarterly?


Attachments
patch-mplayer2_screenshot.c (1.40 KB, patch)
2016-11-29 12:42 UTC, Carlos J. Puga Medina
no flags Details | Diff
patch-first-attempt (40.71 KB, patch)
2016-11-30 02:59 UTC, Carlos J. Puga Medina
no flags Details | Diff
patch-mplayer2-ffmpeg3 (43.99 KB, patch)
2016-11-30 13:29 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
patch-mplayer2-ffmpeg3 (49.43 KB, patch)
2016-12-01 00:51 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
patch-mplayer2-ffmpeg3 (48.12 KB, patch)
2016-12-04 03:53 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
patch-mplayer2-ffmpeg3 (47.73 KB, patch)
2016-12-04 04:28 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
patch-mplayer2-ffmpeg3 (48.17 KB, patch)
2016-12-04 05:30 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
patch-mplayer2-ffmpeg3 (48.08 KB, patch)
2016-12-04 06:17 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff
svn-patch-mplayer2-ffmpeg3 (55.58 KB, patch)
2016-12-08 16:09 UTC, Carlos J. Puga Medina
cpm: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2016-11-28 06:54:10 UTC
screenshot.c:60:5: error: implicit declaration of function 'avcodec_free_frame' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    avcodec_free_frame(&ctx->pic);
    ^
screenshot.c:72:20: error: implicit declaration of function 'avcodec_alloc_frame' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        ctx->pic = avcodec_alloc_frame();
                   ^
screenshot.c:97:22: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean
      'AV_PIX_FMT_RGB24'?
    avctx->pix_fmt = PIX_FMT_RGB24;
                     ^~~~~~~~~~~~~
                     AV_PIX_FMT_RGB24
/usr/local/include/libavutil/pixfmt.h:64:5: note: 'AV_PIX_FMT_RGB24' declared here
    AV_PIX_FMT_RGB24,     ///< packed RGB 8:8:8, 24bpp, RGBRGB...
    ^
screenshot.c:113:5: error: implicit declaration of function 'avcodec_get_frame_defaults' is invalid
      in C99 [-Werror,-Wimplicit-function-declaration]
    avcodec_get_frame_defaults(pic);
    ^
screenshot.c:118:16: error: implicit declaration of function 'avcodec_encode_video' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
               ^

http://package23.nyi.freebsd.org/data/93amd64-default-PR207547/2016-11-27_17h03m14s/logs/errors/mplayer2-2.0.20130428_23.log
Comment 1 Jan Beich freebsd_committer freebsd_triage 2016-11-28 06:57:16 UTC
Grep ports/ tree for example fixes see doc/APIchanges in FFmpeg source.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2016-11-28 07:02:04 UTC
Alternatively, expire the port if you no longer use it.
Comment 3 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-29 12:42:17 UTC
Created attachment 177510 [details]
patch-mplayer2_screenshot.c

Jan,

Attempt to fix mplayer2 build with ffmpeg 3.0.x

Thanks for reporting.
Comment 4 Jan Beich freebsd_committer freebsd_triage 2016-11-29 13:08:48 UTC
Comment on attachment 177510 [details]
patch-mplayer2_screenshot.c

More errors:

  libvo/vo_png.c:77:22: error: calling 'imgfmt2pixfmt' with incomplete return type 'enum PixelFormat'
      avctx->pix_fmt = imgfmt2pixfmt(format);
		       ^~~~~~~~~~~~~~~~~~~~~
  ./fmt-conversion.h:24:18: note: 'imgfmt2pixfmt' declared here
  enum PixelFormat imgfmt2pixfmt(int fmt);
		   ^
  ./fmt-conversion.h:24:6: note: forward declaration of 'enum PixelFormat'
  enum PixelFormat imgfmt2pixfmt(int fmt);
       ^
  libvo/vo_png.c:114:11: error: implicit declaration of function 'avcodec_encode_video' is invalid in
	C99 [-Werror,-Wimplicit-function-declaration]
      res = avcodec_encode_video(avctx, outbuffer, outbuffer_size, &pic);
	    ^
  libvo/vo_png.c:114:11: note: did you mean 'avcodec_encode_video2'?
  /usr/local/include/libavcodec/avcodec.h:5323:5: note: 'avcodec_encode_video2' declared here
  int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
      ^

>-    int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
>+    int size = avcodec_encode_video2(avctx, outbuffer, outbuffer_size, pic);

The API isn't same, see multimedia/transcode/files/patch-ffmpeg29 or
https://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/utils.c;h=cc28732c01fb;hb=refs/heads/release/2.8#l2120
Comment 5 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-30 02:59:53 UTC
Created attachment 177530 [details]
patch-first-attempt

cc -o mplayer command.o m_property.o mixer.o mp_fifo.o mplayer.o parser-mpcmd.o screenshot.o input/input.o libao2/ao_null.o libao2/ao_pcm.o libao2/audio_out.o libvo/aspect.o libvo/csputils.o libvo/filter_kernels.o libvo/geometry.o libvo/old_vo_wrapper.o libvo/video_out.o libvo/vo_null.o libvo/vo_png.o libvo/vo_jpeg.o libvo/vo_md5sum.o libao2/ao_oss.o libvo/vo_pnm.o libvo/vo_tga.o libvo/vo_vdpau.o libvo/vo_x11.o libvo/x11_common.o libvo/vo_xv.o libvo/vo_yuv4mpeg.o asxparser.o av_log.o av_opts.o bstr.o codec-cfg.o cpudetect.o defaultopts.o fmt-conversion.o m_config.o m_option.o m_struct.o mp_msg.o mpcommon.o parser-cfg.o path.o playtree.o playtreeparser.o subopt-helper.o talloc.o libaf/af.o libaf/af_center.o libaf/af_channels.o libaf/af_comp.o libaf/af_delay.o libaf/af_dummy.o libaf/af_equalizer.o libaf/af_extrastereo.o libaf/af_format.o libaf/af_gate.o libaf/af_hrtf.o libaf/af_karaoke.o libaf/af_lavcac3enc.o libaf/af_lavcresample.o libaf/af_pan.o libaf/af_resample.o libaf/af_scaletempo.o libaf/af_sinesuppress.o libaf/af_stats.o libaf/af_sub.o libaf/af_surround.o libaf/af_sweep.o libaf/af_tools.o libaf/af_volnorm.o libaf/af_volume.o libaf/filter.o libaf/format.o libaf/reorder_ch.o libaf/window.o libmpcodecs/ad.o libmpcodecs/ad_alaw.o libmpcodecs/ad_dk3adpcm.o libmpcodecs/ad_dvdpcm.o libmpcodecs/ad_ffmpeg.o libmpcodecs/ad_hwac3.o libmpcodecs/ad_hwmpa.o libmpcodecs/ad_imaadpcm.o libmpcodecs/ad_msadpcm.o libmpcodecs/ad_pcm.o libmpcodecs/dec_audio.o libmpcodecs/dec_teletext.o libmpcodecs/dec_video.o libmpcodecs/img_format.o libmpcodecs/mp_image.o libmpcodecs/pullup.o libmpcodecs/vd.o libmpcodecs/vd_ffmpeg.o libmpcodecs/vd_hmblck.o libmpcodecs/vd_lzo.o libmpcodecs/vd_mpegpes.o libmpcodecs/vd_mtga.o libmpcodecs/vd_null.o libmpcodecs/vd_raw.o libmpcodecs/vd_sgi.o libmpcodecs/vf.o libmpcodecs/vf_1bpp.o libmpcodecs/vf_2xsai.o libmpcodecs/vf_blackframe.o libmpcodecs/vf_boxblur.o libmpcodecs/vf_crop.o libmpcodecs/vf_cropdetect.o libmpcodecs/vf_decimate.o libmpcodecs/vf_delogo.o libmpcodecs/vf_denoise3d.o libmpcodecs/vf_detc.o libmpcodecs/vf_dint.o libmpcodecs/vf_divtc.o libmpcodecs/vf_down3dright.o libmpcodecs/vf_dsize.o libmpcodecs/vf_dvbscale.o libmpcodecs/vf_eq.o libmpcodecs/vf_eq2.o libmpcodecs/vf_expand.o libmpcodecs/vf_field.o libmpcodecs/vf_fil.o libmpcodecs/vf_filmdint.o libmpcodecs/vf_fixpts.o libmpcodecs/vf_flip.o libmpcodecs/vf_format.o libmpcodecs/vf_framestep.o libmpcodecs/vf_fspp.o libmpcodecs/vf_geq.o libmpcodecs/vf_gradfun.o libmpcodecs/vf_halfpack.o libmpcodecs/vf_harddup.o libmpcodecs/vf_hqdn3d.o libmpcodecs/vf_hue.o libmpcodecs/vf_il.o libmpcodecs/vf_ilpack.o libmpcodecs/vf_ivtc.o libmpcodecs/vf_kerndeint.o libmpcodecs/vf_lavc.o libmpcodecs/vf_lavcdeint.o libmpcodecs/vf_mirror.o libmpcodecs/vf_noformat.o libmpcodecs/vf_noise.o libmpcodecs/vf_ow.o libmpcodecs/vf_palette.o libmpcodecs/vf_perspective.o libmpcodecs/vf_phase.o libmpcodecs/vf_pp7.o libmpcodecs/vf_pullup.o libmpcodecs/vf_qp.o libmpcodecs/vf_rectangle.o libmpcodecs/vf_remove_logo.o libmpcodecs/vf_rgbtest.o libmpcodecs/vf_rotate.o libmpcodecs/vf_sab.o libmpcodecs/vf_scale.o libmpcodecs/vf_screenshot.o libmpcodecs/vf_smartblur.o libmpcodecs/vf_softpulldown.o libmpcodecs/vf_stereo3d.o libmpcodecs/vf_softskip.o libmpcodecs/vf_swapuv.o libmpcodecs/vf_telecine.o libmpcodecs/vf_test.o libmpcodecs/vf_tfields.o libmpcodecs/vf_tile.o libmpcodecs/vf_tinterlace.o libmpcodecs/vf_unsharp.o libmpcodecs/vf_vo.o libmpcodecs/vf_yadif.o libmpcodecs/vf_yuvcsp.o libmpcodecs/vf_yvu9.o libmpdemux/aac_hdr.o libmpdemux/asfheader.o libmpdemux/aviheader.o libmpdemux/aviprint.o libmpdemux/demuxer.o libmpdemux/demux_aac.o libmpdemux/demux_asf.o libmpdemux/demux_audio.o libmpdemux/demux_avi.o libmpdemux/demux_demuxers.o libmpdemux/demux_edl.o libmpdemux/demux_film.o libmpdemux/demux_fli.o libmpdemux/demux_lavf.o libmpdemux/demux_lmlm4.o libmpdemux/demux_mf.o libmpdemux/demux_mkv.o libmpdemux/demux_mov.o libmpdemux/demux_mpg.o libmpdemux/demux_nsv.o libmpdemux/demux_pva.o libmpdemux/demux_rawaudio.o libmpdemux/demux_rawvideo.o libmpdemux/demux_realaud.o libmpdemux/demux_real.o libmpdemux/demux_roq.o libmpdemux/demux_smjpeg.o libmpdemux/demux_ts.o libmpdemux/demux_ty.o libmpdemux/demux_viv.o libmpdemux/demux_vqf.o libmpdemux/demux_y4m.o libmpdemux/ebml.o libmpdemux/extension.o libmpdemux/mf.o libmpdemux/mp3_hdr.o libmpdemux/mp_taglists.o libmpdemux/mpeg_hdr.o libmpdemux/mpeg_packetizer.o libmpdemux/parse_es.o libmpdemux/parse_mp4.o libmpdemux/video.o libmpdemux/yuv4mpeg.o libmpdemux/yuv4mpeg_ratio.o libvo/osd.o libvo/bitmap_packer.o osdep/numcores.o osdep/io.o osdep/getch2.o osdep/timer-linux.o stream/stream.o stream/stream_cue.o stream/stream_ffmpeg.o stream/stream_file.o stream/stream_mf.o stream/stream_null.o stream/url.o sub/dec_sub.o sub/find_sub.o sub/find_subfiles.o sub/sd_lavc.o sub/spudec.o sub/sub.o sub/sub_cc.o sub/subassconvert.o sub/subreader.o sub/vobsub.o timeline/tl_edl.o timeline/tl_matroska.o stream/stream_dvd.o stream/stream_dvd_common.o libvo/aclib.o stream/stream_ftp.o libmpcodecs/vf_bmovl.o libaf/af_export.o osdep/mmap_anon.o libmpcodecs/vd_ijpg.o libmpcodecs/ad_liba52.o libmpcodecs/vf_ass.o sub/ass_mp.o sub/osd_libass.o sub/sd_ass.o libmpcodecs/vf_pp.o osdep/shmem.o stream/asf_mmst_streaming.o stream/asf_streaming.o stream/cookies.o stream/http.o stream/network.o stream/pnm.o stream/rtp.o stream/udp.o stream/tcp.o stream/stream_rtp.o stream/stream_udp.o libmpcodecs/vd_mpng.o libmpcodecs/ad_realaud.o libmpcodecs/vd_realvid.o stream/cache2.o stream/stream_tv.o stream/tv.o stream/frequencies.o stream/tvi_dummy.o stream/tvi_bsdbt848.o sub/unrar_exec.o stream/stream_vcd.o libmpcodecs/ad_libvorbis.o libmpdemux/demux_ogg.o libmpcodecs/vd_xanim.o -Wl,-z,noexecstack  -L/usr/local/lib  -fstack-protector   /usr/lib/libncurses.so -L/usr/local/lib -lvdpau   -lpng -lz -ljpeg  -ldvdread -L/usr/local/lib -lass   -lz -lvorbis -logg -la52 -L/usr/local/lib -lavutil -lavcodec -lavformat -lswscale   -L/usr/local/lib -lpostproc   -L/usr/local/lib -lavresample   -lpthread  -rdynamic  -lm  -lXext -lX11 -lpthread -lXv -lXxf86vm
screenshot.o: In function `screenshot_save':
screenshot.c:(.text+0x2aa): undefined reference to `avcodec_encode_video'
libvo/vo_png.o: In function `control':
libvo/vo_png.c:(.text+0x334): undefined reference to `avcodec_encode_video'
libmpcodecs/vf_lavc.o: In function `put_image':
libmpcodecs/vf_lavc.c:(.text+0x3c9): undefined reference to `avcodec_encode_video'
libmpcodecs/vf_lavcdeint.o: In function `put_image':
libmpcodecs/vf_lavcdeint.c:(.text+0x17d): undefined reference to `avpicture_deinterlace'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [Makefile:549: mplayer] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/multimedia/mplayer2/work/mplayer2-2.0.20130428'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
Comment 6 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-30 03:13:57 UTC
Some progress has been made in order to correct mplayer2 build with ffmpeg 3.2.1.

So I hope I can fix it properly during the week.

Thanks Jan.
Comment 7 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-30 13:29:55 UTC
Created attachment 177536 [details]
patch-mplayer2-ffmpeg3
Comment 8 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-30 13:31:05 UTC
poudriere testport -j 103x32 -o multimedia/mplayer2 [OK]
Comment 9 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-11-30 16:56:05 UTC
(In reply to Carlos J. Puga Medina from comment #8)

More tests:

poudriere testport -j 101x32 -o multimedia/mplayer2 [OK]
poudriere testport -j 101x64 -o multimedia/mplayer2 [OK]
poudriere testport -j 103x64 -o multimedia/mplayer2 [OK]
poudriere testport -j 110x32 -o multimedia/mplayer2 [OK]
poudriere testport -j 110x64 -o multimedia/mplayer2 [OK]
Comment 10 Jan Beich freebsd_committer freebsd_triage 2016-11-30 21:25:17 UTC
Comment on attachment 177536 [details]
patch-mplayer2-ffmpeg3

> +++ libmpcodecs/ad_ffmpeg.c
[...]
> -    lavc_context->request_channels = opts->audio_output_channels;

Why remove and not replace? Maybe use mplayer fix

  $ svn di -c37447 svn://svn.mplayerhq.hu/mplayer/trunk

> +++ libmpdemux/demux_lavf.c
[...]
> +    char mime[] = "";
[...]
> +        avpd.mime_type = mime;

Hmm, mplayer fixed in a different way.

  $ svn di -c37251 svn://svn.mplayerhq.hu/mplayer/trunk

> +++ libmpcodecs/vf_lavcdeint.c
[...]
> -  if (avpicture_deinterlace(&pic, &lavc_picture,
> -			    priv->pix_fmt, priv->width, priv->height) < 0)
>     {

mplayer turned vf_lavcdeint into nop as fixing requires converting to libavfilter (incompatible). Maybe do the same instead of silently breaking put_image.

  $ svn di -c37388 svn://svn.mplayerhq.hu/mplayer/trunk

> +++ screenshot.c
[...]
> -    int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
> +    av_init_packet(&pkt);
> +    pkt.data = outbuffer;
> +    pkt.size = outbuffer_size;
> +    int size = avcodec_encode_video2(avctx, &pkt, pic, &got_pkt);

Looks wrong given "size" is later used as an argument for fwrite(). See libvo/vo_png.c for an example.
Comment 11 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-01 00:51:38 UTC
Created attachment 177564 [details]
patch-mplayer2-ffmpeg3

Jan, 

I think I have not forgotten any details. Please, check it out :)
Comment 12 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-03 19:10:43 UTC
Hi Thomas,

Does the patch looks good to you? Do you think it's okay?

Thanks
Comment 13 Jan Beich freebsd_committer freebsd_triage 2016-12-04 00:34:36 UTC
Comment on attachment 177564 [details]
patch-mplayer2-ffmpeg3

> +++ libmpcodecs/dec_audio.h
[...]
> -int decode_audio(sh_audio_t *sh_audio, struct bstr *outbuf, int minlen);
> +int mp_decode_audio(sh_audio_t *sh_audio, struct bstr *outbuf, int minlen);

Why? It causes the following dangerous behavior

  mplayer.c:2407:11: warning: implicit declaration of function 'decode_audio'
  		     is invalid in C99 [-Wimplicit-function-declaration]
      res = decode_audio(sh_audio, &ao->buffer, 1);
	    ^

> +++ libmpcodecs/ad_ffmpeg.c
[...]
> -    lavc_context->request_channels = opts->audio_output_channels;
> +    lavc_context->request_channel_layout = av_get_default_channel_layout(audio_output_channels);

Notice mplayer2 keeps audio_output_channels as part of options struct MPOpts. No need to hardcode the value in libmpcodecs/dec_audio.c.

> +++ libmpdemux/demux_lavf.c
> +    AVProbeData avpd = { 0 };
[...]
> +    char mime[] = "";
> +        avpd.mime_type = mime;

Why do you need both variants of the same fix?

> +++ screenshot.c
[...]
> -    int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
> +    int size = avcodec_encode_video2(avctx, &pkt, pic, &got_pkt);
>      if (size < 1)
>          goto error_exit;
[...]
> -    fwrite(outbuffer, size, 1, fp);
> +    fwrite(outbuffer, pkt.size, 1, fp);

The new function doesn't return size and you may want to check got_pkt before doing fwrite().

  int avcodec_encode_video(AVCodecContext *, uint8_t *, int, const AVFrame *):

    * @return On error a negative value is returned, on success zero or the number
    * of bytes used from the output buffer.

vs.

  int avcodec_encode_video2(AVCodecContext *, AVPacket *, const AVFrame *, int *):

    * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
    *                            output packet is non-empty, and to 0 if it is
    *                            empty. If the function returns an error, the
    *                            packet can be assumed to be invalid, and the
    *                            value of got_packet_ptr is undefined and should
    *                            not be used.
    * @return          0 on success, negative error code on failure


mpv has a fix after moving screenshot.c code into another file.

  https://github.com/mpv-player/mpv/commit/ba5fc1d5e6c7
Comment 14 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 03:53:25 UTC
Created attachment 177645 [details]
patch-mplayer2-ffmpeg3

Done!
Comment 15 Jan Beich freebsd_committer freebsd_triage 2016-12-04 04:11:48 UTC
Comment on attachment 177645 [details]
patch-mplayer2-ffmpeg3

> +++ libmpcodecs/ad_ffmpeg.c
[...]
> +    int audio_output_channels;
[...]
> -    lavc_context->request_channels = opts->audio_output_channels;
> +    lavc_context->request_channel_layout = av_get_default_channel_layout(audio_output_channels);

Using uninitialized variable is even worse. Why do you insist on removing "opts->" ?
Comment 16 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 04:28:38 UTC
Created attachment 177646 [details]
patch-mplayer2-ffmpeg3

Oops! Here I mixed it with the previous patch.
Comment 17 Jan Beich freebsd_committer freebsd_triage 2016-12-04 04:45:35 UTC
Comment on attachment 177646 [details]
patch-mplayer2-ffmpeg3

> +++ libmpcodecs/ad_ffmpeg.c
[...]
> -    lavc_context->request_channels = opts->audio_output_channels;
> +    lavc_context->request_channel_layout = opts->audio_output_channels;

Not the same thing. Rebase mplayer fix like before but don't lose "opts->".

  // from ffmpeg-2.8.8/libavcodec/avcodec.h
  typedef struct AVCodecContext {
  [...]
      /**
       * Decoder should decode to this many channels if it can (0 for default)
       * - encoding: unused
       * - decoding: Set by user.
       * @deprecated Deprecated in favor of request_channel_layout.
       */
      attribute_deprecated int request_channels;

      /**
       * Request decoder to use this channel layout if it can (0 for default)
       * - encoding: unused
       * - decoding: Set by user.
       */
      uint64_t request_channel_layout;
  [...]

> +++ libvo/vo_png.c
[...]
>      AVFrame pic;

According to libavutil/frame.h

    * AVFrame must be allocated using av_frame_alloc(). Note that this only
    * allocates the AVFrame itself, the buffers for the data must be managed

and av_frame_free() later relies on

  $ svn di -c37427 svn://svn.mplayerhq.hu/mplayer/trunk

> +    res = avcodec_encode_video2(avctx, &pkt, &got_pkt, &pic);
> +    av_frame_free(&pic);

libvo/vo_png.c:118:46: warning: incompatible pointer types passing 'int *' to parameter of type 'const AVFrame *' (aka 'const struct AVFrame *') [-Wincompatible-pointer-types]
    res = avcodec_encode_video2(avctx, &pkt, &got_pkt, &pic);
                                             ^~~~~~~~
/usr/local/include/libavcodec/avcodec.h:5324:42: note: passing argument to parameter 'frame' here
                          const AVFrame *frame, int *got_packet_ptr);
                                         ^
libvo/vo_png.c:118:56: warning: incompatible pointer types passing 'AVFrame *' (aka 'struct AVFrame *') to parameter of type 'int *' [-Wincompatible-pointer-types]
    res = avcodec_encode_video2(avctx, &pkt, &got_pkt, &pic);
                                                       ^~~~
/usr/local/include/libavcodec/avcodec.h:5324:54: note: passing argument to parameter 'got_packet_ptr' here
                          const AVFrame *frame, int *got_packet_ptr);
                                                     ^
libvo/vo_png.c:119:19: warning: incompatible pointer types passing 'AVFrame *' (aka 'struct AVFrame *') to parameter of type 'AVFrame **' (aka 'struct AVFrame **') [-Wincompatible-pointer-types]
    av_frame_free(&pic);
                  ^~~~
/usr/local/include/libavutil/frame.h:595:30: note: passing argument to parameter 'frame' here
void av_frame_free(AVFrame **frame);
                             ^
Comment 18 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 05:30:31 UTC
Created attachment 177647 [details]
patch-mplayer2-ffmpeg3

Let me know if you need anything else.

Thanks for you kind help, Jan :)
Comment 19 Jan Beich freebsd_committer freebsd_triage 2016-12-04 06:02:48 UTC
Comment on attachment 177647 [details]
patch-mplayer2-ffmpeg3

Looks OK now.

> +++ libvo/vo_png.c
[...]
> - 	    mp_msg(MSGT_VO,MSGL_WARN, "[VO_PNG] Error in create_png.\n");
> +         mp_msg(MSGT_VO,MSGL_WARN, "[V0_PNG] Error in create_png.\n");

Nop change unless the typo is intentional.
Comment 20 Jan Beich freebsd_committer freebsd_triage 2016-12-04 06:10:52 UTC
Don't forget to check runtime with ffmpeg 3.x as some workaround may have been removed.
Comment 21 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 06:12:42 UTC
(In reply to Jan Beich (mail not working) from comment #19)

Yes, it is a typo. I must have lost the tip of my finger :)
Comment 22 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 06:13:59 UTC
(In reply to Jan Beich (mail not working) from comment #20)

Okay, I'll keep it in mind :)

Thanks again, Jan.
Comment 23 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-04 06:17:59 UTC
Created attachment 177649 [details]
patch-mplayer2-ffmpeg3

Fix typo in patch-libvo_vo__png.c
Comment 24 Thomas Zander freebsd_committer freebsd_triage 2016-12-04 09:41:18 UTC
Frankly, is there any reason to keep mplayer2? There is mplayer (which is being actively developed), there is mpv (which is being actively developed), there is vlc (which is .... you get my point :-)

In mplayer2, we have this:
MASTER_SITES=   LOCAL/gblach/
MPLAYER2_SNAPSHOT_DATE= 2013-04-28

Since there is no upstream development, you will face the same nightmare with every major ffmpeg update in the foreseeable future. Personally, I think it's not worth it.
Comment 25 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-06 11:24:20 UTC
(In reply to Thomas Zander from comment #24)

I agree. If no one uses the port or is not interested after run the ffmpeg update, mplayer2 can be marked to expire.

However I remember someone telling me via mail that he was still using mplayer2.
Comment 26 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-08 16:09:46 UTC
Created attachment 177806 [details]
svn-patch-mplayer2-ffmpeg3
Comment 27 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-08 16:12:40 UTC
Waiting for mentor approval to commit it.

@Jan

If you are in a hurry, please, go ahead to commit the patch!
Comment 28 Jason Unovitch freebsd_committer freebsd_triage 2016-12-09 01:53:16 UTC
(In reply to Carlos J. Puga Medina from comment #27)
LGTM Carlos.
Comment 29 commit-hook freebsd_committer freebsd_triage 2016-12-09 15:10:48 UTC
A commit references this bug:

Author: cpm
Date: Fri Dec  9 15:10:38 UTC 2016
New revision: 428215
URL: https://svnweb.freebsd.org/changeset/ports/428215

Log:
  multimedia/mplayer2: Fix build with ffmpeg 3.x

  screenshot.c:60:5: error: implicit declaration of function 'avcodec_free_frame' is invalid in C99
        [-Werror,-Wimplicit-function-declaration]
      avcodec_free_frame(&ctx->pic);
      ^
  screenshot.c:72:20: error: implicit declaration of function 'avcodec_alloc_frame' is invalid in C99
        [-Werror,-Wimplicit-function-declaration]
          ctx->pic = avcodec_alloc_frame();
                     ^
  screenshot.c:97:22: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean
        'AV_PIX_FMT_RGB24'?
      avctx->pix_fmt = PIX_FMT_RGB24;
                       ^~~~~~~~~~~~~
                       AV_PIX_FMT_RGB24
  /usr/local/include/libavutil/pixfmt.h:64:5: note: 'AV_PIX_FMT_RGB24' declared here
      AV_PIX_FMT_RGB24,     ///< packed RGB 8:8:8, 24bpp, RGBRGB...
      ^
  screenshot.c:113:5: error: implicit declaration of function 'avcodec_get_frame_defaults' is invalid
        in C99 [-Werror,-Wimplicit-function-declaration]
      avcodec_get_frame_defaults(pic);
      ^
  screenshot.c:118:16: error: implicit declaration of function 'avcodec_encode_video' is invalid in C99
        [-Werror,-Wimplicit-function-declaration]
      int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
                 ^

  PR:		214896
  Reported by:	jbeich
  Reviewed by:	jbeich, junovitch (mentor)
  Approved by:	jbeich, junovitch (mentor)

Changes:
  head/multimedia/mplayer2/Makefile
  head/multimedia/mplayer2/files/patch-fmt-conversion.c
  head/multimedia/mplayer2/files/patch-fmt-conversion.h
  head/multimedia/mplayer2/files/patch-libaf_af__lavcac3enc.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_ad__ffmpeg.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_dec__teletext.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vd__ffmpeg.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__halfpack.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__lavc.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__lavcdeint.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__sab.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__scale.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__scale.h
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__screenshot.c
  head/multimedia/mplayer2/files/patch-libmpcodecs_vf__smartblur.c
  head/multimedia/mplayer2/files/patch-libmpdemux_demux__lavf.c
  head/multimedia/mplayer2/files/patch-libvo_vo__png.c
  head/multimedia/mplayer2/files/patch-screenshot.c
  head/multimedia/mplayer2/files/patch-sub_spudec.c
Comment 30 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-09 15:12:46 UTC
Committed, thanks!