Pipeline to create short 8-bit AVIs from 16-bit image stack

I have thousands of .cxd movies, all 1500 frames long and stored as 16-bit. I would like to batch create short movies of the first 250 frames from the command line. Example:

bfconvert -range 0 249 -compression JPEG file.cxd /media/movies/test.avi

This, however, stops already because avi does not support 16bit files:

Exception in thread "main" loci.formats.FormatException: Unsupported image type 'uint16'.

Is there any way I could achieve this, either with bfconvert or any other tool?

Unfortunately the AVI Writer in Bio-Formats does not currently support 16 bit images. You should be able to create a macro in ImageJ/FIJI to use the Bio-Formats Importer to read the file and then export as AVI. Something similar to the below:

run("Bio-Formats Importer", "open=[/path/to/myFile.cxd] autoscale color_mode=Composite rois_import=[ROI manager] specify_range view=Hyperstack stack_order=XYCZT c_begin=1 c_end=2 c_step=1 z_begin=1 z_end=25 z_step=1");
run("AVI... ", "compression=JPEG frame=7 save=[/path/to/myOutput.avi]");