* Re: [FFmpeg-devel] [PATCH v4] examples/decode_video: flush parser to fix missing frame [not found] <tencent_DBB0697601B568767CE6AECA382DC2ADB40A@qq.com> @ 2022-04-11 9:12 ` "zhilizhao(赵志立)" 2022-04-18 16:01 ` "zhilizhao(赵志立)" 0 siblings, 1 reply; 2+ messages in thread From: "zhilizhao(赵志立)" @ 2022-04-11 9:12 UTC (permalink / raw) To: FFmpeg development discussions and patches Ping. The same kind of issue like `doc/examples/transcode_aac: Don't ignore last encoded frame. https://patchwork.ffmpeg.org/project/ffmpeg/patch/8fd28808-07f8-9458-b032-8792c67a38fd@gmail.com/ > On Jul 14, 2021, at 11:02 AM, Zhao Zhili <quinkblack@foxmail.com> wrote: > > --- > v4: break when error occured in fread, fix infinite loop introduced by v3 > v3: check EOF by "eof = !data_size && feof(f);" > > doc/examples/decode_video.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c > index 18ee90a6c0..7238e38103 100644 > --- a/doc/examples/decode_video.c > +++ b/doc/examples/decode_video.c > @@ -92,6 +92,7 @@ int main(int argc, char **argv) > uint8_t *data; > size_t data_size; > int ret; > + int eof; > AVPacket *pkt; > > if (argc <= 2) { > @@ -150,15 +151,16 @@ int main(int argc, char **argv) > exit(1); > } > > - while (!feof(f)) { > + do { > /* read raw data from the input file */ > data_size = fread(inbuf, 1, INBUF_SIZE, f); > - if (!data_size) > + if (ferror(f)) > break; > + eof = !data_size; > > /* use the parser to split the data into frames */ > data = inbuf; > - while (data_size > 0) { > + while (data_size > 0 || eof) { > ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, > data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0); > if (ret < 0) { > @@ -170,8 +172,10 @@ int main(int argc, char **argv) > > if (pkt->size) > decode(c, frame, pkt, outfilename); > + else if (eof) > + break; > } > - } > + } while (!eof); > > /* flush the decoder */ > decode(c, frame, NULL, outfilename); > -- > 2.31.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4] examples/decode_video: flush parser to fix missing frame 2022-04-11 9:12 ` [FFmpeg-devel] [PATCH v4] examples/decode_video: flush parser to fix missing frame "zhilizhao(赵志立)" @ 2022-04-18 16:01 ` "zhilizhao(赵志立)" 0 siblings, 0 replies; 2+ messages in thread From: "zhilizhao(赵志立)" @ 2022-04-18 16:01 UTC (permalink / raw) To: FFmpeg development discussions and patches > On Apr 11, 2022, at 5:12 PM, zhilizhao(赵志立) <quinkblack@foxmail.com> wrote: > > Ping. The same kind of issue like `doc/examples/transcode_aac: Don't ignore last encoded frame. > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/8fd28808-07f8-9458-b032-8792c67a38fd@gmail.com/ Will apply this weekend unless there are objections. > >> On Jul 14, 2021, at 11:02 AM, Zhao Zhili <quinkblack@foxmail.com> wrote: >> >> --- >> v4: break when error occured in fread, fix infinite loop introduced by v3 >> v3: check EOF by "eof = !data_size && feof(f);" >> >> doc/examples/decode_video.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c >> index 18ee90a6c0..7238e38103 100644 >> --- a/doc/examples/decode_video.c >> +++ b/doc/examples/decode_video.c >> @@ -92,6 +92,7 @@ int main(int argc, char **argv) >> uint8_t *data; >> size_t data_size; >> int ret; >> + int eof; >> AVPacket *pkt; >> >> if (argc <= 2) { >> @@ -150,15 +151,16 @@ int main(int argc, char **argv) >> exit(1); >> } >> >> - while (!feof(f)) { >> + do { >> /* read raw data from the input file */ >> data_size = fread(inbuf, 1, INBUF_SIZE, f); >> - if (!data_size) >> + if (ferror(f)) >> break; >> + eof = !data_size; >> >> /* use the parser to split the data into frames */ >> data = inbuf; >> - while (data_size > 0) { >> + while (data_size > 0 || eof) { >> ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, >> data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0); >> if (ret < 0) { >> @@ -170,8 +172,10 @@ int main(int argc, char **argv) >> >> if (pkt->size) >> decode(c, frame, pkt, outfilename); >> + else if (eof) >> + break; >> } >> - } >> + } while (!eof); >> >> /* flush the decoder */ >> decode(c, frame, NULL, outfilename); >> -- >> 2.31.1 >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >> > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-18 16:01 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <tencent_DBB0697601B568767CE6AECA382DC2ADB40A@qq.com> 2022-04-11 9:12 ` [FFmpeg-devel] [PATCH v4] examples/decode_video: flush parser to fix missing frame "zhilizhao(赵志立)" 2022-04-18 16:01 ` "zhilizhao(赵志立)"
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git