Quote from: arnezami on 05/19/2014 08:43 amI think I have figured it out! Way to go!! That pframe looks absolutely delicious!And look at all this nasty interlacing - talk about different luminance values in the same block! Sheesh!
I think I have figured it out!
So, if you have a broken/completely wrecked) I-frame you can generate a new one by working out what the previous frame looks like, and using that. Simply inject a new i-frame in to the bitstream. Or, you could, if you have a partial I-frame, generate one from a combination of what you do have that looks OK, plus any data from the prewious frame.
Why the video stream can’t be recovered...I’ve been repairing videos full time for the last 7 years, so I immediately knew that the bitstream was corrupt and that at best we could hope to partially fix some frames. Maybe a 50% chance of recovering one or two frames.Based on previous “edge-of-impossible” repairs, I know that the error rate must be close to zero. A 20kb frame, for example, contains 160,000 bits. If more than 2 or 3 of them are wrong, it becomes impossible to repair it.
Please forgive me if this has already been covered somewhere in the previous 50 pages....trying to get my understanding correct.As I understand it I-frames are complete standalone frames - they need no other data to represent aa full frame. P frames are difference frames (as are B but I don't think they are used here). A p-frame contains all the information required to go from the previous P or I frame to the current frame. The result of applying a P-frame to the previous frame should be the current frame. A p-frame is a bunch of 64x64 macroblocks, plus offset information (where the 64x64 base data came from). These contain the difference information from wherever the MB came from and where is it now. So the current frame is basically the previous frame (fully rendered) with the current MB set applied over the top. The result should be a perfect representation of the frame, minus any high frequency compression differences (a bit like JPEG)So, if you have a broken/completely wrecked) I-frame you can generate a new one by working out what the previous frame looks like, and using that. Simply inject a new i-frame in to the bitstream. Or, you could, if you have a partial I-frame, generate one from a combination of what you do have that looks OK, plus any data from the prewious frame. And of course in H264 every frame can be an I-frame, so you could process through, creating a new bitstream from the old one, replacing all P-frames with I-frames.Is that what people are attempting?
If I get a chance, I'll have a chat with our H264 codec team (I work for a company that amongst other things designs and build H264 encoder/decoder chips). It's not my field, though I do have to deal with it sometimes, and sadly the guy who sat opposite me until he left to cycle round NZ a few months ago was quite an expert.
Quote from: arnezami on 05/18/2014 08:15 pmI will also try to figure this out myself. Since we trying something new here (P-frames in combination with others) we can expect some unexpected results. We'll just have to figure out what is going on.Regards,arnezamiHi guys,I think I have figured it out! We were doing it wrong. By extracting the P-frames individually and then making png's of the mpg4-img files we were interpreting the P-frames as if they were I-frames! As you can imagine the mmb for such an instance would not work when the same frame was interpreted as a P-frame.Attached are two interpretations of frame 170. One is simply the extraction of the png using the frame170.mpg4-img file. The other is an extraction of the png using fixed_edit8_part_169.ts with "FRAME0:0:0:-1". This mmb-command completely erases frame 169. Because of that you can see 170 in the next frame interpreted as a P-frame. Looks much better!So when making mmb's for P-frames set all frames before it to "FRAMExx:0:0:-1". Then you will see the frame as interpreted as a P-frame.Regards,arnezamiPS. This is still an hypotheses, but I think this is actually correct or close to it.
I will also try to figure this out myself. Since we trying something new here (P-frames in combination with others) we can expect some unexpected results. We'll just have to figure out what is going on.Regards,arnezami
Actually, thinking more about repairing I-frames, although you may not be able to reconstruct an entire I-frame from the previous P-frame set due to bad cumulative error, the P-frame set MAY be able to fill in gaps in the I-frame if valid data does exist. Might recover a few blocks here and there. What is the I-frame rate in the bitstream btw? (Intra-refresh?) If I were SpaceX I'd increase that at the expense of higher bandwidth - gives much better frame recovery in the event of transmission issues.
That looks good! But when I try doing the same, I don't get this, I get +/- empty frames until the 6th P-frame... Could you generate the *.mpg4-img files for everyone? or at least a test sample between 169 and 189?
./ffmpeg -r 44999/3003 -mmb `cat mmb_starting_from_169.txt` -debug mb_pos_size -err_detect ignore_err -i fixed_edit8_part_169.ts -f image2 fixed_edit8_part_169_%03d.png
FRAME0:0:0:-1
FRAME0:0:0:-1=FRAME1:0:0:-1
FRAME0:0:0:-1=FRAME1:0:0:-1=FRAME2:0:0:-1
FRAME0:0:0:-1=FRAME1:0:0:-1=FRAME2:0:0:-1=FRAME3:0:0:-1
Quote from: SwissCheese on 05/19/2014 03:59 pmThat looks good! But when I try doing the same, I don't get this, I get +/- empty frames until the 6th P-frame... Could you generate the *.mpg4-img files for everyone? or at least a test sample between 169 and 189?Hi,I posted all .mpg4-img files here in a zip called fixed_edit8_all_frames_mpg4-img.zipWhat happens if you download fixed_edit8_part_169.zip. Unzip it. Then edit mmb_starting_from_169.txt to contain "FRAME0=0:0:-1=FRAME1=0:0:-1=FRAME2=0:0:-1". And run this command:Quote./ffmpeg -r 44999/3003 -mmb `cat mmb_starting_from_169.txt` -debug mb_pos_size -err_detect ignore_err -i fixed_edit8_part_169.ts -f image2 fixed_edit8_part_169_%03d.pngYou should get three gray frames followed by the 3rd P-frame. And you should be able to do this for every n-th frame. I will test this myself later when I have some more time but I expect this to work.Regards,arnezami
I know, but I cannot manage to make the multiple mmb work correctly, still the same issue... Maybe I should try to install everything on a unix/linux machine?
Quote from: Shanuson on 05/18/2014 11:49 pmQuote from: Shanuson on 05/18/2014 02:14 pmThe following is important for all of us that are working on the raw video stream file. I will attach 15 parts of raw_edit8.ts each containing a I-Frame and the following P-frames too a follow on post.<snip>Maybe someone can add a wiki page where people can write down which part they are fixing. CheersShanusonI will take care of this tomorrow. I'm currently debating over different options... the current structure is not ideal. I hope I'll be able to come with a better design for the wiki, in order to keep things more organized. Any suggestions will be greatly appreciated.
Quote from: Shanuson on 05/18/2014 02:14 pmThe following is important for all of us that are working on the raw video stream file. I will attach 15 parts of raw_edit8.ts each containing a I-Frame and the following P-frames too a follow on post.<snip>Maybe someone can add a wiki page where people can write down which part they are fixing. CheersShanuson
The following is important for all of us that are working on the raw video stream file. I will attach 15 parts of raw_edit8.ts each containing a I-Frame and the following P-frames too a follow on post.<snip>
Quote from: IainCole on 05/18/2014 10:34 amThis is fixed.Great! Works well now I've been thinking about the P-frames for the online editor. I think what would be useful and fairly easy to add is a third dropdown. What you get is first the option of the ts file (raw_edit8 for example). Then you select the "base I-frame" in the second dropdown. And then you can choose the actual frame (which would default to the first frame (=I-frame)) in the third dropdown. In the case of edit8 the third drowdown not only contains the I-frame but also the P-frames within the chosen base I-frame. And you keep using the framexxx.mpg4-img files as your input to ffmpeg. That way more ppl can start working on the P-frames. In the case of try1 and coerced you only get one option in the third dropdown, which is always chosen.Of course this will only show the P-frame individually (not fed by I-frame data). And we should also make sure we can run it though the multi-mmb call to ffmpeg, but thats for later I guess. Regards,arnezami
This is fixed.
./ffmpeg -r 44999/3003 -mmb <the mmb commands> -debug mb_pos_size -err_detect ignore_err -i fixed_edit8_part_169.ts -f image2 fixed_edit8_part_169_%03d.png
FRAME0:0:0:-1=FRAME1:0:0:-1=FRAME2:0:0:-1=FRAME3:0:0:-1=FRAME4=
How am I supposed to interpret the log? before I was just looking as MB positions and parsing that to give you info n the editor. How does this work for p frames?
[force CFR for input from stream 0:0 @ 0x1b354a0] N:0 PTS:0 T:0.000000 POS:0 INTERLACED:0 -> PTS:0 T:0.000000[AVIOContext @ 0x1b410e0] Statistics: 0 seeks, 1 writeouts
[force CFR for input from stream 0:0 @ 0x1b354a0] N:1 PTS:6006 T:400.809307 POS:21432 INTERLACED:0 -> PTS:1 T:0.066735[AVIOContext @ 0x1ba7cc0] Statistics: 0 seeks, 1 writeouts
[mpeg4 @ 0x1b49d00] MB pos/size: 0 002:03:01:3521 128 dc: 140 159 28 32 - 128 129, MB_type: 513, MV: 0 0