JavaFX媒体播放器无法播放视频 [英] JavaFX media player does not play video

查看:245
本文介绍了JavaFX媒体播放器无法播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用OpenJFX 11我正在使用Mediaplayer在Linux系统上播放某些剪辑.其中一些显示,其他不显示.据我所知,编码的唯一区别是未播放的视频包含音轨. 这是播放的视频的mediainfo的输出:

Using OpenJFX 11 I am using a mediaplayer to play some clips on a Linux system. Some of them display, others don't. As far as I can tell the only difference in the encoding is, that the not playing video contains an audio track. This is the output of mediainfo for the video that plays:

General
Complete name                            : OpenPatricianData/src/main/resources/video/event/BlackDeath.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 26.0 MiB
Duration                                 : 30s 0ms
Overall bit rate                         : 7 265 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf54.63.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 30s 0ms
Bit rate                                 : 7 264 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 24.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.146
Stream size                              : 26.0 MiB (100%)
Writing library                          : x264 core 142 r2389 956c8d8
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

这是不起作用的信息:

General
Complete name                            : OpenPatricianData/src/main/resources/video/event/fire.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 30.4 MiB
Duration                                 : 19s 368ms
Overall bit rate                         : 13.2 Mbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf54.63.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L5
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 19s 334ms
Bit rate                                 : 12.9 Mbps
Nominal bit rate                         : 40.0 Mbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 24.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.260
Stream size                              : 29.8 MiB (98%)
Writing library                          : x264 core 142 r2389 956c8d8
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=0 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=40000 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Mode                                     : Joint stereo
Codec ID                                 : 6B
Duration                                 : 19s 368ms
Bit rate mode                            : Constant
Bit rate                                 : 256 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 605 KiB (2%)
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

没有记录或显示任何错误消息.

There is no error message logged or displayed.

如果我没记错的话,以前在版本8中使用JavaFX时,它已经起作用了.此后,我还升级了操作系统,因此也可能缺少一些编解码器.

If I remember correctly this has worked before, when using JavaFX in version 8. Since then I also upgraded the OS, so it could be some missing codecs as well.

  1. 我应该如何用声音编码视频,以便使用JavaFX MediaPlayer播放它?
  2. 如果在某些操作系统上,则需要提供其他编解码器,如这篇旧文章,如何使用Maven项目做到这一点?我不希望用户要求手动安装其他库,以便我的应用程序可以正常工作.
  1. How would I have to encode a video with sound, so that it is played using JavaFX MediaPlayer?
  2. If on certain OS it is required to supply additional codecs, as hinted by this old article, how to do that with a Maven project? I do not want the user to require to install additional libraries by hand, so that my application works.

可能与libavcodec有关的是sudo find / -name 'libavcodec*'返回的列表:

On the chance that it has anything to do with libavcodec here is the list returned by sudo find / -name 'libavcodec*':

/var/lib/dpkg/info/libavcodec-dev:amd64.list
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.list
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.shlibs
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.symbols
/var/lib/dpkg/info/libavcodec-dev:amd64.md5sums
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.triggers
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.md5sums
/var/cache/apt/archives/libavcodec-ffmpeg56_7%3a2.8.14-0ubuntu0.16.04.1_amd64.deb
/var/cache/apt/archives/libavcodec-dev_7%3a2.8.15-0ubuntu0.16.04.1_amd64.deb
/var/cache/apt/archives/libavcodec-ffmpeg56_7%3a2.8.15-0ubuntu0.16.04.1_amd64.deb
/var/cache/apt/archives/libavcodec-dev_7%3a2.8.14-0ubuntu0.16.04.1_amd64.deb
/usr/lib/vlc/plugins/codec/libavcodec_plugin.so
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56
/usr/lib/x86_64-linux-gnu/libavcodec.so
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56.60.100
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.a
/usr/lib/x86_64-linux-gnu/libavcodec.a
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so
/usr/lib/x86_64-linux-gnu/pkgconfig/libavcodec-ffmpeg.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libavcodec.pc
/usr/share/doc/libavcodec-ffmpeg56
/usr/share/doc/libavcodec-dev
/usr/share/lintian/overrides/libavcodec-ffmpeg56
/usr/include/x86_64-linux-gnu/libavcodec

推荐答案

事实证明,虽然MP3支持作为音频,但视频不支持MP3,至少Linux不支持.

Turns out that while MP3 is supported as audio, it is not supported for video, at least not out of the box for Linux.

可以通过MP4和AAC进行音轨.至少对于Linux Mint 18.3上的Java 11,OpenJFX 11来说确实如此.

What works through is MP4 together with AAC for the audio track. At least this is true for Java 11, OpenJFX 11 on Linux Mint 18.3.

这篇关于JavaFX媒体播放器无法播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆