Get File Information

Why Create This Page

I am creating this page to standardize the methods by which I obtain information about user uploaded files - mainly image, audio, and video (media) files. When a user uploads media or document files, there are various concerns:

  • For Image Files:
    1. You need to make sure that the image file does not contain any inappropriate content.
    2. You may want to generate a caption for the image in the case that the user did not provide one already (this helps with accessability). This could also be useful for text-to-image search.
    3. You want to know the image file format. Different web browsers are capable of showing only some image formats, so you may want to use ImageMagick to convert the image to a common format that can be displayed by all browsers.
    4. You want to know the file size of the image. You want to have a max file size so that images load quickly.
    5. You want to know the width and height of the image. You may need to resize images to different widths and heights to display them at different sizes.
    6. You want to have a vector for the image - this can help with analysis and image search.
    7. You want to know whether the image is transparent and you want to know the background color of the image. This way, when you are resizing the image, you know an appropriate background color to use.
    8. You want to know whether the image contains lighter colors or darker colors. This way, when the image is transparent, you know whether to use a white or black background.
  • For Audio Files:
    1. You need to determine the size of an audio file. Most sites only allow files of a certain size to be uploaded. The maximum file size also affects server size and the size requirement for serverless function - if you choose to go in that direction.
    2. You need to determine the audio file format and each stream's codec. You need to determine the sample rate, channels, duration, and bit rate of each stream.
    3. You need to determine the start time,duration, bit rate, and number of streams for the audio file.
    4. You need to create a VTT file for the audio file to be used for closed captioning. You can also use the text from this file to determine if the audio is inappropriate.
  • For Video Files:
    1. You need to determine the size of a video file. Most sites only allow files of a certain size to be uploaded. The maximum file size also affects server size and the size requirement for serverless function - if you choose to go in that direction.
    2. You need to do everything that you did for audio files for the audio streams that are encapsulated in the video.
    3. You need to determine the video file format. For each stream, you need to determine the codec type, profile, width, height, aspect ratio, frame rate, number of frames, start time, duration, and bit rate.
      • You can extract each frame and perform a content moderation ML model on each image to make sure that the video does not contain anything inappropriate.
    4. You need to determine the start time, bit rate, number of streams, probe score, and number of streams encapsulated in the video file.
  • For Documents:
    1. You need to determine the size of a text document. Most sites only allow files of a certain size to be uploaded.
    2. You need to determine the type of document (.md, .tex, .ipynb, .docx, ...).
    3. If the document contains images, then you need to do everything that you do for image files for every image in the document.

Image File Information

Audio File Information

Video File Information

Document Information