Skip to content

Instantly share code, notes, and snippets.

@neilpa
Last active October 12, 2023 13:14
Show Gist options
  • Save neilpa/2bfa8baa9372b5a3c908 to your computer and use it in GitHub Desktop.
Save neilpa/2bfa8baa9372b5a3c908 to your computer and use it in GitHub Desktop.
Use ffmpeg to convert raw Android camera frame buffers
# Assuming the raw byte[] buffer from onPreviewFrame was written at $1
INPUT=$1
# Need preview size since we dumped to a raw file w/out header info
SIZE=1280x960
# Converting to JPEG
ffmpeg -f image2 -vcodec rawvideo -s $SIZE -pix_fmt nv21 -i $INPUT out.jpeg
# Converting to PNG
ffmpeg -f image2 -vcodec rawvideo -s $SIZE -pix_fmt nv21 -i $INPUT out.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment