Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 167272 - sys-apps/file not identifying mpeg2-ts files properly
Summary: sys-apps/file not identifying mpeg2-ts files properly
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://bugs.gw.com/view.php?id=222
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-16 21:16 UTC by Matthew Schultz
Modified: 2012-12-31 00:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
foo.mpg (foo.mpg,128.00 KB, application/octet-stream)
2007-02-17 17:28 UTC, SpanKY
Details
New file grabbed from 0.21 mythtv identified as data (foo2.mpg,128.00 KB, application/octet-stream)
2008-07-17 21:25 UTC, Matthew Schultz
Details
Patch to fix detection of MPEG transport stream (magic-fix.patch,658 bytes, patch)
2012-12-30 04:47 UTC, Bradley Broom
Details | Diff
Unified diff (magic-fix.udiff,713 bytes, patch)
2012-12-30 07:01 UTC, Bradley Broom
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Schultz 2007-02-16 21:16:35 UTC
sys-apps/file-4.19 is not identifying mpeg2-ts files properly.




I don't know how it's supposed to identify an mpeg2-ts file but it's certainly not a font file.

Reproducible: Always

Steps to Reproduce:
1. Get an mpeg2-ts file
2. file 1518_20070215210000.mpg
Actual Results:  
1518_20070215210000.mpg: TeX font metric data (\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377

Expected Results:  
It should identify as an mpeg file.
Comment 1 Matthew Schultz 2007-02-16 21:21:12 UTC
emerge --info
Portage 2.1.2-r9 (default-linux/amd64/2006.1, gcc-4.1.1, glibc-2.5-r0, 2.6.20-gentoo x86_64)
=================================================================
System uname: 2.6.20-gentoo x86_64 AMD Opteron(tm) Processor 144
Gentoo Base System release 1.12.9
Timestamp of tree: Fri, 16 Feb 2007 09:00:01 +0000
dev-java/java-config: 1.3.7, 2.0.31
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config /var/bind"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer parallel-fetch sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.mirrors.easynews.com/linux/gentoo/ http://mirror.phy.olemiss.edu/mirror/gentoo http://mirror.espri.arizona.edu/gentoo/"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac alsa amd64 apache2 audiofile avi bcmath berkdb bitmap-fonts bzip2 calendar cjk clamav cli cracklib crypt ctype cups curl curlwrappers dio directfb dlloader dri dts dvb dvd dvdread emu-linux-x86 encode exif fbcon ffmpeg flac fortran ftp gd gdbm gif gmp gpm gtk gtk2 hardenedphp hash iconv id3 ieee1394 imagemagick imlib innodb ipv6 isdnlog ithreads java javascript jpeg jpeg2k kde lcms ldap libg++ lzo mad matroska mcal mhash midi mime mjpeg mng mp3 mp4 mpeg mplayer msession mysql mysqli ncurses network nls nptl nptlonly nsplugin nvidia ogg openal opengl osc oss pam pcntl pcre pdf pdo pear perl png posix ppds pppd python qt qt3 qt4 quicktime readline reflection samba sasl sdl seamonkey session simplexml snmp soap sockets spl sqlite ssl svg tcpd theora threads tidy tiff tokenizer transcode truetype truetype-fonts type1-fonts unicode urandom usb v4l v4l2 vcd vorbis wddx wxwindows xforms xine xml xml2 xorg xpm xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="nv nvidia vesa fbdev v4l"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2007-02-16 21:23:00 UTC
Would help to attach some sample I guess? :)
Comment 3 Matthew Schultz 2007-02-16 21:57:38 UTC
Just to note, the source of the mpeg2-ts file is from mythtv.  I did a stream dump from mplayer of a an mpeg2 transport stream and I get this:

file test.ts

Result:
test.ts: data
Comment 4 Matthew Schultz 2007-02-16 21:58:53 UTC
I need to record a short sample from mythtv because the files I have are far to large to attach.
Comment 5 Matthew Schultz 2007-02-17 01:42:16 UTC
Well I can't attach more than a 1mb file (mpeg2-ts gets big really fast), I'm going to have to paste a url where you can get it. This mpeg2-ts file was recorded with mythtv and not run through any post processing program after it was recorded.

http://php.studio11.com/1518_20070216190653.mpg
Comment 6 Matthew Schultz 2007-02-17 01:43:08 UTC
Just to note, the link is only a 3MB file so it should download pretty fast.
Comment 7 SpanKY gentoo-dev 2007-02-17 17:28:38 UTC
Created attachment 110482 [details]
foo.mpg

dd if=1518_20070216190653.mpg of=foo.mpg count=256
file foo.mpg
foo.mpg: TeX font metric data (ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ)
Comment 8 Doug Goldstein (RETIRED) gentoo-dev 2008-07-17 20:21:34 UTC
Are you sure that file is valid? I'm going through my recordings in MythTV and all of them come up as "MPEG sequence, v2, program multiplex" while 2 of them come up as just "data".
Comment 9 Matthew Schultz 2008-07-17 21:25:00 UTC
Created attachment 160669 [details]
New file grabbed from 0.21 mythtv identified as data

I grabbed a piece of a file that I had mythtv record and as of file-4.24, the file is identified as data:

foo2.mpg: data

I downloaded the original foo.mpg file and checked it with file-4.24 and I still get a Tex message with that file.  

I have yet to see an mpeg2-ts file actually identified as such.  If you have an example that identifies it correctly as mpeg2, upload it, so I can test it on my machine to see if it does the same.
Comment 10 Matthew Schultz 2008-07-17 21:27:52 UTC
When attempting to play foo2.mpg, mplayer identifies it as a TS file:

MPlayer dev-SVN-r27120-4.1.2 (C) 2000-2008 MPlayer Team
CPU: AMD Opteron(tm) Processor 144 (Family: 15, Model: 5, Stepping: 10)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

Playing foo2.mpg.
TS file format detected.
VIDEO MPEG2(pid=49) AUDIO A52(pid=52) NO SUBS (yet)!  PROGRAM N. 1
VIDEO:  MPEG2  1920x1080  (aspect 3)  29.970 fps  14000.0 kbps (1750.0 kbyte/s)
Comment 11 Matthew Schultz 2008-07-17 21:30:21 UTC
The original foo.mpg file might have had a problem:

MPlayer dev-SVN-r27120-4.1.2 (C) 2000-2008 MPlayer Team
CPU: AMD Opteron(tm) Processor 144 (Family: 15, Model: 5, Stepping: 10)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

Playing foo.mpg.
TS file format detected.
VIDEO MPEG2(pid=35) AUDIO A52(pid=37) NO SUBS (yet)!  PROGRAM N. 1
MPEG: FATAL: EOF while searching for sequence header.
Video: Cannot read properties.
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 384.0 kbit/25.00% (ratio: 48000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
a52: CRC check failed!
a52: error at resampling
A:3349.9 (55:49.8) of 2.7 (02.7) ??,?%
Comment 12 Bradley Broom 2012-12-30 04:10:18 UTC
This bug is still present in sys-apps/file-5.11 in December 2012!

It detrimentally affects other applications that use file to automagically file video files.

Any ideas on how to solve it?
Comment 13 Bradley Broom 2012-12-30 04:47:48 UTC
Created attachment 333724 [details, diff]
Patch to fix detection of MPEG transport stream


I think the original test was too strict. It was checking that the continuity field was 0, but often it's not. The attached patch removes the check for the continuity byte equal to 0 and file now correctly detects all the MPEG transport stream files I currently have.
Comment 14 Matthew Schultz 2012-12-30 06:34:50 UTC
(In reply to comment #13)
> Created attachment 333724 [details, diff] [details, diff]
> Patch to fix detection of MPEG transport stream
> 
> 
> I think the original test was too strict. It was checking that the
> continuity field was 0, but often it's not. The attached patch removes the
> check for the continuity byte equal to 0 and file now correctly detects all
> the MPEG transport stream files I currently have.

Please post a unified diff.  Also upstream is receptive.  If you create a bug at http://bugs.gw.com/ and post a unified diff there, they will likely patch it for inclusion in the next version.
Comment 15 Matthew Schultz 2012-12-30 06:36:39 UTC
(In reply to comment #13)
> Created attachment 333724 [details, diff] [details, diff]
> Patch to fix detection of MPEG transport stream
> 

I can verify that this patch fixes the bug and correctly identifies the attached foo.mpg as mpeg transport stream data:

(patched 5.11)

$ file foo.mpg 
foo.mpg: MPEG transport stream data
Comment 16 Matthew Schultz 2012-12-30 06:46:10 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > Created attachment 333724 [details, diff] [details, diff] [details, diff]
> > Patch to fix detection of MPEG transport stream
> > 
> > 
> > I think the original test was too strict. It was checking that the
> > continuity field was 0, but often it's not. The attached patch removes the
> > check for the continuity byte equal to 0 and file now correctly detects all
> > the MPEG transport stream files I currently have.
> 
> Please post a unified diff.  Also upstream is receptive.  If you create a
> bug at http://bugs.gw.com/ and post a unified diff there, they will likely
> patch it for inclusion in the next version.

Also include a link to the upstream bug here.
Comment 17 Bradley Broom 2012-12-30 06:47:52 UTC
Oops, sorry. I just noticed that you also need to change another entry a bit further down the file to make file -i option work correctly.  It's exactly the same change because a very similar test is used for the video/mp2t mime type.
Comment 18 Bradley Broom 2012-12-30 07:01:09 UTC
Created attachment 333732 [details, diff]
Unified diff


This is a unified diff that fixes two problems with file related to the identification of mpeg transport streams.
Comment 19 Matthew Schultz 2012-12-30 07:03:49 UTC
(In reply to comment #18)
> Created attachment 333732 [details, diff] [details, diff]
> Unified diff
> 
> 
> This is a unified diff that fixes two problems with file related to the
> identification of mpeg transport streams.

I have confirmed that this patch works with file -i foo.mpg now:

$ file -i foo.mpg 
foo.mpg: video/mp2t; charset=binary
Comment 20 Bradley Broom 2012-12-30 07:20:31 UTC
Upstream bug report:

http://bugs.gw.com/view.php?id=222