cygwin file command not detecting mpg?

1

0

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

http://www.berkut13.com/videos/brakeup.mpg

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
000001ba2100010001800e3b000001bb000c800e3b07e1ffc0c020e0e02e

$ 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

barlop

Posted 2011-05-07T23:10:08.270

Reputation: 18 677

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 – 2011-05-08T05:44:32.093

Works fine here. $ file brakeup.mpg brakeup.mpg: MPEG sequence, v1, system multiplex – Ignacio Vazquez-Abrams – 2011-05-08T07:16:23.023

here's the magic file http://www.sendspace.com/file/i0qu6h I remember now it was cygwin, i've updated title and tags.

– barlop – 2011-05-08T10:23:52.990

Answers

2

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@ccwf.cc.utexas.edu (VaX#n8)
# FLC, SGI, Apple originally from Daniel Quinlan (quinlan@yggdrasil.com)

# 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

njd

Posted 2011-05-07T23:10:08.270

Reputation: 9 743

thanks, i've just updated my question adding a comment linking to my magic file – barlop – 2011-05-08T10:18:14.617

+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 – 2011-05-08T10:40:43.833

file is a BSD command, and I think you mean 5.05. – Ignacio Vazquez-Abrams – 2011-05-08T10:40:47.970

@Ignacio yes you're right, 5.05 – barlop – 2011-05-08T10:41:49.060