Program: 28286
Project: 28286
Buggy source:
public static void main(String[] args) throws Exception, org.bytedeco.javacv.FrameGrabber.Exception {
  int captureWidth=1280;
  int captureHeight=720;
  OpenCVFrameGrabber grabber=new OpenCVFrameGrabber(WEBCAM_DEVICE_INDEX);
  grabber.setImageWidth(captureWidth);
  grabber.setImageHeight(captureHeight);
  grabber.start();
  FFmpegFrameRecorder recorder=new FFmpegFrameRecorder("String_Node_Str",captureWidth,captureHeight,2);
  recorder.setInterleaved(true);
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoBitrate(2000000);
  recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
  recorder.setFormat("String_Node_Str");
  recorder.setFrameRate(FRAME_RATE);
  recorder.setGopSize(GOP_LENGTH_IN_FRAMES);
  recorder.setAudioOption("String_Node_Str","String_Node_Str");
  recorder.setAudioQuality(0);
  recorder.setAudioBitrate(192000);
  recorder.setSampleRate(44100);
  recorder.setAudioChannels(2);
  recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
  recorder.start();
  new Thread(new Runnable(){
    @Override public void run(){
      AudioFormat audioFormat=new AudioFormat(44100.0F,16,2,true,false);
      Mixer.Info[] minfoSet=AudioSystem.getMixerInfo();
      Mixer mixer=AudioSystem.getMixer(minfoSet[AUDIO_DEVICE_INDEX]);
      DataLine.Info dataLineInfo=new DataLine.Info(TargetDataLine.class,audioFormat);
      try {
        TargetDataLine line=(TargetDataLine)AudioSystem.getLine(dataLineInfo);
        line.open(audioFormat);
        line.start();
        int sampleRate=(int)audioFormat.getSampleRate();
        int numChannels=audioFormat.getChannels();
        int audioBufferSize=sampleRate * numChannels;
        byte[] audioBytes=new byte[audioBufferSize];
        ScheduledThreadPoolExecutor exec=new ScheduledThreadPoolExecutor(1);
        exec.scheduleAtFixedRate(new Runnable(){
          @Override public void run(){
            try {
              int nBytesRead=line.read(audioBytes,0,line.available());
              int nSamplesRead=nBytesRead / 2;
              short[] samples=new short[nSamplesRead];
              ByteBuffer.wrap(audioBytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(samples);
              ShortBuffer sBuff=ShortBuffer.wrap(samples,0,nSamplesRead);
              recorder.recordSamples(sampleRate,numChannels,sBuff);
            }
 catch (            org.bytedeco.javacv.FrameRecorder.Exception e) {
              e.printStackTrace();
            }
          }
        }
,0,(long)1000 / FRAME_RATE,TimeUnit.MILLISECONDS);
      }
 catch (      LineUnavailableException e1) {
        e1.printStackTrace();
      }
    }
  }
).start();
  CanvasFrame cFrame=new CanvasFrame("String_Node_Str",CanvasFrame.getDefaultGamma() / grabber.getGamma());
  Frame capturedFrame=null;
  while ((capturedFrame=grabber.grab()) != null) {
    if (cFrame.isVisible()) {
      cFrame.showImage(capturedFrame);
    }
    if (startTime == 0)     startTime=System.currentTimeMillis();
    videoTS=1000 * (System.currentTimeMillis() - startTime);
    if (videoTS > recorder.getTimestamp()) {
      System.out.println("String_Node_Str" + videoTS + "String_Node_Str"+ recorder.getTimestamp()+ "String_Node_Str"+ (videoTS - recorder.getTimestamp()));
      recorder.setTimestamp(videoTS);
    }
    recorder.record(capturedFrame);
  }
  cFrame.dispose();
  recorder.stop();
  grabber.stop();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception, org.bytedeco.javacv.FrameGrabber.Exception {
  int captureWidth=1280;
  int captureHeight=720;
  OpenCVFrameGrabber grabber=new OpenCVFrameGrabber(WEBCAM_DEVICE_INDEX);
  grabber.setImageWidth(captureWidth);
  grabber.setImageHeight(captureHeight);
  grabber.start();
  FFmpegFrameRecorder recorder=new FFmpegFrameRecorder("String_Node_Str",captureWidth,captureHeight,2);
  recorder.setInterleaved(true);
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoOption("String_Node_Str","String_Node_Str");
  recorder.setVideoBitrate(2000000);
  recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
  recorder.setFormat("String_Node_Str");
  recorder.setFrameRate(FRAME_RATE);
  recorder.setGopSize(GOP_LENGTH_IN_FRAMES);
  recorder.setAudioOption("String_Node_Str","String_Node_Str");
  recorder.setAudioQuality(0);
  recorder.setAudioBitrate(192000);
  recorder.setSampleRate(44100);
  recorder.setAudioChannels(2);
  recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
  recorder.start();
  new Thread(new Runnable(){
    @Override public void run(){
      AudioFormat audioFormat=new AudioFormat(44100.0F,16,2,true,false);
      Mixer.Info[] minfoSet=AudioSystem.getMixerInfo();
      Mixer mixer=AudioSystem.getMixer(minfoSet[AUDIO_DEVICE_INDEX]);
      DataLine.Info dataLineInfo=new DataLine.Info(TargetDataLine.class,audioFormat);
      try {
        TargetDataLine line=(TargetDataLine)AudioSystem.getLine(dataLineInfo);
        line.open(audioFormat);
        line.start();
        int sampleRate=(int)audioFormat.getSampleRate();
        int numChannels=audioFormat.getChannels();
        int audioBufferSize=sampleRate * numChannels;
        byte[] audioBytes=new byte[audioBufferSize];
        ScheduledThreadPoolExecutor exec=new ScheduledThreadPoolExecutor(1);
        exec.scheduleAtFixedRate(new Runnable(){
          @Override public void run(){
            try {
              int nBytesRead=0;
              while (nBytesRead == 0) {
                nBytesRead=line.read(audioBytes,0,line.available());
              }
              int nSamplesRead=nBytesRead / 2;
              short[] samples=new short[nSamplesRead];
              ByteBuffer.wrap(audioBytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(samples);
              ShortBuffer sBuff=ShortBuffer.wrap(samples,0,nSamplesRead);
              recorder.recordSamples(sampleRate,numChannels,sBuff);
            }
 catch (            org.bytedeco.javacv.FrameRecorder.Exception e) {
              e.printStackTrace();
            }
          }
        }
,0,(long)1000 / FRAME_RATE,TimeUnit.MILLISECONDS);
      }
 catch (      LineUnavailableException e1) {
        e1.printStackTrace();
      }
    }
  }
).start();
  CanvasFrame cFrame=new CanvasFrame("String_Node_Str",CanvasFrame.getDefaultGamma() / grabber.getGamma());
  Frame capturedFrame=null;
  while ((capturedFrame=grabber.grab()) != null) {
    if (cFrame.isVisible()) {
      cFrame.showImage(capturedFrame);
    }
    if (startTime == 0)     startTime=System.currentTimeMillis();
    videoTS=1000 * (System.currentTimeMillis() - startTime);
    if (videoTS > recorder.getTimestamp()) {
      System.out.println("String_Node_Str" + videoTS + "String_Node_Str"+ recorder.getTimestamp()+ "String_Node_Str"+ (videoTS - recorder.getTimestamp()));
      recorder.setTimestamp(videoTS);
    }
    recorder.record(capturedFrame);
  }
  cFrame.dispose();
  recorder.stop();
  grabber.stop();
}