You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

  1. --- a/src/ffmpeg.c
  2. +++ b/src/ffmpeg.c
  3. @@ -50,6 +50,10 @@
  4. #include <ctype.h>
  5. #include "ffmpeg.h"
  6. +#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
  7. +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
  8. +#endif
  9. +
  10. #ifndef CODEC_TYPE_AUDIO
  11. #define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
  12. #endif
  13. @@ -96,7 +100,7 @@ static int stream_component_open(priv_t
  14. enc->err_recognition = 1;
  15. #endif
  16. - if (!codec || avcodec_open(enc, codec) < 0)
  17. + if (!codec || avcodec_open2(enc, codec, NULL) < 0)
  18. return -1;
  19. if (enc->codec_type != AVMEDIA_TYPE_AUDIO) {
  20. lsx_fail("ffmpeg CODEC %x is not an audio CODEC", enc->codec_type);
  21. @@ -178,7 +182,7 @@ static int startread(sox_format_t * ft)
  22. }
  23. /* Get CODEC parameters */
  24. - if ((ret = av_find_stream_info(ffmpeg->ctxt)) < 0) {
  25. + if ((ret = avformat_find_stream_info(ffmpeg->ctxt, NULL)) < 0) {
  26. lsx_fail("ffmpeg could not find CODEC parameters for %s", ft->filename);
  27. return SOX_EOF;
  28. }
  29. @@ -256,7 +260,7 @@ static int stopread(sox_format_t * ft)
  30. if (ffmpeg->audio_stream >= 0)
  31. stream_component_close(ffmpeg, ffmpeg->audio_stream);
  32. if (ffmpeg->ctxt) {
  33. - av_close_input_file(ffmpeg->ctxt);
  34. + avformat_close_input(&ffmpeg->ctxt);
  35. ffmpeg->ctxt = NULL; /* safety */
  36. }
  37. @@ -267,16 +271,21 @@ static int stopread(sox_format_t * ft)
  38. /*
  39. * add an audio output stream
  40. */
  41. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
  42. +static AVStream *add_audio_stream(sox_format_t * ft, AVFormatContext *oc, enum AVCodecID codec_id)
  43. +#else
  44. static AVStream *add_audio_stream(sox_format_t * ft, AVFormatContext *oc, enum CodecID codec_id)
  45. +#endif
  46. {
  47. AVCodecContext *c;
  48. AVStream *st;
  49. - st = av_new_stream(oc, 1);
  50. + st = avformat_new_stream(oc, NULL);
  51. if (!st) {
  52. lsx_fail("ffmpeg could not alloc stream");
  53. return NULL;
  54. }
  55. + st->id = 1;
  56. c = st->codec;
  57. c->codec_id = codec_id;
  58. @@ -306,7 +315,7 @@ static int open_audio(priv_t * ffmpeg, A
  59. }
  60. /* open it */
  61. - if (avcodec_open(c, codec) < 0) {
  62. + if (avcodec_open2(c, codec, NULL) < 0) {
  63. lsx_fail("ffmpeg could not open CODEC");
  64. return SOX_EOF;
  65. }