Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable hardware decoding and check whether it works #372

Closed
usingsystem8 opened this issue Nov 27, 2013 · 44 comments
Closed

How to enable hardware decoding and check whether it works #372

usingsystem8 opened this issue Nov 27, 2013 · 44 comments

Comments

@usingsystem8
Copy link

I'm sorry, but I don't know how to enable hardware decoding while playing videos at all.
By default, does mpv play videos with hardware decoding?
Because I don't know whether mpv is now using hardware decoding, I added an option '--hwdec=vdpau'. However, I think this makes no difference from before.
In addition, please tell me how to check whether hardware decoding is used.

Hardware...MacBook Air (Late 2010)
OS...OS X Mavericks (10.9)

@pigoz
Copy link
Member

pigoz commented Nov 27, 2013

On OS X you need to use --hwdec=vda --vo=corevideo. VDPAU in not an OS X API. There is also https://github.com/mpv-player/mpv/tree/vda_gl_interop this branch if you like testing stuff. It allows to use --hwdec=vda in compination with --vo=opengl.

@pigoz pigoz closed this as completed Nov 27, 2013
@usingsystem8
Copy link
Author

Although I tried '--hwdec=vda --vo=corevideo', but I found that mpv isn't using hardware decoding, because I got a message "Using software decoding."

This is the whole log I got:

Detected file format: QuickTime / MOV (libavformat)
Clip info:
major_brand: isom
minor_version: 512
compatible_brands: isomiso2avc1mp41
encoder: Lavf55.1.0
copyright: hogehoge. All Rights Reserved.
[stream] Video (+) --vid=1 (h264)
[stream] Audio (+) --aid=1 --alang=jpn (aac)
Using software decoding.
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [lavc:h264]
Selected audio codec: AAC (Advanced Audio Coding) [lavc:aac]
AO: [coreaudio] 44100Hz stereo 2ch floatle
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VO: [corevideo] 640x480 => 640x480 yuyv
AV: 00:00:04 / 01:33:08 (0%) A-V: -0.000

@pigoz
Copy link
Member

pigoz commented Nov 27, 2013

can you make sure FFmpeg version is new enough: 2.0 or head? (warning: homebrew installs 1.2 by default).

@usingsystem8
Copy link
Author

Oh, I didn't notice that. My ffmpeg version was 1.2.4. Sorry.
After I update ffmpeg, I'll try hardware decoding.

@usingsystem8
Copy link
Author

I updated ffmpeg to version N-57964-g48f3766. However, I still get the log "Using software decoding".

@pigoz
Copy link
Member

pigoz commented Nov 28, 2013

did you compile ffmpeg with --enable-vda? it is disabled by default.

@usingsystem8
Copy link
Author

I had compiled ffmpeg without --enable-vda, so I recompiled ffmpeg with that option.
Then, I tried playing videos with --hwdec=vda --vo=corevideo, but it still uses software decoding.
Do I have to recompile mpv?

@pigoz
Copy link
Member

pigoz commented Nov 28, 2013

Do I have to recompile mpv?

Yes. You need to rerun ./configure, not just recompile.

@usingsystem8
Copy link
Author

Thank you. I succeeded in using hardware decoding.
I got the log "Trying to use hardware decoding".

What I've done is:
1.git clone https://github.com/mpv-player/mpv-build.git
2.cd mpv-build
3.sh ./force-head
4../update
5.echo --enable-vda >> ffmpeg_options
6.make
7.sudo make install

@pigoz
Copy link
Member

pigoz commented Nov 28, 2013

We should maybe put a notice about --enable-vda somewhere. You are not the first guy to fall for this.

@usingsystem8
Copy link
Author

What option do I have to put after "mpv" on ubuntu?
I think the option is different from Mac.

@ghost
Copy link

ghost commented Dec 4, 2013

Also a combination of --hwdec and --vo, but probably different values. RTFM.

@usingsystem8
Copy link
Author

I'm sorry not to have read the manual.
Now I've read the manual and executed mpv --hwdec=vdpau --vo=opengl <filename>, but an error occurred.
This is the log I got:

Detected file format: QuickTime / MOV (libavformat)
Clip info:
 major_brand: isom
 minor_version: 512
 compatible_brands: isomiso2avc1mp41
 encoder: Lavf55.1.0
[stream] Video (+) --vid=1 (*) (h264)
[stream] Audio (+) --aid=1 --alang=und (*) (aac)
X11 error: GLXBadFBConfig
[vo/opengl] Could not create GL3 context. Retrying with legacy context.
VO does not support requested hardware decoder.
Using software decoding.
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [lavc:h264]
Selected audio codec: AAC (Advanced Audio Coding) [lavc:aac]
AO: [pulse] 44100Hz stereo 2ch floatle
VO: [opengl] 640x480 => 640x480 420p 
AV: 00:00:00 / 01:30:40 (0%) A-V:  0.000                                        

I noticed that opengl doesn't support hardware decoding, so I tried these video outputs:

opengl         : Extended OpenGL Renderer
xv             : X11/Xv
opengl-old     : OpenGL
x11            : X11 ( XImage/Shm )
null           : Null video output
image          : Write video frames to image files
opengl-hq      : Extended OpenGL Renderer (high quality rendering preset)

However, I couldn't play the video with hardware decoding.
Is there any way to play the video with hardware decoding?

[Note]: The os of my pc is ubuntu 13.10.

@pigoz
Copy link
Member

pigoz commented Dec 5, 2013

You need to install vdpau.

@usingsystem8
Copy link
Author

I wanted to install vdpau with command "sudo aptitude install vdpau", but package 'vdpau' wasn't found. Alternatively, I found libvdpau-dev, but it was already installed.
So I installed vdpau-va-driver, but nothing has changed.
What package should I install? Could you give me the exact name of it?

@pigoz
Copy link
Member

pigoz commented Dec 5, 2013

We have a pkg-config check for 'vdpau >= 0.2'. I think that is provided by 'libvdpau-dev'. Maybe post your config.log file created in the build/ directory.

@usingsystem8
Copy link
Author

My config.log file is too long, so I uploaded it to my dropbox.
click here to download

@usingsystem8
Copy link
Author

When I run mpv --hwdec=vdpau --vo=vdpau <filename>, I always get this error:

Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
[vo/vdpau] Error when calling vdp_device_create_x11: 1
Error opening/initializing the selected video_out (-vo) device.

What does this error mean? Does this mean that my pc isn't supported hardware decoding?
(Note: my pc has not a nvidia video card, but an intel video card)

@pigoz
Copy link
Member

pigoz commented Dec 5, 2013

You need to use VAAPI with Intel, not VDPAU. VDPAU is only available for nVidia and AMD afaik.

@usingsystem8
Copy link
Author

Oh, I didn't know that.
However, mpv supports these vo:

Available video outputs:
  vdpau          : VDPAU with X11
  opengl         : Extended OpenGL Renderer
  xv             : X11/Xv
  opengl-old     : OpenGL
  x11            : X11 ( XImage/Shm )
  null           : Null video output
  image          : Write video frames to image files
  opengl-hq      : Extended OpenGL Renderer (high quality rendering preset)

So, I can't select VAAPI as vo.

@usingsystem8
Copy link
Author

I tried mpv --hwdec=vaapi --vo=opengl <filename>, but mpv outputs Using software decoding.
In addition, mpv --hwdec=vaapi --vo=vaapi causes an error [vo] Video output vaapi not found! Error opening/initializing the selected video_out (-vo) device.
How can I use hardware decoding?

@usingsystem8
Copy link
Author

I think --enable-vda option is wrong on ubuntu. What option should I put in ffmpeg_options?

@Nyx0uf
Copy link
Contributor

Nyx0uf commented Dec 5, 2013

VDA is an OS X only API, of course it will not work on Ubuntu.

@usingsystem8
Copy link
Author

Thank you!
I succeeded in playing videos with hardware decoding on ubuntu.

Summarizing the above,

OS X (with Intel Graphics)
[ Installation ]
1.git clone https://github.com/mpv-player/mpv-build.git
2.cd mpv-build
3.sh ./force-head
4../update
5.echo --enable-vda >> ffmpeg_options
6.make
7.sudo make install
[ Playing ]
mpv --hwdec=vda --vo=opengl <filename>

Debian or Ubuntu (with Intel Graphics)
[ Installation ]
1.sudo apt-get install equivs devscripts libva-dev libva-intel-vaapi-driver
2.git clone https://github.com/mpv-player/mpv-build.git
3.cd mpv-build
4.mk-build-deps -s sudo -ir
5.sh ./force-head
6../update
7.echo --enable-vaapi >> ffmpeg_options
8.make
9.sudo make install
[ Playing ]
mpv --hwdec=vaapi --vo=vaapi <filename>

Debian or Ubuntu (with NVIDIA or AMD)
[ Installation ]
1.sudo apt-get install equivs devscripts libvdpau-dev
2.git clone https://github.com/mpv-player/mpv-build.git
3.cd mpv-build
4.mk-build-deps -s sudo -ir
5.sh ./force-head
6../update
7.echo --enable-vdpau >> ffmpeg_options
8.make
9.sudo make install
[ Playing ]
mpv --hwdec=vdpau --vo=vdpau <filename>

*I don't know how to install and play on OS X with NVIDIA or AMD.

@pigoz
Copy link
Member

pigoz commented Dec 5, 2013

on OSX you should prefer mpv --hwdec=vda --vo=opengl <filename> with git HEAD

@usingsystem8
Copy link
Author

What is the difference between corevideo and opengl?
Does opengl process faster than core video?

*Updated my previous comment.

@pigoz
Copy link
Member

pigoz commented Dec 6, 2013

vo_opengl performs color conversion to RGB correctly. OTOH, vo_corevideo always assumes a BT.601 colormatrix when using hwaccel direct rendering (which is wrong for HD video).

@usingsystem8
Copy link
Author

When I use vo=opengl, I got this error:

Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf filter,scale instead of -vf filter.
Attempted filter chain:
 [scale] ??? -> ???
 [vo] ???
Error using hardware decoding, falling back to software decoding.

FATAL: Could not initialize video filters (-vf) or video output (-vo).
[ffmpeg/h264] reference picture missing during reorder
[ffmpeg/h264] reference picture missing during reorder
[ffmpeg/h264] reference picture missing during reorder
[ffmpeg/h264] Missing reference picture, default is 0
[ffmpeg/h264] decode_slice_header error

What was wrong? My config file is clean.

@ghost
Copy link

ghost commented Dec 6, 2013

This should usually happen only if there was a video filter inserted (doesn't seem to be the case), or because the VO doesn't support hardware decoding (doesn't seem to be the case), so I'm unable to guess what's your problem.

@pigoz
Copy link
Member

pigoz commented Dec 6, 2013

you need the git master to use hardware decoding with vo_opengl

@usingsystem8
Copy link
Author

How can I get the git master?

@pigoz
Copy link
Member

pigoz commented Dec 6, 2013

brew install --HEAD mpv

@usingsystem8
Copy link
Author

How can I do it without Homebrew?
I compiled mpv with running sh ./force-head. Is this the way to do it?

@usingsystem8
Copy link
Author

Updated version of the way to use hardware acceleration:
OS X (with Intel Graphics)
[ Installation ]
1: git clone https://github.com/mpv-player/mpv.git
2: cd mpv
3: ./bootstrap
4: ./waf configure --enable-vda-hwaccel
5: ./waf build
6: sudo ./waf install
[ Playing ]
mpv --hwdec=vda <filename>

@xswqaz
Copy link

xswqaz commented Sep 20, 2014

Failed to hwaccel even with --hwdec=vda

[ffmpeg/video] h264: Cannot initialize VDA -12473
failed to init VDA decoder: Generic error returned by the decoder layer. The cause can range from VDADecoder finding errors in the bitstream to another application using VDA at the moment. Only one application can use VDA at a givent time. (-1094995529)
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame!
Error using hardware decoding, falling back to software decoding
VO: [opengl] 1920x1080 => 1920x1080 yuv420p

@pigoz
Copy link
Member

pigoz commented Sep 20, 2014

This is not a mpv issue. Either the file you are watching is not supported by VDA, or VDA is being used by another application on your system.

@xswqaz
Copy link

xswqaz commented Sep 20, 2014

How can I detect Application using VDA?
It was no change after shutdown other application(e.g. Safari)

@usingsystem8
Copy link
Author

Reboot your machine, and the problem will disappear.

@xswqaz
Copy link

xswqaz commented Sep 20, 2014

Problem was not disappeared after Reboot

@usingsystem8
Copy link
Author

Then, what's the codec of the video file?

@xswqaz
Copy link

xswqaz commented Sep 20, 2014

It is h264 I written

@usingsystem8
Copy link
Author

I think this line in the log is associated with this problem:
VO: [opengl] 1920x1080 => 1920x1080 yuv420p

My log is following:
VO: [opengl] 1920x1080 => 1920x1080 vda

You probably should clean your config file.

@ghost
Copy link

ghost commented Sep 20, 2014

You don't need to speculate. This error:

[ffmpeg/video] h264: Cannot initialize VDA -12473
failed to init VDA decoder: Generic error returned by the decoder layer. The cause can range from VDADecoder finding errors in the bitstream to another application using VDA at the moment. Only one application can use VDA at a givent time. (-1094995529)

is pretty clear on what's going on. VDA won't work, and we can't do anything about it. There's (AFAIK) not even a way to see what other applications might use VDA, or any other details about what's wrong.

@xswqaz
Copy link

xswqaz commented Sep 20, 2014

Debug log informed Pixel could be decoded by vda_vld vda yuv420p
and Failed to open decoder instance ( OS X 10.10 PB3 )


[vd] Pixel formats supported by decoder: vda_vld vda yuv420p
[01:15:48.030] vtDecompressionDuctCreate signalled err=-8973 (err) (Could not select and open decoder instance) at /SourceCache/CoreMedia_frameworks/CoreMedia-1562.19/Sources/VideoToolbox/VTDecompressionSession.c line 1181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants