don't attempt to rewind before demuxing
This commit is contained in:
parent
b4de9fb0fb
commit
db8de06306
20
src/png.c
20
src/png.c
|
@ -2,6 +2,24 @@
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
#include "png.h"
|
#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)
|
int mediatools_write_frame_to_png(AVFrame *in_frame, const char *path)
|
||||||
{
|
{
|
||||||
struct SwsContext *sws_ctx = NULL;
|
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
|
// 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)
|
if (!sws_ctx)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Best effort attempt to seek to beginning of file
|
|
||||||
av_seek_frame(format, -1, 0, AVSEEK_FLAG_BACKWARD);
|
|
||||||
|
|
||||||
uint64_t frames = 0;
|
uint64_t frames = 0;
|
||||||
int64_t last_pts = 0;
|
int64_t last_pts = 0;
|
||||||
int last_stream = 0;
|
int last_stream = 0;
|
||||||
|
|
|
@ -65,8 +65,6 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_seek_frame(format, -1, 0, AVSEEK_FLAG_BACKWARD);
|
|
||||||
|
|
||||||
// Loop until we get to the first video frame past the intended pts,
|
// Loop until we get to the first video frame past the intended pts,
|
||||||
// decoding all video frames along the way.
|
// decoding all video frames along the way.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue