count++;
output.write(firstByte);
if ((firstByte & MPEGFrameHeader.SYNC_BYTE1) == MPEGFrameHeader.SYNC_BYTE1) {
// if byte is $FF, we must check the following byte if there is one
if (input.available() > 0) {
input.mark(1); // remember where we were, if we don't need to unsynchronize
int secondByte = input.read();
if ((secondByte & MPEGFrameHeader.SYNC_BYTE2) == MPEGFrameHeader.SYNC_BYTE2) {
// we need to unsynchronize here
if (logger.isLoggable(Level.FINEST)) {
//logger.finest("Writing unsynchronisation bit at:" + count);