jvcleave / ofxOMXPlayer

OpenMax accelerated video player for openFrameworks on the Raspberry Pi 0-3. Does not work with RPI4
GNU General Public License v2.0
180 stars 61 forks source link

Frame flashes white at the end of a movie when looping first time through #32

Closed sethismyfriend closed 6 years ago

sethismyfriend commented 10 years ago

I have 5 or 6 movies compressed with Streamclip which are 6-30 seconds long and loop. They have black backgrounds and all of them seem to have one frame where it flashes white at the end of the first loop (second time through it doesn't do this). I'm not sure how to fix this or why it is happening - it would be better for me if it flashed black - I set the background to black.

Any ideas on what I should be looking at? I think using h.264 via your recommendations should have done the trick for good compression.

lutz-s commented 9 years ago

Hi, it might sound extremely odd, but are these movies without audio track? I had the same issue over here, lots of short clips all looping fine and one was flashing (only!) on the first loop. (Kind of lame when you want to show it to a customer...). Tried all kind of stuff, compressing with final cut, compressor, handbrake, mpegstreamclip - no difference. Tried to cut to keyframes - no difference. A while ago I thought - well, that is the only clip with no audio track.... Just added some some noise (quick'n'dirty with quicktime 7) - voila the flashing seems to be gone. Maybe thats the reason for the flashing thing? lutz

sethismyfriend commented 9 years ago

I will try adding an audio clip and let you know!

On Wednesday, November 26, 2014, lutz-s notifications@github.com wrote:

Hi, it might sound extremely odd, but are these movies without audio track? I had the same issue over here, lots of short clips all looping fine and one was flashing (only!) on the first loop. (Kind of lame when you want to show it to a customer...). Tried all kind of stuff, compressing with final cut, compressor, handbrake, mpegstreamclip - no difference. Tried to cut to keyframes - no difference. A while ago I thought - well, that is the only clip with no audio track.... Just added some some noise (quick'n'dirty with quicktime 7) - voila the flashing seems to be gone. Maybe thats the reason for the flashing thing? lutz

— Reply to this email directly or view it on GitHub https://github.com/jvcleave/ofxOMXPlayer/issues/32#issuecomment-64724957 .


Seth Hunter PhD, MIT Media Lab - Research Scientist at Intel Labs website http://www.perspectum.com/ | inspiration http://arplay.tumblr.com/ | life

http://flickr.com/photos/sethismyfriend/

sethismyfriend commented 9 years ago

For me there is one flash on the first loop - but adding audio did not resolve my problem. I used quicktime 7 and pasted an audio track on the timeline and saved the file. What format are your clips? I could try converting mine - not all of them flash so I'm trying to figure out if its related to the file format.

jvcleave commented 9 years ago

using MediaInfo (https://mediaarea.net/en/MediaInfo) this is the output for my best video. I believe I had to use Compressor in order to get GOP : N=1 (a keyframe every frame) but you may be able to set that option in Quicktime export

The file is much larger but plays back great

General
Complete name : /Volumes/Data/home/pi/videos/current/AirBallonTimecode.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt
File size : 521 MiB
Duration : 4mn 1s
Overall bit rate mode : Variable
Overall bit rate : 18.1 Mbps
Encoded date : UTC 2014-03-06 07:26:44
Tagged date : UTC 2014-03-06 07:26:47
Writing library : Apple QuickTime

Video
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L4.1
Format settings, CABAC : No
Format settings, ReFrames : 2 frames
Format settings, GOP : N=1
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4mn 1s
Bit rate mode : Variable
Bit rate : 16.6 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.720
Stream size : 477 MiB (92%)
Language : English
Encoded date : UTC 2014-03-06 07:26:37
Tagged date : UTC 2014-03-06 07:26:47
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio
ID : 1
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : sowt
Duration : 4mn 1s
Bit rate mode : Constant
Bit rate : 1 536 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Stream size : 44.2 MiB (8%)
Language : English
Encoded date : UTC 2014-03-06 07:26:37
Tagged date : UTC 2014-03-06 07:26:47
cmarty commented 9 years ago

Hi I want to ask if is there any workaround to fix this first time loop white flash. I converted several dozen of video clips (8 - 30s long) from MJPEG to H246 and for the half of them there is this first time loop white flash. I have tried everything (different codec, containter, GOP each frame, silent audio track etc...) and can not get rid of this first loop white flash. I can not even find any connection between the working video clips and those with the white flash. For converting from mjpeg to h264 I use ffmpeg with the parameters: ffmpeg -i $1 -vcodec libx264 -vpre libx264-hq -b 4000k -pass 1 -an $1p1 .mp4 ffmpeg -i $1 -vcodec libx264 -vpre libx264-hq -b 4000k -pass 2 -an $1.mp4 the example of h264 video are here: https://www.dropbox.com/s/4obzo0y2wlee9c5/Whiteflash.mp4?dl=0

I use the ofxomxplayer from commit on 13.12.2014 0880b58 which works great for looping. The next commit 54a16d8 from 26.12.2014 brings some stutter when looping after the first loop. The first loop white flash persist. I checked all this on the last commit but problem persist. I use textured version of player (example-basic) with audio disabled. But enable audio flag or using non textture mode behave same.

Gorgull commented 9 years ago

I agree with cmarty about the stutter happening with revision 54a16d8, and it seems like it's there since then. Any solution but reverting to the 7e0e8f5b revision?

sethismyfriend commented 9 years ago

I looked at the changes and between those revisions. At the bottom there is a change to OMXVideo.cpp related to the timestamp.

Reading around it looks like hints.ptsinvalid gets set when the (presentation timestamp) are not available to xbmc. I wonder if removing this check and forcing OMX_IndexParamBrcmVideoTimestampFifo

When enabled, the timestamp fifo mode will change the way incoming timestamps are associated with output images. In this mode the incoming timestamps get used without re-ordering on output images.

I wonder if sometimes the codecs used before the if hints.ptsinvalid was removed had valid presentation timestamps and now we are forcing it to use decode timestamps which don't allow the frames to be reordered.

This is just a theory based on reading articles like this one which also use the OMX player..


Seth Hunter PhD, MIT Media Lab - Research Scientist at Intel Labs website http://www.perspectum.com/ | inspiration http://arplay.tumblr.com/ | life

http://flickr.com/photos/sethismyfriend/

On Tue, Apr 28, 2015 at 5:15 AM, Pierre Guilluy notifications@github.com wrote:

I agree with cmarty about the stutter happening with revision 54a16d8 https://github.com/jvcleave/ofxOMXPlayer/commit/54a16d8206e69481413440d2cfa200c2a296bec1, and it seems like it's there since then. Any solution but reverting to the 7e0e8f5 https://github.com/jvcleave/ofxOMXPlayer/commit/7e0e8f5bea9d6f10459083e67c1acb131e244dfe revision?

— Reply to this email directly or view it on GitHub https://github.com/jvcleave/ofxOMXPlayer/issues/32#issuecomment-97040505 .

jvcleave commented 9 years ago

@sethismyfriend good point

An easy test would be to try a problematic video and set

timeStampMode.bEnabled = OMX_FALSE;

OMXVideo.cpp applies to Non-Texture mode and OMXEGLImage.cpp applies to Texture mode

cmarty commented 9 years ago

I think I found where the white flash problem is. In class ofxOMXPlayerEngine in function void ofxOMXPlayerEngine::Process(). When there is omxReader.SeekTime(0 * 1000.0f, AVSEEK_FLAG_BACKWARD, &startpts);\n packet = omxReader.Read(); packet.pts and packet.dts aren't adjusted after loop with loop offset and this packet with pts and dts == 0 do this white flash in second loop. I just simply comment the line packet = omxReader.Read(); and it helps. Now I was able to move my working branch to your commit 5a11459 (9.Jan2015). But next commit a0397ce from (10.Jan 2015) produce next visual problem when looping. It is due to the fact that when video starts the dts and pts are not == 0 and after the seek (loop) and adding loop_offset there is a gap in dts,pts ordering. What helps me with debuging is displaing the pts and dts in OMXPlayerVideoBase.cpp. For test you can try video in my previous post.

HakanL commented 9 years ago

Hi, do we have a patch for this that solved the issue completely? I have the same problem, I play some h264 videos without looping (and with audio) and they all flash at the end. They are purchased videos (from atmosfx.com) so I'm not sure how they are mastered, but I have white flash/flicker at the end of each of them.

jvcleave commented 9 years ago

@HakanL nothing new. The example movies don't flash so it seems to vary with compression settings.

sethismyfriend commented 9 years ago

@HakanL if you revert to commit of ofxOMXPlayer

git reset --hard a0397ce7eb33719b64e582204929e43a35c24b28 nano ofxOMXPlayerEngine.cpp

and comment out the "packet= omxReader.Read();" line in the Process() function, it may solve your flashing issue for some compressions.

I had 5 videos which I tried recompressing multiple times and could never get rid of the flash, audio or not - so I tried the method above recommended by @cmarty - and its working for my one off purposes.

It removed the flash for 4 out of 5 of my clips - after the first loop.

At this point it's a hack fix. If anyone finds the perfect compression settings please post them in this thread and I'll try them on another fork.


Seth Hunter PhD, MIT Media Lab - Research Scientist at Intel Labs website http://www.perspectum.com/ | inspiration http://arplay.tumblr.com/ | life

http://flickr.com/photos/sethismyfriend/

On Sat, Oct 10, 2015 at 2:29 PM, Jason Van Cleave notifications@github.com wrote:

@HakanL https://github.com/HakanL nothing new. The example movies don't flash so it seems to vary with compression settings.

— Reply to this email directly or view it on GitHub https://github.com/jvcleave/ofxOMXPlayer/issues/32#issuecomment-147127187 .

HakanL commented 9 years ago

ok, thanks for the info. You said it removes the flash after the first loop, I don't loop my videos, does that mean the fix won't work for me?

jvcleave commented 9 years ago

going to do some updates soon in order to accommodate the upcoming OF 0.9. If anyone has videos they are able to send me that cause the white flash feel free to email them (or links to them) at jvcleave@gmail.com