mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 113 forks source link

Problem with animated GIF #710

Open sergiohinniger opened 2 years ago

sergiohinniger commented 2 years ago

Recently i've opened an issue (already closed) that i thought it was an compilation problem or a video problem: error decoding video (receiving frame): End of file, in attract mode 2.6.2, in a RPi 4, compiled with Xinerama.

But now i managed to discover that in reality this issue happens with all animated gifs. I have tried with a bunch of different animated gifs and all causes the "error decoding video (receiving frame): End of file"

If anyone knows anything about it i will be grateful.

OzFalcon commented 2 years ago

I was getting the same warning with video files while looking at #720 So I tried re-encoding various video files & encoding sequences of images. To cut a long story short, I found that using "ffmpeg -crf 0" caused the warning.

Error decoding video (receiving frame): End of file

Even when re-encoding known good video files.

H264 wiki mentions -crf 0 is lossless https://trac.ffmpeg.org/wiki/Encode/H.264

A re-encode with -crf 1 works fine.... ffmpeg -r:v 30 -i "./Countdown 5 Seconds HD.mp4" -codec:a aac -codec:v libx264 -preset medium -pix_fmt yuv420p -crf 1 "output_crf1.mp4"

OzFalcon commented 2 years ago

Animated PNG files seem to be handled the same (With same warning) https://github.com/mickelson/attract/blob/c209088df7ca5afda17f928e17056092b9874ccd/src/media.cpp#L1376 animated_0-9

AM requires the animated png to have a *.apng extension

OzFalcon commented 2 years ago

A quick look at media.cpp seems to indicate that do_flush has something to do with End of file. Skipping the do_flush sequence seems to avoid the error/warning.

However do_flush purpose is to be realized before this is satisfactory.

OzFalcon commented 2 years ago

Update on media.cpp Looks like the do_flush was recently added. https://github.com/mickelson/attract/commit/1b933c39dbd9201b09140e922babe21939d64dad

Commit notes:

However I suspect that we only need to send a null packet to the decoder, And don't need to receive a frame....

OzFalcon commented 2 years ago

The "r" status shows a value of -541478725 with animated Gif/Png & some mp4 files.

OzFalcon commented 2 years ago

On second thoughts this patch is a better approach to the EOF warning for animated gif, png & lossless h264. Rather than looking at the status value it just checks to see if do_flush is executing.

Pull request (If Andrew deems it acceptable) https://github.com/mickelson/attract/pull/726

Local Commit https://github.com/OzFalcon/attract/commit/ed2e966a6edf8eae5b739ec395c51efa9a17eaa0