Skip to content

Commit

Permalink
* Fix FFmpegFrameRecorder.record() when called with `AV_PIX_FMT_NV…
Browse files Browse the repository at this point in the history
…21` (pull #787)
  • Loading branch information
michaeldietz authored and saudet committed Sep 13, 2017
1 parent 38f32ae commit 1ecb555
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -889,12 +889,15 @@ public boolean recordImage(int width, int height, int depth, int channels, int s
pixelFormat = AV_PIX_FMT_RGBA;
} else if ((depth == Frame.DEPTH_UBYTE || depth == Frame.DEPTH_BYTE) && channels == 2) {
pixelFormat = AV_PIX_FMT_NV21; // Android's camera capture format
step = width;
} else {
throw new Exception("Could not guess pixel format of image: depth=" + depth + ", channels=" + channels);
}
}

if (pixelFormat == AV_PIX_FMT_NV21) {
step = width;
}

if (video_c.pix_fmt() != pixelFormat || video_c.width() != width || video_c.height() != height) {
/* convert to the codec pixel format if needed */
img_convert_ctx = sws_getCachedContext(img_convert_ctx, width, height, pixelFormat,
Expand Down

0 comments on commit 1ecb555

Please sign in to comment.