I don't think there is a direct way to do it, but the following bash script should work for you. It's a two step procedure :
- You'll need to create temporary shapefiles for each feature so that you can extract the feature Extent
- You will then pass the extent to gdal_translate.
for id in $(ogrinfo -ro -al input.shp | grep uniqueID | grep -o '[0-9]*');
do
ogr2ogr tmp_ouput$id.shp input.shp -where "uniqueID = $id";
extent=$( ogrinfo -al -so input$id | grep Extent | sed 's/Extent: (//g' | sed 's/)//g' | sed 's/(//g' | sed 's/-/,/g' | awk -F, '{print $1 $2 $3 $4}' );
gdal_translate -projwin $extent -of GTiff input_raster.tif subset_raster.tif";
done
You'll need to replace 'uniqueID' with a unique Feature or Object ID in your shapefile.
Kudos to this post as it was very useful.