oneam / h264bsd

A simple h264 software decoding library
Other
194 stars 52 forks source link

Cant play movie twice #6

Closed BleuBleu closed 7 years ago

BleuBleu commented 8 years ago

Hi!

I am experimenting with your library for H264 decoding. The first time the stream is played, it works really well, but I'm having a problem playing the same stream twice (to simulate looping). The problem seems to come from h264bsdExtractNalUnit which modifies the input stream, possibly to try to fix malformed data. The stream was encoded with x264 and plays well in all video players i have tried.

Do you know of any workaround to fix this issue? Thanks!

-Mat

out.zip

oneam commented 8 years ago

The decoder modifies the bytes that are sent to it. It's an unfortunate side-effect that I have not spent any time looking into.

What I've done in the test applications is to keep a gold master copy of the input stream, then copy it to a decode stream that can be modified by the decoder.

Here's the Javascript example: https://github.com/oneam/h264bsd/blob/master/js/test.html#L50

IOS: https://github.com/oneam/h264bsd/blob/master/ios/test/h264bsd%20Test/ViewController.m#L130