Skip to content

Instantly share code, notes, and snippets.

@wuziq
Forked from neilpa/nv21-convert.sh
Created August 23, 2017 17:39
Show Gist options
  • Save wuziq/362ba0001b6dda576ab2d137101d5f09 to your computer and use it in GitHub Desktop.
Save wuziq/362ba0001b6dda576ab2d137101d5f09 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