anthwlock / untrunc

Restore a truncated mp4/mov. Improved version of ponchio/untrunc
GNU General Public License v2.0
1.87k stars 182 forks source link

'make' goes with failure on Arch Linux #121

Closed abdulbadii closed 1 month ago

abdulbadii commented 1 year ago

How is the solution of this failure on Arch Linux


src/codec.cpp: In function ‘int untr_decode_audio4(AVCodecContext*, AVFrame*, int*, AVPacket*, uint)’:
src/codec.cpp:341:24: error: ‘avcodec_decode_audio4’ was not declared in this scope; did you mean ‘untr_decode_audio4’?
  341 |         int consumed = avcodec_decode_audio4(avctx, frame, got_frame, pkt);

and line 361, please help out guide to correct way

domino-pl commented 1 year ago

Yeah, I think this function was removed as deprecated: https://www.ffmpeg.org/doxygen/3.3/group__lavc__decoding.html#gaaa1fbe477c04455cdc7a994090100db4

broes5 commented 1 year ago

Can the deprecated function used in untrunc be swapped out with a new one that does the same thing?

davidebeatrici commented 4 months ago

See https://stackoverflow.com/questions/68240679/avcodec-decode-audio4-was-deprecated-how-can-i-decode-the-audio-frame-of-size-a.

diff --git a/src/codec.cpp b/src/codec.cpp
index e4fac55..e6142a2 100644
--- a/src/codec.cpp
+++ b/src/codec.cpp
@@ -338,7 +338,7 @@ bool Codec::matchSample(const uchar *start) {
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 inline int untr_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt, uint maxlength) {
-       int consumed = avcodec_decode_audio4(avctx, frame, got_frame, pkt);
+       int consumed = pkt->size;

        // ffmpeg 3.4+ uses internal buffer which needs to be updated.
        // this is slow because of the internal memory allocation.
@@ -350,7 +350,7 @@ inline int untr_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_fr
                }
                avcodec_flush_buffers(avctx);
                pkt->size = maxlength;
-               consumed = avcodec_decode_audio4(avctx, frame, got_frame, pkt);
+               consumed = pkt->size;
                if (consumed < 0) {
                        avcodec_flush_buffers(avctx);
                }
@@ -363,7 +363,7 @@ inline int untr_decode_video2(AVCodecContext *avctx, AVFrame *frame, int *got_fr
        // thus there is no way to detect video frame bounderies using ffmpeg3.4+..
        // https://github.com/FFmpeg/FFmpeg/blob/7fc329e2dd6226dfecaa4a1d7adf353bf2773726/libavcodec/avcodec.h#L4793
        // https://github.com/FFmpeg/FFmpeg/commit/061a0c14bb5767bca72e3a7227ca400de439ba09
-       return avcodec_decode_video2(avctx, frame, got_frame, pkt);
+       return pkt->size;
 }
 #pragma GCC diagnostic pop