# FULL HD playback



## marudov (Jul 10, 2009)

Hi everybody,

I wanted to turn my FreeBSD box into multimedia station, but I encountered some serious problems: 

First, I have an issue with playing full hd movies. My hardware is good enough to handle them. 

Hardware details : 

```
CPU: Intel(R) Core(TM)2 Quad  CPU   Q8200  @ 2.33GHz (2333.08-MHz K8-class C
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
hw.physmem: 4245417984
hw.usermem: 1882910720
hw.realmem: 5100273664
agp0: <Intel G45 SVGA controller> on vgapci0
```

As written in the handbook, I have tuned kern.ipc.shmmax and kern.ipc.shmall, but still no effect. 

Mplayer output: 


```
MPlayer interrupted by signal 11 in module: decode_video
- MPlayer crashed by bad usage of CPU/FPU/RAM.
  Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and
  disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
- MPlayer crashed. This shouldn't happen.
  It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
  gcc version. If you think it's MPlayer's fault, please read
  DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
  won't help unless you provide this information when reporting a possible bug.
```


I am running Freebsd 7.2 with latest ports installed. 

Any help would be greatly appreciated. 

Thanks.


----------



## marudov (Jul 10, 2009)

I forgot to mention that I have installed the required codecs : 

```
[root@media /usr/ports/multimedia/mplayer]# make showconfig

===> The following configuration options are available for mplayer-0.99.11_13:
     DEBUG=off "Include debug symbols in mplayer's binary files"
     RTCPU=on "Let mplayer dynamically check for CPU features"
     OCFLAGS=on "Use optimized compiler flags"
     SIMD=on "Allow mplayer to use vector engines (MMX...)"
     IPV6=on "Include inet6 network support"
     X11=on "Enable X11 support for mplayer's video output"
     X11XV=on "X11 video drivers: XV"
     X11DGA=on "X11 video drivers: DGA"
     X11GL=on "X11 video drivers: OpenGL"
     X11XIN=on "X11 video drivers: Xinerama"
     X11VM=on "X11 VidMode support"
     X11XVMC=off "Enable XvMC acceleration"
     GUI=on "Enable GTK2 graphical user interface with X11"
     SDL=off "Enable SDL video output"
     VIDIX=on "Enable VIDIX video output on supported archs"
     SKINS=on "Force dependency on mplayer-skins"
     FREETYPE=on "Use freetype for OSD fonts (TrueType!)"
     RTC=off "Add support for kernel real time clock timing"
     ARTS=off "Enable KDE sound system support"
     ESOUND=off "Enable GNOME esound support"
     JACK=off "Enable JackIt audio server support"
     NAS=off "Enable NAS sound server support"
     OPENAL=off "Enable OpenAL sound support"
     LIBUNGIF=on "Enable gif support"
     AALIB=off "Enable aalib support"
     LIBCACA=off "Enable libcaca support"
     SVGALIB=off "Enable svgalib support"
     LIBDV=off "Enable libdv support"
     MAD=on "Enable mad MPEG audio engine support"
     DTS=on "Enable DTS audio codec support"
     LIBMPCDEC=off "Enable libmpcdec support"
     LADSPA=off "Enable LADSPA plugin support"
     SPEEX=on "Enable speex audio codec support"
     TREMOR=off "Use built-in tremor instead of libvorbis"
     XMMS=off "Enable XMMS plugin support"
     THEORA=off "Enable ogg theora video support"
     WIN32=on "Enable win32 codec set on the IA32 arch"
     AMR=on "Enable AMR audio codec support"
     X264=on "Enable x264 (H.264) video codec support"
     XANIM=off "Enable xanim DLL support"
     XVID=on "Enable XVID video codec support"
     REALPLAYER=off "Enable real player plugin"
     LIVEMEDIA=off "Enable LIVE555 streaming support"
     SMB=off "Enable Samba input support"
     FRIBIDI=off "Enable FriBiDi support"
     LIRC=off "Enable lirc support"
     LIBCDIO=off "Enable libcdio support"
     CDPARANOIA=off "Enable cdparanoia support"
     LIBLZO=off "Enable external liblzo library"
     JOYSTICK=off "Enable joystick support"
===> Use 'make config' to modify these settings
```

The video that I try to play is mpeg2-ts.


----------



## SirDice (Jul 10, 2009)

What video output are you using with mplayer?
And what video driver do you use for X?


----------



## marudov (Jul 10, 2009)

The video driver that I use is : 


```
[root@media /usr/ports/multimedia/mplayer]# pkg_info | grep intel           xf86-video-intel-2.7.1 Driver for Intel integrated graphics chipsets
```

First I tried to run mplayer without any parameters, then with -vo xv and some others video outputs, but whatever I use the effect is the same - CPU utilization 100% and mplayer crashes.


----------



## adamk (Jul 10, 2009)

It could be an issue with mplayer.  Have you tried another video player?

Adam


----------



## marudov (Jul 10, 2009)

Yes, I tried VLC, but again no luck. It plays well videos up to 2 GB, but crashes with big, > 20G movies. 

May be intel G45 chipset is not fully supported yet ?


----------



## marudov (Jul 10, 2009)

Here is the output that I get from mplayer: 

```
[root@media /mnt]# mplayer file1080p.ts
MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Quad  CPU   Q8200  @ 2.33GHz (Family: 6, Model: 23, Stepping: 7)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Playing file1080p.ts.
TS file format detected.
VIDEO H264(pid=4113) AUDIO A52(pid=4354) NO SUBS (yet)!  PROGRAM N. 1
FPS seems to be: 23.976025
vo: couldn't open the X11 display ()!
vo: couldn't open the X11 display ()!
VO XOverlay need a subdriver
[gl] using extended formats. Use -vo gl:nomanyfmts if playback fails.
vo: couldn't open the X11 display ()!
vo: couldn't open the X11 display ()!
vo: couldn't open the X11 display ()!
No vidix driver name provided, probing available ones (-v option for details)!
vo: couldn't open the X11 display ()!
vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!
[VO_SUB_VIDIX] Couldn't find working VIDIX driver.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VDec: vo config request - 1920 x 1080 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [null] 1920x1080 => 1920x1080 Planar YV12
A: 605.4 V: 604.9 A-V:  0.495 ct: -0.046 116/116 74%  0%  1.4% 50 0

           ************************************************
           **** Your system is too SLOW to play this!  ****
           ************************************************

Possible reasons, problems, workarounds:
- Most common: broken/buggy _audio_ driver
  - Try -ao sdl or use the OSS emulation of ALSA.
  - Experiment with different values for -autosync, 30 is a good start.
- Slow video output
  - Try a different -vo driver (-vo help for a list) or try -framedrop!
- Slow CPU
  - Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,
    e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.
- Broken file
  - Try various combinations of -nobps -ni -forceidx -mc 0.
- Slow media (NFS/SMB mounts, DVD, VCD etc)
  - Try -cache 8192.
- Are you using -cache to play a non-interleaved AVI file?
  - Try -nocache.
Read DOCS/HTML/en/video.html for tuning/speedup tips.
If none of this helps you, read DOCS/HTML/en/bugreports.html.

[h264 @ 0xcd07e0]left block unavailable for requested intra4x4 mode -1 at 0 0
[h264 @ 0xcd07e0]error while decoding MB 0 0, bytestream (84703)
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 0 16
[h264 @ 0xcd07e0]error while decoding MB 0 16, bytestream (185085)
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 0 34
[h264 @ 0xcd07e0]error while decoding MB 0 34, bytestream (145297)
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 0 50
[h264 @ 0xcd07e0]error while decoding MB 0 50, bytestream (88202)
[h264 @ 0xcd07e0]concealing 8160 DC, 8160 AC, 8160 MV errors


MPlayer interrupted by signal 11 in module: decode_video
- MPlayer crashed by bad usage of CPU/FPU/RAM.
  Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and
  disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
- MPlayer crashed. This shouldn't happen.
  It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
  gcc version. If you think it's MPlayer's fault, please read
  DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
  won't help unless you provide this information when reporting a possible bug.
```


----------



## adamk (Jul 10, 2009)

You would appear to be running mplayer as root, but running X as a regular user.  This can cause lots of problems, as witnessed by the "couldn't open the X11 display ()!" errors.  Run mplayer as the same user logged into X.

Adam


----------



## marudov (Jul 10, 2009)

Thanks for your reply, Adam. Unfortunately, I run X and play the video with the same user - root. 

Any other ideas ?


----------



## marudov (Jul 10, 2009)

Thanks for your reply, Adam. Unfortunately, I run X and play the video with the same user - root. 

Any other ideas ?


----------



## adamk (Jul 10, 2009)

Ewww....  You should not be running X as root.  

I have no explanation for why mplayer is reverting to the null video output device.  Try again as a normal user and show us the output of the mplayer command.

Adam


----------



## marudov (Jul 10, 2009)

I have specified -display :0 and the errors are gone, but again mplayer crashes. Here is the full output: 

```
[root@media /mnt/movies]# ps -auxw | grep X
root        1394  0.5  7.6 425092 315640  p1  S     7:22PM   1:34.27 X (Xorg)
root       23197  0.0  0.0  5932  1288  p2  D+    8:47PM   0:00.00 grep X
[root@media /mnt/movies]# mplayer -display :0 file1080p.ts
MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Quad  CPU   Q8200  @ 2.33GHz (Family: 6, Model: 23, Stepping: 7)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Playing file1080p.ts.
TS file format detected.
VIDEO H264(pid=4113) AUDIO A52(pid=4354) NO SUBS (yet)!  PROGRAM N. 1
FPS seems to be: 23.976025
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VDec: vo config request - 1920 x 1080 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xv] 1920x1080 => 1920x1080 Planar YV12
[ASPECT] Warning: No suitable new res found!
[ASPECT] Warning: No suitable new res found!
[ASPECT] Warning: No suitable new res found!
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 1 0
[h264 @ 0xcd07e0]error while decoding MB 1 0, bytestream (69379)
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 0 16
[h264 @ 0xcd07e0]error while decoding MB 0 16, bytestream (203003)
[h264 @ 0xcd07e0]left block unavailable for requested intra mode at 0 34
[h264 @ 0xcd07e0]error while decoding MB 0 34, bytestream (182242)
[h264 @ 0xcd07e0]top block unavailable for requested intra4x4 mode -1 at 0 50
[h264 @ 0xcd07e0]error while decoding MB 0 50, bytestream (95558)
[h264 @ 0xcd07e0]concealing 8160 DC, 8160 AC, 8160 MV errors


MPlayer interrupted by signal 11 in module: decode_video
- MPlayer crashed by bad usage of CPU/FPU/RAM.
  Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and
  disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
- MPlayer crashed. This shouldn't happen.
  It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
  gcc version. If you think it's MPlayer's fault, please read
  DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
  won't help unless you provide this information when reporting a possible bug.
```

I get the same output when I run it as a regular user

The video starts, but the CPU reaches 100% utilization and if I rew forward, mplayer crashes with the output above.

I will pull my hair off


----------



## adamk (Jul 10, 2009)

No idea then.

Adam


----------



## marudov (Jul 10, 2009)

Ok, thank you Adam. 

Having in mind that my HDMI audio also doesn't work I am forced to switch to linux. Although this is unthinkable for me .. I am the greatest freebsd fan


----------



## graudeejs (Jul 10, 2009)

Reading that someone uses root for daily use on FreeBSD, makes my hard bleed....


----------



## marudov (Jul 10, 2009)

I think the user is not relevant in this case.


----------



## adamk (Jul 10, 2009)

It is still considered a very bad idea to run as root for day-to-day use.  Many people who provide support will stop assisting you as soon as they find out that you are doing that.

Adam


----------



## richardpl (Jul 10, 2009)

What version of Mesa DRI port do you have?
It could be driver problem, vsync issue with intel MSI (fixed on 8.0), or some of Xorg ports.


----------



## marudov (Jul 11, 2009)

thank you for your reply, Richard

dri version:

```
[root@media ~]# pkg_info | grep dri
dri-7.4.4,2         OpenGL hardware acceleration drivers for the DRI
```

and xorg.0.log:


```
[root@media /usr/ports/graphics/dri]# egrep  "EE|WW" /var/log/Xorg.0.log
Current Operating System: FreeBSD media 7.2-RELEASE-p2 FreeBSD 7.2-RELEASE-p2 #0: Mon Jul  6 01:13:40 EEST 2009     root@media:/usr/obj/usr/src/sys/GENERIC amd64
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(WW) AllowEmptyInput is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.
(WW) Disabling Mouse0
(WW) Disabling Keyboard0
(II) Loading extension MIT-SCREEN-SAVER
(WW) intel(0): DRI2 requires UXA
(WW) intel(0): drmDropMaster failed: Unknown error: -1
(WW) intel(0): ESR is 0x00000011, page table error
(WW) intel(0): PGTBL_ER is 0x00100000, CS instruction GTT PTE
(WW) intel(0): Existing errors found in hardware state.
(WW) intel(0): Option "PreferredMode" is not used
(WW) intel(0): drmDropMaster failed: Unknown error: -1
(WW) intel(0): DRI2 requires UXA
(WW) intel(0): drmDropMaster failed: Unknown error: -1
(WW) intel(0): ESR is 0x00000011, page table error
(WW) intel(0): PGTBL_ER is 0x00100000, CS instruction GTT PTE
(WW) intel(0): Existing errors found in hardware state.
(EE) XKB: No components provided for device Virtual core keyboard
(WW) Couldn't load XKB keymap, falling back to pre-XKB keymap
```


----------



## DutchDaemon (Jul 11, 2009)

marudov, do me a favour, and look into code tags when you post system output.


----------



## richardpl (Jul 11, 2009)

And xorg.conf
DRI2 shouldn't be in logs at all.


----------



## adamk (Jul 11, 2009)

DRI2 is loaded by default, these days.  Of course, it's completely unsupported, so Xorg fails to use it (hence the message in his log file), but this is harmless.

Adam


----------



## marudov (Jul 12, 2009)

I used code tags this time. Sorry for the previous posts.

Here is my xorg.conf:


```
Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 40 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
        ModulePath   "/usr/local/lib/xorg/modules"
        FontPath     "/usr/local/lib/X11/fonts/misc/"
        FontPath     "/usr/local/lib/X11/fonts/TTF/"
        FontPath     "/usr/local/lib/X11/fonts/OTF"
        FontPath     "/usr/local/lib/X11/fonts/Type1/"
        FontPath     "/usr/local/lib/X11/fonts/100dpi/:unscaled"
        FontPath     "/usr/local/lib/X11/fonts/100dpi/"
        FontPath     "/usr/local/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
        Load  "dbe"
        Load  "dri"
        Load  "dri2"
        Load  "extmod"
        Load  "glx"
        Load  "record"
EndSection

Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
EndSection

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "auto"
        Option      "Device" "/dev/sysmouse"
        Option      "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Panasonic"
        ModelName    "Viera"
        Modeline "1920x100_50" 148.50   1821 2364 2492 2600   1030 1054 1069 1125 +hsync +vsync
        #Modeline "1920x100_50" 148.50   1860 2448 2492 2640   1060 1084 1089 1125 +hsync
        Option "PreferredMode"  "1920x100_50"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "NoAccel"                   # [<bool>]
        #Option     "SWcursor"                  # [<bool>]
        #Option     "ColorKey"                  # <i>
        #Option     "CacheLines"                # <i>
        #Option     "Dac6Bit"                   # [<bool>]
        #Option     "DRI"                       # [<bool>]
        #Option     "NoDDC"                     # [<bool>]
        #Option     "ShowCache"                 # [<bool>]
        #Option     "XvMCSurfaces"              # <i>
        #Option     "PageFlip"                  # [<bool>]
        Identifier  "Card0"
        Driver      "intel"
        VendorName  "Intel Corporation"
        BoardName   "4 Series Chipset Integrated Graphics Controller"
        BusID       "PCI:0:2:0"
        Option "monitor-HDMI-2" "Monitor0"
EndSection
Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        DefaultDepth    24
        SubSection "Display"
                Viewport   0 0
                Depth     1
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     4
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     8
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     15
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     16
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     24
                Modes "1920x100_50"
        EndSubSection
EndSection
```


----------



## marudov (Jul 22, 2009)

The things got better when I included the drm module in the kernel. Now mplayer does not crash and plays the movies significantly better, but still not smooth. One of the CPU cores reaches 100% utilization, while the others remain unused. This leads to performance issues.

May be mplayer-mt would fix the issue, since it supports multithreading. 

Are ffmpeg-mt and mplayer-mt going to be ported for FreeBSD?


----------



## marudov (Jul 26, 2009)

*Solved*

I have compiled mplayer from source, replacing libavcodec, libavutil and libavformat as described here: 

http://ubuntuforums.org/showthread.php?t=1049449 

So I ended up with mplayer which supports multithreading.
Now the CPU load is evenly distributed across the cores and the performance is very good.

Here is the situation when I invoke mplayer with -lavdopts thread=4 :


```
/0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10
     Load Average   ||||

                    /0%  /10  /20  /30  /40  /50  /60  /70  /80  /90  /100
root     idle: cpu0 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
root     idle: cpu3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
root     idle: cpu2 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
root     idle: cpu1 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
root           Xorg XXXXXXXXXXXXXXXX
roki        mplayer XXXXXXX
roki        mplayer XXXXXXX
roki        mplayer XXXXXXX
roki        mplayer XXXXXX
roki        mplayer XXXXX
```


----------



## Seeker (Feb 6, 2011)

Ain't that already ported?

```
# cat /usr/ports/multimedia/mplayerxp/pkg-descr
```


----------



## richardpl (Feb 6, 2011)

Nope. Long story short: decoding(ffmpeg[red]-mp[/red] code actually) is one thing and reproducing (mplayerxp do this in more than one thread) is another.


----------



## Seeker (Feb 8, 2011)

Ah, I see.
Will this be ported?


----------



## richardpl (Feb 8, 2011)

Maybe. Last time I checked ffmpeg-mp was still experimental. There was talk ffmpeg-mp will be merged into ffmpeg. Mplayer use ffmpeg libraries to play multimedia stuff (libavcodec is one of them). But mplayer can also play files using windows drivers: multimedia/win32-codecs.

It is not hard to compile ffmpeg(latest git version) and mplayer(latest git version) on your own, without using ports.

There is also fork of mplayer...


----------



## mix_room (Mar 8, 2011)

What happens if you run mplayer with another video output? 


```
mplayer FILE -vo x11
```

I have similar problems with mplayer once in a while, still haven't been able to work out why. When I run mplayer with 'mplayer FILE' it crashes, as above works, but is CPU bound and won't play the files at proper speed. 
Perhaps this can help you localize the error.


----------

