Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have noticed that the file command in linux, is detecting this mpg as data?

it detects flv ok but this mpg file it doesn't..

i'd like to be able to detect mpg files.

I found the part of the magic file for MPEG..

#                       MPEG file
# MPEG sequences
# FIXME: This section is from the old magic.mime file and needs integrating with the rest
0       belong             0x000001BA
>4      byte               &0x40
!:mime  video/mp2p
>4      byte               ^0x40
!:mime  video/mpeg
0       belong             0x000001BB
!:mime  video/mpeg
0       belong             0x000001B0
!:mime  video/mp4v-es
0       belong             0x000001B5
!:mime  video/mp4v-es
0       belong             0x000001B3
!:mime  video/mpv
0       belong&0xFF5FFF1F  0x47400010
!:mime  video/mp2t
0       belong             0x00000001
>4      byte&0x1F      0x07
!:mime  video/h264

and the file

$ xxd -p brakeup.mpg | head -n 1

$ od -x brakeup.mpg | head -n 2
0000000 0000 ba01 0021 0001 8001 3b0e 0000 bb01
0000020 0c00 0e80 073b ffe1 c0c0 e020 2ee0 0000
share|improve this question
It's a restricted format so it's not surprising that Linux handles it awkwardly. Do you have the w32codecs package and ffmpeg properly installed? – Blomkvist May 8 '11 at 5:44
Works fine here. $ file brakeup.mpg brakeup.mpg: MPEG sequence, v1, system multiplex – Ignacio Vazquez-Abrams May 8 '11 at 7:16
here's the magic file I remember now it was cygwin, i've updated title and tags. – barlop May 8 '11 at 10:23

The file command uses a list of file definitions in a magic file (usually /usr/share/file/magic on linux systems, or /etc/magic on Unix).

Most of the entries in that file are just 'magic' numbers: the file command matches the first few bytes of a file against these entries to identify the file.

Try adding these definitions from this example magic file:

# animation:  file(1) magic for animation/movie formats
# animation formats
# MPEG, FLI, DL originally from (VaX#n8)
# FLC, SGI, Apple originally from Daniel Quinlan (

# MPEG animation format
0   belong      0x000001b3      MPEG video stream data
#>4 beshort&0xfff0  x           (%d x
#>5 beshort&0x0fff  x           %d)
0   belong      0x000001ba      MPEG system stream data

Your brakeup.mpg file begins with 00,00,01,ba so the file command should identify it as MPEG system data at least.

On Ubuntu-based linux distributions, the /usr/share/file/magic already has definitions that will identify that MPG file as:

brakeup.mpg: MPEG sequence, v1, system multiplex
share|improve this answer
thanks, i've just updated my question adding a comment linking to my magic file – barlop May 8 '11 at 10:18
+1 for finding that line.. my magic file has 0x000001BA but also it says "# FIXME: This section is from the old magic.mime file and needs integrating with the rest " It may be more like the BSD version 'cos man file says BSD manual. and it reports as 5.5 – barlop May 8 '11 at 10:40
file is a BSD command, and I think you mean 5.05. – Ignacio Vazquez-Abrams May 8 '11 at 10:40
@Ignacio yes you're right, 5.05 – barlop May 8 '11 at 10:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.