diff --git a/src/png.c b/src/png.c index aa7f21d..44724ce 100644 --- a/src/png.c +++ b/src/png.c @@ -2,6 +2,24 @@ #include #include "png.h" +enum AVPixelFormat pix_fmt(AVFrame *in_frame) +{ + // [swscaler @ 0x219f6c0] + // deprecated pixel format used, make sure you did set range correctly + switch (in_frame->format) { + case AV_PIX_FMT_YUVJ420P: + return AV_PIX_FMT_YUV420P; + case AV_PIX_FMT_YUVJ422P: + return AV_PIX_FMT_YUV422P; + case AV_PIX_FMT_YUVJ444P: + return AV_PIX_FMT_YUV444P; + case AV_PIX_FMT_YUVJ440P: + return AV_PIX_FMT_YUV440P; + default: + return in_frame->format; + } +} + int mediatools_write_frame_to_png(AVFrame *in_frame, const char *path) { struct SwsContext *sws_ctx = NULL; @@ -64,7 +82,7 @@ int mediatools_write_frame_to_png(AVFrame *in_frame, const char *path) // Rewrite frame into correct color format - sws_ctx = sws_getContext(in_frame->width, in_frame->height, in_frame->format, out_frame->width, out_frame->height, AV_PIX_FMT_RGBA, SWS_LANCZOS, NULL, NULL, NULL); + sws_ctx = sws_getContext(in_frame->width, in_frame->height, pix_fmt(in_frame), out_frame->width, out_frame->height, AV_PIX_FMT_RGBA, SWS_LANCZOS, NULL, NULL, NULL); if (!sws_ctx) goto error; diff --git a/src/stat.c b/src/stat.c index 1c66407..feb6866 100644 --- a/src/stat.c +++ b/src/stat.c @@ -55,9 +55,6 @@ int main(int argc, char *argv[]) return -1; } - // Best effort attempt to seek to beginning of file - av_seek_frame(format, -1, 0, AVSEEK_FLAG_BACKWARD); - uint64_t frames = 0; int64_t last_pts = 0; int last_stream = 0; diff --git a/src/thumb.c b/src/thumb.c index ecc7761..37cca70 100644 --- a/src/thumb.c +++ b/src/thumb.c @@ -65,8 +65,6 @@ int main(int argc, char *argv[]) return -1; } - av_seek_frame(format, -1, 0, AVSEEK_FLAG_BACKWARD); - // Loop until we get to the first video frame past the intended pts, // decoding all video frames along the way.