De-identifying your ultrasound videos:Step-by-step instructions for cropping videos on your Mac using FFmpeg

Batch Cropping

  1. Copy crop_all.command from your Desktop to a directory full of videos and images to be cropped
  2. Double click crop_all.command
  3. Type how many pixels you would like to crop from top and hit enter (28 works well for Sonosite video)

Note: FFmpeg must be installed for the script to work. Cropped videos will be saved to same directory, leaving original files alone. The cropped videos will have original name with _cropped added. Example: will be saved as If your still images are upside down and flipped after cropping (GE images) see this page.

Single File Cropping

  1. Place video or image on your Desktop
  2. Open a Terminal window.
  3. Change to the desktop directory with this command: cd ~/Desktop
  4. To crop video use this command:

ffmpeg -i INVIDEO.MP4 -sameq -b 8000k -vf crop=in_w:in_h-28:0:28 OUTVIDEO.MP4

replace text in red:
  • INVIDEO.MP4: replace with the name of your uncropped video, e.g. or cardiac.avi or pneumothorax.mp4
  • OUTVIDEO.MP4: replace with the name you want your cropped video to be, e.g. or cardiac1.avi or pneumothorax1.mp4
  • 28: Replace both instances of 28 with the same number as needed to crop more/fewer pixels. This is the number of pixels to crop from top of the invideo, 28 works well for Sonosite clips.

Note: FFmpeg must be installed for this to work. It doesn’t matter if you use upper or lower case for filename (it will still crop if your video is name and your “invideo” is; however, spacing DOES matter, so you’ll have to put in a “_” for any spaces (e.g. instead of CBD; keep the output filetype the same as the input to avoid problems with playback (mp4, mov, avi, wmv etc). Lastly, the -b 8000k flag means that the output video will be 8000 kbps (or 1MB/s). This can be increased if the output video quality is not sufficient, or decreased to save space.


  • Crop 50 pixels off top of gallbladder.mp4, save as gallbladder1.mp4
ffmpeg -i gallbladder.mp4 -sameq -vf crop=in_w:in_h-50:0:50 gallbladder1.mp4

  • Crop 75 pixels off top of echo.avi, save as echo_cropped.avi
ffmpeg -i echo.avi -sameq -vf crop=in_w:in_h-75:0:75 echo_cropped.avi

Other Resources

  • Much more detail than you ever wanted to know about the ffmpeg crop nomenclature and usage here.
  • A MacOS GUI frontend to ffmpeg can be downloaded herethat supports batch encoding, just make sure you are using the "-sameq" and "-b 8000" flags to maintain video quality. The GUI hides the command line often times, making it difficult to know exactly what options are being used.
  • A Mac Automator action has been created for ffmpeg, might be used to batch convert files.


Ben C Smith, MD, FACEP