lucid-dreams / electricsheep

private copy: Automatically exported from code.google.com/p/electricsheep
1 stars 0 forks source link

ContentDecoder failing to decode frames #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi guys,

this is more of a "cry for help" rather than a bugreport. I just want to get a 
pointer or two about where to look further from someone who is more skilled in 
using ffmpeg/libav* API than I am.

I have been battling with the issue of getting electricsheep to run correctly 
on my ArchLinux box. As I have posted in ticket #11 I was able to get it to 
compile but once a few sheep are downloaded, the screensaver acts like nothing 
is going on -- nothing gets displayed, not even the window is cleared so the 
screen shows whatever content there was before electricsheep was run.

I spent the last few evenings trying to trace the code in gdb and so far I have 
been able to find out that while the call to avcodec_decode_video2() returns a 
value > 0 (in fact, that value is equal to the size of the packet as defined by 
packet.size member), the flag indicating successful retrieval of the frame 
(called frameDecoded) is always 0 so the rest of the method is skipped and thus 
nothing gets displayed. When I ran electricsheep under gdb, I saw lots of 
threads repeatedly getting started and terminated immediately thereafter.

Having no prior experience with ffmpeg, I googled up a tutorial ( 
http://dranger.com/ffmpeg/tutorial01.html ) and noticed that after the frame is 
allocated by a call to avcodec_alloc_frame(), another step is made before the 
packets are read out and processed. Following the tutorial, I added the code to 
allocate the buffer for the raw image data and bound it to the frame object 
with the call to avpicture_fill(). However, that still doesn't cut it. (Maybe 
this whole step was not necessary since electricsheep has its own way of 
displaying stuff but it was worth a shot :) ).

So that is what I was able to find out up to this point. I'm kinda running out 
of ideas at the moment so if anyone can chime in with their proposals, I'm more 
than willing to listen. :)

Thanks a lot in advance.

Regards, Zbynek

Original issue reported on code.google.com by znovo...@gmail.com on 8 Nov 2013 at 1:06

GoogleCodeExporter commented 9 years ago
Okay, a little followup info -- I was finally able to get electricsheep to 
render sheep on the screen. I found inspiration in this discussion --> 
http://libav-users.943685.n4.nabble.com/Libav-user-got-picture-ptr-of-avcodec-de
code-video2-always-returns-0-for-a-particular-MTS-file-td4360493.html -- where 
the advisor points out that the video in question contained "non-displayable" 
(?) frames for which avcodec_decode_video2() returned 0 in the flag used to 
indicate a valid video frame.

Thus I changed CContentDecoder::ReadOneFrame() method to repeatedly attempt to 
get a valid frame (with a maximum of 10 attempts before giving up) and it turns 
out that for some sheep, there are as many as 5 frames at the beginning that 
have to be skipped before the first usable frame is obtained. However, there 
are no other frames in that sheep that have to be skipped this way.

This makes me wonder why this happens -- is it a quirk of the codec used by 
electricsheep or something? Also, what is the behavior of electricsheep on 
other platforms? After all, this is shared code that should pretty much behave 
the same way on all supported platforms. Can anyone say how it works on 
Windows/Mac?

At any rate, this wasn't the only problem with electricsheep that prevents its 
proper use. It seems that the input processing part is also somewhat broken 
because when I run the screensaver via the command line, I cannot terminate it 
from its window, even with Ctrl+C; I always have to go to the command line and 
press Ctrl+C there. (Maybe the deprecation message mentioned in ticket #13 has 
something to do with that.)

Original comment by znovo...@gmail.com on 9 Nov 2013 at 6:56