mplayer-wrapper (python)

Bash太让人崩溃了,用python重写了一遍mplayer-wrapper。

下载

https://github.com/sunbing81/scripts/blob/master/mplayer.py

功能

  • 视频填充:扩展/填充视频,使得字幕和OSD显示在屏幕上下的黑边上(查看截图
  • 字体自适应:保证不同分辨率的视频在同一屏幕上的字体大小保持不变,并将字幕放在合适的位置上
  • 字幕自动下载:根据文件hash向射手网(http://www.shooter.com.cn)查询并下载字幕,好处是不依赖文件名、不依赖javascript解释器,坏处是射手网由于负载原因而不提供中文以外的字幕;想要英文字幕的就只好手动下载了;
  • 待实现:连续播放、记录视频播放位置和音量设置

依赖

  • xrandr:屏幕分辨率检测

使用

  • 比命令行的mplayer多两个参数:-debug和-dry-run,其他参数会转发给命令行的mplayer
发表评论?

68 条评论。

  1. 怎么使用呢?用什么命令?我的是centos5.x 用如下命令
    python mplayer.py
    出现的是这个:
    File “mplayer.py”, line 29
    return fullpath if os.access(fullpath, os.X_OK) else None
    ^
    SyntaxError: invalid syntax
    [root@chow Desktop]# python mplayer.py -debug
    File “mplayer.py”, line 29
    return fullpath if os.access(fullpath, os.X_OK) else None
    ^
    SyntaxError: invalid syntax
    不知道我用的命令对不对?望帮助,谢谢。

    • python的版本问题吧

      运行下python –version看看版本

      • [root@chow ~]# python
        Python 2.4.3 (#1, Sep 21 2011, 20:06:00)
        [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
        Type “help”, “copyright”, “credits” or “license” for more information.
        >>>

        应该什么版本才可以?

        • python >2.6 <3.0

          centos的python升级容易出问题,因为yum是用python写的

          • 谢谢 我试试

          • [root@chow Desktop]# python2.7 mplayer.py
            Traceback (most recent call last):
            File “mplayer.py”, line 598, in
            run()
            File “mplayer.py”, line 572, in run
            screen_dim = check_dimension()
            File “mplayer.py”, line 49, in check_dimension
            if d[0] > dim[0]: dim = map(int,d)
            ValueError: invalid literal for int() with base 10: ‘*0′

            仍然有问题,麻烦你了

          • 运行xrandr看看输出是啥

            另外在上面的链接重新下一次吧,更新过了。

            谢谢你的反馈。

          • SZ: Pixels Physical Refresh
            *0 1280 x 800 ( 301mm x 191mm ) *50
            1 1152 x 768 ( 270mm x 184mm ) 51
            2 1024 x 768 ( 240mm x 184mm ) 52 53
            3 832 x 624 ( 195mm x 149mm ) 54
            4 800 x 600 ( 188mm x 143mm ) 55 56 57 58 59
            5 800 x 512 ( 188mm x 122mm ) 60
            6 720 x 450 ( 169mm x 107mm ) 61
            7 720 x 400 ( 169mm x 95mm ) 62
            8 700 x 525 ( 164mm x 125mm ) 63
            9 640 x 512 ( 150mm x 122mm ) 64 65
            10 640 x 480 ( 150mm x 115mm ) 66 67 68 69 70
            11 640 x 400 ( 150mm x 95mm ) 71 72 73 74 75
            12 640 x 384 ( 150mm x 92mm ) 76 77 78 79
            13 640 x 360 ( 150mm x 86mm ) 80 81 82 83
            14 640 x 350 ( 150mm x 83mm ) 84
            15 576 x 432 ( 135mm x 103mm ) 85 86 87 88 89 90
            16 576 x 384 ( 135mm x 92mm ) 91
            17 512 x 384 ( 120mm x 92mm ) 92 93 94 95 96
            18 416 x 312 ( 97mm x 74mm ) 97
            19 400 x 300 ( 94mm x 71mm ) 98 99 100 101 102
            20 360 x 200 ( 84mm x 47mm ) 103
            21 320 x 240 ( 75mm x 57mm ) 104 105 106 107
            22 320 x 200 ( 75mm x 47mm ) 108
            23 320 x 175 ( 75mm x 41mm ) 109
            Current rotation – normal
            Current reflection – none
            Rotations possible – normal
            Reflections possible – none
            ------------------------------
            以上是运行xrandr后的结果

          • 更新文件后,仍然出现3月1号反馈的问题

        • 嗯,更新是因为之前暂时禁用了字幕下载,现在又启用了

          xrandr又是版本问题,不过可以直接处理,把
          xrandr -q
          xrandr -v
          贴一下

  2. [root@chow Desktop]# xrandr -q
    SZ: Pixels Physical Refresh
    *0 1280 x 800 ( 301mm x 191mm ) *50
    1 1152 x 768 ( 270mm x 184mm ) 51
    2 1024 x 768 ( 240mm x 184mm ) 52 53
    3 832 x 624 ( 195mm x 149mm ) 54
    4 800 x 600 ( 188mm x 143mm ) 55 56 57 58 59
    5 800 x 512 ( 188mm x 122mm ) 60
    6 720 x 450 ( 169mm x 107mm ) 61
    7 720 x 400 ( 169mm x 95mm ) 62
    8 700 x 525 ( 164mm x 125mm ) 63
    9 640 x 512 ( 150mm x 122mm ) 64 65
    10 640 x 480 ( 150mm x 115mm ) 66 67 68 69 70
    11 640 x 400 ( 150mm x 95mm ) 71 72 73 74 75
    12 640 x 384 ( 150mm x 92mm ) 76 77 78 79
    13 640 x 360 ( 150mm x 86mm ) 80 81 82 83
    14 640 x 350 ( 150mm x 83mm ) 84
    15 576 x 432 ( 135mm x 103mm ) 85 86 87 88 89 90
    16 576 x 384 ( 135mm x 92mm ) 91
    17 512 x 384 ( 120mm x 92mm ) 92 93 94 95 96
    18 416 x 312 ( 97mm x 74mm ) 97
    19 400 x 300 ( 94mm x 71mm ) 98 99 100 101 102
    20 360 x 200 ( 84mm x 47mm ) 103
    21 320 x 240 ( 75mm x 57mm ) 104 105 106 107
    22 320 x 200 ( 75mm x 47mm ) 108
    23 320 x 175 ( 75mm x 41mm ) 109
    Current rotation – normal
    Current reflection – none
    Rotations possible – normal
    Reflections possible – none
    [root@chow Desktop]#

    ———————————————
    [root@chow Desktop]# xrandr -v
    Server reports RandR version 1.1

    —————————————–
    最近挺忙的,现在才上网

    • 已修改,不过我这里没有xrandr1.1,希望没问题 :evil:

      • 具体怎么用这个脚本呢?带什么参数?

        • python2.7 mplayer.py MyMovie.mkv

          • Traceback (most recent call last):
            File “mplayer.py”, line 656, in
            run()
            File “mplayer.py”, line 617, in run
            screen_dim = check_dimension()
            File “mplayer.py”, line 56, in check_dimension
            if d[0] > dim[0]: dim = map(int,d)
            ValueError: invalid literal for int() with base 10: ‘*0′
            -------------------
            不好意思阿 ,还是出现问题

        • 下载最新的了么?看上去还是之前那个xrandr的问题啊

          • ——
            File “mplayer.py”, line 4

            ^
            SyntaxError: invalid syntax
            -------------
            更新了出现这个提示

          • File “mplayer.py”, line 4
            ==========================

            第四行是注释,不可能SyntaxError的啊

            文件没问题吧。。。

          • 我才发现我我的文字多了几个空白行,删除后就可以播放了,但是似乎没有字幕,以下是允许信息:
            Creating config file: /root/.mplayer/config
            MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team
            mplayer: could not connect to socket
            mplayer: No such file or directory
            Failed to open LIRC support. You will not be able to use your remote control.

            Playing mplayer.py.
            Seek failed

          • 上面的回复是在我用错命令的前提下回的,还是那个问题,确实提示第四行出问题,我重新下那个文件还是提示第四行出问题

          • 很诡异啊……

            那看看
            head mplayer.py
            啥输出呢?

          • 实在实在不好意思,是我下错文件了,下了对的,但是似乎没有字幕可以下载阿,难道是我的电影太新了?而且明显不如直接用mplayer播放好,用那个文件播放电影会自动关闭视频的,而且按快进也会关闭视频

  3. [root@chow Desktop]# python mplayer.py /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    [matroska @ 0xafe5be0] Estimating duration from bitrate, this may be inaccurate
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    Playing /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv.
    libavformat file format detected.
    Couldn’t open video filter ‘ass’.
    ASS: cannot add video filter
    [ass] Fontconfig disabled, only default font will be used.
    [lavf] stream 0: video (h264), -vid 0
    [lavf] stream 1: audio (dca), -aid 0, -alang fre
    [lavf] stream 2: subtitle (unknown), -sid 0, -slang eng
    VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    No such audio driver ‘pulse’
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Starting playback…
    Movie-Aspect is 2.39:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×536 => 1280×536 Planar YV12
    [ass] PlayResX undefined, setting to 384 0/ 0 30% 9% 3.1% 30 0
    [ass] Error opening font: ‘/root/.mplayer/subfont.ttf’, 0 3.1% 30 0

    MPlayer interrupted by signal 11 in module: filter 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.
    ----------------------
    这是我的播放信息

    • mplayer.py /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv -dry-run
      看看是啥输出

      然后mplayer.py /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv -noass
      跑一下看是不是还退出

  4. [root@chow Desktop]# python mplayer.py /mnt/Movie/ZJTV.Bei.Jing.Love.Story.Complete.HDTV.720p.x264-CHDTV/ZJTV.Bei.Jing.Love.Story.Complete.HDTV.720p.x264-CHDTV/ZJTV.Bei.Jing.Love.Story.Ep37.HDTV.720p.x264-CHDTV.mkv
    INFO: Connecting to shooter server…
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    [matroska @ 0xa3d1090] Estimating duration from bitrate, this may be inaccurate
    Playing /mnt/Movie/ZJTV.Bei.Jing.Love.Story.Complete.HDTV.720p.x264-CHDTV/ZJTV.Bei.Jing.Love.Story.Complete.HDTV.720p.x264-CHDTV/ZJTV.Bei.Jing.Love.Story.Ep37.HDTV.720p.x264-CHDTV.mkv.
    Cache fill: 7.91% (663552 bytes)
    Couldn’t open video filter ‘ass’.
    ASS: cannot add video filter
    libavformat file format detected.
    [ass] Fontconfig disabled, only default font will be used.
    [lavf] stream 0: video (h264), -vid 0
    [lavf] stream 1: audio (ac3), -aid 0
    VIDEO: [H264] 1280×720 0bpp 25.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Opening video filter: [pp=ac]
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    No such audio driver ‘pulse’
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000)
    Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Process Process-1:
    Traceback (most recent call last):
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 232, in _bootstrap
    self.run()
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 88, in run
    self._target(*self._args, **self._kwargs)
    File “mplayer.py”, line 322, in handle_shooter_subtitles
    subs = fetch_sub(build_req(media))
    File “mplayer.py”, line 301, in fetch_sub
    response = urllib2.urlopen(req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 126, in urlopen
    return _opener.open(url, data, timeout)
    File “/usr/local/lib/python2.6/urllib2.py”, line 397, in open
    response = meth(req, response)
    File “/usr/local/lib/python2.6/urllib2.py”, line 510, in http_response
    ‘http’, request, response, code, msg, hdrs)
    File “/usr/local/lib/python2.6/urllib2.py”, line 435, in error
    return self._call_chain(*args)
    File “/usr/local/lib/python2.6/urllib2.py”, line 369, in _call_chain
    result = func(*args)
    File “/usr/local/lib/python2.6/urllib2.py”, line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    HTTPError: HTTP Error 404: Not Found
    [vdpau] Error when calling vdp_presentation_queue_block_until_surface_idle: A catch-all error, used when no other error code applies.

    • 这是因为射手的有些服务器有时候会挂,但我还没把自动重试的功能加进去。

  5. 分别是:
    DEBUG: /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    Fullpath: /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    Seekable: True
    Video: True
    Dimension(pixel): 1280×536
    Dimension(display): 1280×536
    Aspect(display): 2.3881
    Subtitles: embedded text

    DEBUG: Final command:
    /usr/bin/mplayer -input file=/tmp/tmpSHmLGz/mplayer_fifo -subfont-autoscale 2 -ass -ass-font-scale 2 -ass-use-margins -ass-bottom-margin 83 -ass-top-margin 83 -ass-force-style ScaleX=0.763519879135 /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    ———————————–
    Traceback (most recent call last):
    File “./mplayer.py”, line 666, in
    run()
    File “./mplayer.py”, line 617, in run
    parser = CmdLineParser(sys.argv,mplayer)
    File “./mplayer.py”, line 581, in __init__
    flag = mplayer.support(s.split(‘-’,1)[1])
    File “./mplayer.py”, line 360, in support
    if not self.__opts: self.__gen_opts()
    File “./mplayer.py”, line 443, in __gen_opts
    options = Popen([self.__path, "-list-options"], stdout=PIPE).communicate()[0].splitlines()
    NameError: global name ‘Popen’ is not defined

    • oops,改了,现在再试试-debug那个吧

      现在是不自动退出,但还下不了字幕是吗?

      • 还是会自动退出,信息如下
        [root@chow Desktop]# python mplayer.py /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
        mplayer: could not connect to socket
        mplayer: No such file or directory
        Failed to open LIRC support. You will not be able to use your remote control.
        [matroska @ 0x9c34c60] Estimating duration from bitrate, this may be inaccurate
        MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

        Playing /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv.
        libavformat file format detected.
        Couldn’t open video filter ‘ass’.
        ASS: cannot add video filter
        [ass] Fontconfig disabled, only default font will be used.
        [lavf] stream 0: video (h264), -vid 0
        [lavf] stream 1: audio (dca), -aid 0, -alang eng
        VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
        SUB: Added subtitle file (1): /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.srt
        ==========================================================================
        Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
        Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
        ==========================================================================
        ==========================================================================
        No such audio driver ‘pulse’
        Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
        AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
        Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
        ==========================================================================
        [ass] PlayResX undefined, setting to 384
        AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
        Starting playback…
        Movie-Aspect is 2.39:1 – prescaling to correct movie aspect.
        VO: [vdpau] 1280×536 => 1280×536 Planar YV12
        [ass] Error opening font: ‘/root/.mplayer/subfont.ttf’, 0 2.3% 31 0

        MPlayer interrupted by signal 11 in module: filter 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.
        [root@chow Desktop]# : 0.001 ct: 0.000 0/ 0 32% 23% 2.3% 31 0

      • 这个才是加了 -debug的
        [root@chow Desktop]# python mplayer.py /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv -debug
        DEBUG: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
        Fullpath: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
        Seekable: True
        Video: True
        Dimension(pixel): 1280×536
        Dimension(display): 1280×536
        Aspect(display): 2.38805970149
        Subtitles: external text

        DEBUG: Final command:
        /usr/bin/mplayer -input file=/tmp/tmplktdkk/mplayer_fifo -subfont-autoscale 2 -ass -ass-font-scale 2 -ass-use-margins -ass-bottom-margin 83 -ass-top-margin 83 -ass-force-style ScaleX=0.763532763533 /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
        mplayer: could not connect to socket
        mplayer: No such file or directory
        Failed to open LIRC support. You will not be able to use your remote control.
        [matroska @ 0x90f6c60] Estimating duration from bitrate, this may be inaccurate
        MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

        Playing /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv.
        libavformat file format detected.
        Couldn’t open video filter ‘ass’.
        ASS: cannot add video filter
        [ass] Fontconfig disabled, only default font will be used.
        [lavf] stream 0: video (h264), -vid 0
        [lavf] stream 1: audio (dca), -aid 0, -alang eng
        VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
        SUB: Added subtitle file (1): /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.srt
        ==========================================================================
        Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
        No such audio driver ‘pulse’
        Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
        ==========================================================================
        ==========================================================================
        Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
        AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
        Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
        ==========================================================================
        [ass] PlayResX undefined, setting to 384
        AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
        Starting playback…
        Movie-Aspect is 2.39:1 – prescaling to correct movie aspect.
        VO: [vdpau] 1280×536 => 1280×536 Planar YV12
        [ass] Error opening font: ‘/root/.mplayer/subfont.ttf’, 0 2.4% 4 0

        MPlayer interrupted by signal 11 in module: filter 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.
        DEBUG: Last timestamp: 17.701 ct: 0.000 0/ 0 34% 15% 2.4% 4 0
        DEBUG: Last exit status: None

    • 哦你的电影已经内嵌字幕了,现在还判断不了字幕是否中文,所以脚本在这种情况下就不会开始自动下载。

  6. 这是我看的一个没有字幕的片,中文的,但是没有下字幕
    信息如下:
    [root@chow Desktop]# python mplayer.py /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv -debug
    DEBUG: /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    Fullpath: /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    Seekable: True
    Video: True
    Dimension(pixel): 1280×544
    Dimension(display): 1280×544
    Aspect(display): 2.35294117647
    Subtitles: none

    DEBUG: Final command:
    /usr/bin/mplayer -input file=/tmp/tmpOOw3PP/mplayer_fifo -subfont-autoscale 2 -ass -ass-font-scale 2 -ass-use-margins -ass-bottom-margin 85 -ass-top-margin 85 -ass-force-style ScaleX=0.761904761905 /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    INFO: Connecting to shooter server…
    DEBUG: Querying server https://splayer5.shooter.cn/api/subapi.php with
    [['User-Agent', 'SPlayer Build $1355'], ['Content-Type', 'multipart/form-data; boundary=----------------------------c8808bc12b83']]
    ——————————c8808bc12b83
    Content-Disposition: form-data; name=”pathinfo”

    c:/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    ——————————c8808bc12b83
    Content-Disposition: form-data; name=”filehash”

    692cbdcaee5dba6bead98e06b21b9d7e;3efbf10b7052202811703f50bcb80594;ca1402bba3253e5202228f9f336b59f3;d47a43092b9ee74438fa0078f5a91e6c
    ——————————c8808bc12b83–

    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    [matroska @ 0x9ad3eb0] Estimating duration from bitrate, this may be inaccurate
    Playing /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv.
    Cache fill: 0.00% (0 bytes)
    libavformat file format detected.
    Process Process-1:
    Traceback (most recent call last):
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 232, in _bootstrap
    self.run()
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 88, in run
    self._target(*self._args, **self._kwargs)
    File “mplayer.py”, line 322, in handle_shooter_subtitles
    subs = fetch_sub(build_req(media))
    File “mplayer.py”, line 301, in fetch_sub
    response = urllib2.urlopen(req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 126, in urlopen
    return _opener.open(url, data, timeout)
    File “/usr/local/lib/python2.6/urllib2.py”, line 391, in open
    response = self._open(req, data)
    File “/usr/local/lib/python2.6/urllib2.py”, line 414, in _open
    ‘unknown_open’, req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 369, in _call_chain
    result = func(*args)
    File “/usr/local/lib/python2.6/urllib2.py”, line 1194, in unknown_open
    raise URLError(‘unknown url type: %s’ % type)
    URLError:
    Couldn’t open video filter ‘ass’.
    ASS: cannot add video filter
    [ass] Fontconfig disabled, only default font will be used.
    No such audio driver ‘pulse’
    [lavf] stream 0: video (h264), -vid 0, TSField @ OnlyHD
    [lavf] stream 1: audio (dca), -aid 0, -alang chi, DTS 5.1 @ 1509 kbps Cantonese
    [lavf] stream 2: audio (ac3), -aid 1, -alang chi, DDPlug to DD 5.1 @ 448 kbps Mandarin
    VIDEO: [H264] 1280×544 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Opening video filter: [pp=ac]
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Cache not filling!
    Cache not filling!
    Starting playback…
    [PP] Using external postprocessing filter, max q = 6.
    Movie-Aspect is 2.35:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×544 => 1280×544 Planar YV12 [fs]

    Exiting… (Quit)
    DEBUG: Last timestamp: 0.0
    DEBUG: Last exit status: Quit

  7. [root@chow Desktop]# python mplayer.py /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv
    INFO: Connecting to shooter server…
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    [matroska @ 0xa3cbe90] Estimating duration from bitrate, this may be inaccurate
    Playing /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv.
    Cache fill: 1.66% (139264 bytes)
    Couldn’t open video filter ‘ass’.
    ASS: cannot add video filter
    libavformat file format detected.
    [ass] Fontconfig disabled, only default font will be used.
    No such audio driver ‘pulse’
    [lavf] stream 0: video (h264), -vid 0
    [lavf] stream 1: audio (dca), -aid 0
    VIDEO: [H264] 1280×544 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Opening video filter: [pp=ac]
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Process Process-1:
    Traceback (most recent call last):
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 232, in _bootstrap
    self.run()
    File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 88, in run
    self._target(*self._args, **self._kwargs)
    File “mplayer.py”, line 322, in handle_shooter_subtitles
    subs = fetch_sub(build_req(media))
    File “mplayer.py”, line 301, in fetch_sub
    response = urllib2.urlopen(req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 126, in urlopen
    return _opener.open(url, data, timeout)
    File “/usr/local/lib/python2.6/urllib2.py”, line 391, in open
    response = self._open(req, data)
    File “/usr/local/lib/python2.6/urllib2.py”, line 409, in _open
    ‘_open’, req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 369, in _call_chain
    result = func(*args)
    File “/usr/local/lib/python2.6/urllib2.py”, line 1161, in http_open
    return self.do_open(httplib.HTTPConnection, req)
    File “/usr/local/lib/python2.6/urllib2.py”, line 1136, in do_open
    raise URLError(err)
    URLError:
    Starting playback…
    [PP] Using external postprocessing filter, max q = 6.
    Movie-Aspect is 2.35:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×544 => 1280×544 Planar YV12 [fs]

    Exiting… (Quit)
    [root@chow Desktop]# python mplayer.py /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv -debug
    DEBUG: /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv
    Fullpath: /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv
    Seekable: True
    Video: True
    Dimension(pixel): 1280×544
    Dimension(display): 1280×544
    Aspect(display): 2.35294117647
    Subtitles: none

    INFO: Connecting to shooter server…
    DEBUG: Final command:
    /usr/bin/mplayer -input file=/tmp/tmpXnMaGt/mplayer_fifo -subfont-autoscale 2 -ass -ass-font-scale 2 -ass-use-margins -ass-bottom-margin 85 -ass-top-margin 85 -ass-force-style ScaleX=0.761904761905 /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv
    DEBUG: Querying server http://splayer3.shooter.cn/api/subapi.php with
    [['User-Agent', 'SPlayer Build $1230'], ['Content-Type', 'multipart/form-data; boundary=----------------------------d772244b07b0']]
    ——————————d772244b07b0
    Content-Disposition: form-data; name=”pathinfo”

    c:/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv
    ——————————d772244b07b0
    Content-Disposition: form-data; name=”filehash”

    1f32ab15425724fab328695e98192ef0;58e0124e071fc90aa6a6d760f9870eee;e3d1df334590bf18303684e7b18825c0;755c31b70ea6072f19c3d85241c439bd
    ——————————d772244b07b0–

    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    [matroska @ 0xa232e90] Estimating duration from bitrate, this may be inaccurate
    Playing /mnt/Movie/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina/The.Viral.Factor.2012.720p.BluRay.x264.DTS-HDChina.mkv.
    Cache fill: 13.77% (1155072 bytes)
    Cache not responding!
    Couldn’t open video filter ‘ass’.
    ASS: cannot add video filter
    [ass] Fontconfig disabled, only default font will be used.
    libavformat file format detected.
    [lavf] stream 0: video (h264), -vid 0
    [lavf] stream 1: audio (dca), -aid 0
    VIDEO: [H264] 1280×544 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Opening video filter: [pp=ac]
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    No such audio driver ‘pulse’
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Starting playback…
    [PP] Using external postprocessing filter, max q = 6.
    Movie-Aspect is 2.35:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×544 => 1280×544 Planar YV12 [fs]

    Exiting… (Quit)
    DEBUG: Last timestamp: 0.0
    DEBUG: Last exit status: Quit
    INFO: Terminating subtitle fetching…

  8. 第一,你的python不支持ssl,所以连不上https开头的服务器;已经在最新的版本中加入了对ssl可用性的检查

    第二,退出的问题可能跟fontconfig有关,用mplayer.py a.mkv -debug -noass试试吧

    第三,有内嵌的文本字幕时,脚本不会自动尝试下载字幕,但这不影响播放过程,所以正常不会自动退出

    ps,都是高清电影啊,羡慕你的网络……

    • 我试试,我其实是个学生,在学校里用六维下的

    • 仍然是自动退出
      [root@chow Desktop]# python mplayer.py /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv -debug -noass
      DEBUG: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
      Fullpath: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
      Seekable: True
      Video: True
      Dimension(pixel): 1280×536
      Dimension(display): 1280×536
      Aspect(display): 2.38805970149
      Subtitles: external text

      DEBUG: Final command:
      /usr/bin/mplayer -input file=/tmp/tmpvIL74t/mplayer_fifo -noass -subfont-autoscale 2 -ass -ass-font-scale 2 -ass-use-margins -ass-bottom-margin 83 -ass-top-margin 83 -ass-force-style ScaleX=0.763532763533 /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
      mplayer: could not connect to socket
      mplayer: No such file or directory
      Failed to open LIRC support. You will not be able to use your remote control.
      MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

      [matroska @ 0xa0afec0] Estimating duration from bitrate, this may be inaccurate
      Playing /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv.
      Cache fill: 10.74% (901120 bytes)
      libavformat file format detected.
      Cache not responding!
      Couldn’t open video filter ‘ass’.
      ASS: cannot add video filter
      [ass] Fontconfig disabled, only default font will be used.
      No such audio driver ‘pulse’
      [lavf] stream 0: video (h264), -vid 0
      [lavf] stream 1: audio (dca), -aid 0, -alang eng
      VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
      SUB: Added subtitle file (1): /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.srt
      Opening video filter: [pp=ac]
      ==========================================================================
      Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
      Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
      ==========================================================================
      ==========================================================================
      Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
      AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
      Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
      ==========================================================================
      AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
      [ass] PlayResX undefined, setting to 384
      [ass] Error opening font: ‘/root/.mplayer/subfont.ttf’, 0

      MPlayer interrupted by signal 11 in module: filter 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.

      MPlayer interrupted by signal 2 in module: enable_cache
      Process Process-1:
      Traceback (most recent call last):
      File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 232, in _bootstrap
      self.run()
      File “/usr/local/lib/python2.6/multiprocessing/process.py”, line 88, in run
      self._target(*self._args, **self._kwargs)
      File “mplayer.py”, line 376, in cmd
      Traceback (most recent call last):
      File “mplayer.py”, line 666, in
      time.sleep(1)
      KeyboardInterrupt
      run()
      File “mplayer.py”, line 651, in run
      mplayer.play(args+[f], cmd_conn_read_end)
      File “mplayer.py”, line 424, in play
      tee(self.__process)
      File “mplayer.py”, line 388, in tee
      c = p.stdout.read(1)
      KeyboardInterrupt

      • 我又乌龙了……

        现在再试试mplayer a.mkv -noass -debug吧

        多谢~

        • 果然带这两个参数就不自动退出了,同时我发现有字幕了,但是是乱码。不带参数还是会自动退出。
          信息如下
          -----------
          [root@chow Desktop]# python mplayer.py /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv -noass -debug
          DEBUG: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
          Fullpath: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
          Seekable: True
          Video: True
          Dimension(pixel): 1280×536
          Dimension(display): 1280×536
          Aspect(display): 2.38805970149
          Subtitles: external text

          DEBUG: Final command:
          /usr/bin/mplayer -input file=/tmp/tmpNU68wE/mplayer_fifo -noass -subfont-autoscale 2 -subpos 98 -vf-pre expand=1280::::1:8/5 /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
          mplayer: could not connect to socket
          mplayer: No such file or directory
          Failed to open LIRC support. You will not be able to use your remote control.
          MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

          [matroska @ 0xa1c4010] Estimating duration from bitrate, this may be inaccurate
          Playing /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv.
          Cache fill: 0.00% (0 bytes)
          libavformat file format detected.
          Cache not responding!
          [lavf] stream 0: video (h264), -vid 0
          [lavf] stream 1: audio (dca), -aid 0, -alang eng
          VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
          SUB: Added subtitle file (1): /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.srt
          Opening video filter: [pp=ac]
          Opening video filter: [expand w=1280 osd=1 aspect=8/5]
          Expand: 1280 x -1, -1 ; -1, osd: 1, aspect: 1.600000, round: 1
          ==========================================================================
          No such audio driver ‘pulse’
          Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
          Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
          ==========================================================================
          ==========================================================================
          Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
          AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
          Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
          ==========================================================================
          AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
          Starting playback…
          [PP] Using external postprocessing filter, max q = 6.
          Movie-Aspect is 2.39:1 – prescaling to correct movie aspect.
          VO: [vdpau] 1280×800 => 1280×800 Planar YV12 [fs]

          Exiting… (Quit)
          DEBUG: Last timestamp: 0.0
          DEBUG: Last exit status: Quit
          -------------
          喜欢在linux下用shell做一些自动化的东西,所以就用这个系统

          • ldd ‘which mplayer’看下结果,退出是因为libass不支持fontconfig

  9. 我给我的python添加ssl了,这是没有字幕的信息
    [root@chow Desktop]# python mplayer.py /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv -noass -debug
    DEBUG: /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    Fullpath: /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    Seekable: True
    Video: True
    Dimension(pixel): 1280×544
    Dimension(display): 1280×544
    Aspect(display): 2.35294117647
    Subtitles: none

    DEBUG: Final command:
    /usr/bin/mplayer -input file=/tmp/tmpNixtXC/mplayer_fifo -noass -subfont-autoscale 2 -subpos 98 -vf-pre expand=1280::::1:8/5 /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    INFO: Connecting to shooter server…
    DEBUG: Querying server http://splayer.shooter.cn/api/subapi.php with
    [['User-Agent', 'SPlayer Build $1317'], ['Content-Type', 'multipart/form-data; boundary=----------------------------c331e9280a22']]
    ——————————c331e9280a22
    Content-Disposition: form-data; name=”pathinfo”

    c:/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv
    ——————————c331e9280a22
    Content-Disposition: form-data; name=”filehash”

    692cbdcaee5dba6bead98e06b21b9d7e;3efbf10b7052202811703f50bcb80594;ca1402bba3253e5202228f9f336b59f3;d47a43092b9ee74438fa0078f5a91e6c
    ——————————c331e9280a22–

    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    [matroska @ 0x9c4d030] Estimating duration from bitrate, this may be inaccurate
    Playing /mnt/Movie/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD/The.Great.Magician.2012.BluRay.720p.DTS.2Audio.x264-OnlyHD.mkv.
    Cache fill: 0.00% (0 bytes)
    libavformat file format detected.
    Cache not responding!
    [lavf] stream 0: video (h264), -vid 0, TSField @ OnlyHD
    [lavf] stream 1: audio (dca), -aid 0, -alang chi, DTS 5.1 @ 1509 kbps Cantonese
    [lavf] stream 2: audio (ac3), -aid 1, -alang chi, DDPlug to DD 5.1 @ 448 kbps Mandarin
    VIDEO: [H264] 1280×544 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Opening video filter: [pp=ac]
    Opening video filter: [expand w=1280 osd=1 aspect=8/5]
    Expand: 1280 x -1, -1 ; -1, osd: 1, aspect: 1.600000, round: 1
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    No such audio driver ‘pulse’
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    INFO: 1 subtitle packages found
    INFO: Length of current package in bytes: 178722
    INFO: 1 subtitles in current package (no description)
    WARNING: Unknown format or incomplete data. Trying again…
    INFO: 0 subtitle(s) fetched.
    Starting playback…
    [PP] Using external postprocessing filter, max q = 6.
    Movie-Aspect is 2.35:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×800 => 1280×800 Planar YV12 [fs]

    Exiting… (Quit)
    DEBUG: Last timestamp: 0.0
    DEBUG: Last exit status: Quit
    [root@chow Desktop]#

  10. 这是出字幕(乱码)的信息
    --------------
    [root@chow Desktop]# python mplayer.py /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv -noass -debug
    DEBUG: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
    Fullpath: /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
    Seekable: True
    Video: True
    Dimension(pixel): 1280×536
    Dimension(display): 1280×536
    Aspect(display): 2.38805970149
    Subtitles: external text

    DEBUG: Final command:
    /usr/bin/mplayer -input file=/tmp/tmph1V8Kk/mplayer_fifo -noass -subfont-autoscale 2 -subpos 98 -vf-pre expand=1280::::1:8/5 /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    [matroska @ 0xaa14e10] Estimating duration from bitrate, this may be inaccurate
    MPlayer SVN-r31628-4.1.2 (C) 2000-2010 MPlayer Team

    Playing /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.mkv.
    libavformat file format detected.
    [lavf] stream 0: video (h264), -vid 0
    [lavf] stream 1: audio (dca), -aid 0, -alang eng
    VIDEO: [H264] 1280×536 0bpp 24.000 fps 0.0 kbps ( 0.0 kbyte/s)
    SUB: Added subtitle file (1): /mnt/Movie/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina/Friends.with.Benefits.2011.BluRay.720p.x264.DTS-HDChina.srt
    Opening video filter: [expand w=1280 osd=1 aspect=8/5]
    Expand: 1280 x -1, -1 ; -1, osd: 1, aspect: 1.600000, round: 1
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    No such audio driver ‘pulse’
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
    Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
    ==========================================================================
    AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
    Starting playback…
    Movie-Aspect is 2.39:1 – prescaling to correct movie aspect.
    VO: [vdpau] 1280×800 => 1280×800 Planar YV12
    A: 73.2 V: 73.2 A-V: 0.073 ct: 0.001 0/ 0 ??% ??% ??,?% 0 0
    Subtitle word ‘�’ too long!
    A: 159.0 V: 158.9 A-V: 0.061 ct: 0.007 0/ 0 ??% ??% ??,?% 0 0
    Subtitle word ‘�’ too long!
    A: 389.9 V: 389.8 A-V: 0.051 ct: 0.011 0/ 0 46% 54% 12.6% 1 0
    Exiting… (Quit)
    DEBUG: Last timestamp: 389.9
    DEBUG: Last exit status: Quit

    • 嗯,centos面向服务器的,所以软件比较保守;平时用倒是可以面向桌面的发行版,多媒体支持方面会好很多。

  11. 乱码的问题有两个方法,一是在命令行里添加选项-subcp gbk;二是安装enca

  12. 编码的问题有空我还会再想想怎么搞定比较好。

  13. [root@chow Desktop]# ldd `which mplayer`
    linux-gate.so.1 => (0×00725000)
    libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x0059d000)
    libfribidi.so.0 => /usr/lib/libfribidi.so.0 (0×06712000)
    libsmbclient.so.0 => /usr/lib/libsmbclient.so.0 (0x06ab1000)
    libpng12.so.0 => /usr/lib/libpng12.so.0 (0x008d4000)
    libz.so.1 => /usr/lib/libz.so.1 (0×00546000)
    libmng.so.1 => /usr/lib/libmng.so.1 (0×03481000)
    libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x009ef000)
    libungif.so.4 => /usr/lib/libungif.so.4 (0x00dfc000)
    libasound.so.2 => /lib/libasound.so.2 (0x03e9c000)
    libdl.so.2 => /lib/libdl.so.2 (0×00523000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x0052a000)
    libcdda_interface.so.0 => /usr/lib/libcdda_interface.so.0 (0x00dd6000)
    libcdda_paranoia.so.0 => /usr/lib/libcdda_paranoia.so.0 (0×06929000)
    libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0×00852000)
    libass.so.4 => /usr/lib/libass.so.4 (0×06273000)
    libenca.so.0 => /usr/lib/libenca.so.0 (0×06441000)
    libbz2.so.1 => /usr/lib/libbz2.so.1 (0x03fd6000)
    liblzo2.so.2 => /usr/lib/liblzo2.so.2 (0x064a1000)
    libmad.so.0 => /usr/lib/libmad.so.0 (0x0624e000)
    libspeex.so.1 => /usr/lib/libspeex.so.1 (0×06236000)
    libtheora.so.0 => /usr/lib/libtheora.so.0 (0x0672b000)
    libogg.so.0 => /usr/lib/libogg.so.0 (0x004d0000)
    libmpg123.so.0 => /usr/lib/libmpg123.so.0 (0x063e0000)
    liba52.so.0 => /usr/lib/liba52.so.0 (0x00a1b000)
    libdca.so.0 => /usr/lib/libdca.so.0 (0×06767000)
    libmpcdec.so.5 => /usr/lib/libmpcdec.so.5 (0x06dfb000)
    libliveMedia.so.0 => /usr/lib/libliveMedia.so.0 (0×06515000)
    libgroupsock.so.0 => /usr/lib/libgroupsock.so.0 (0x0678e000)
    libUsageEnvironment.so.0 => /usr/lib/libUsageEnvironment.so.0 (0x00a28000)
    libBasicUsageEnvironment.so.0 => /usr/lib/libBasicUsageEnvironment.so.0 (0x068d3000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00a48000)
    libopencore-amrnb.so.0 => /usr/lib/libopencore-amrnb.so.0 (0x068f8000)
    libopencore-amrwb.so.0 => /usr/lib/libopencore-amrwb.so.0 (0x068e0000)
    libdv.so.4 => /usr/lib/libdv.so.4 (0x065fc000)
    libxvidcore.so.4 => /usr/lib/libxvidcore.so.4 (0x067e4000)
    libm.so.6 => /lib/libm.so.6 (0x004f8000)
    libdirac_encoder.so.0 => /usr/lib/libdirac_encoder.so.0 (0×06131000)
    libdirac_decoder.so.0 => /usr/lib/libdirac_decoder.so.0 (0x061c7000)
    libXext.so.6 => /usr/lib/libXext.so.6 (0×00568000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0x0074d000)
    libXss.so.1 => /usr/lib/libXss.so.1 (0×04120000)
    libXv.so.1 => /usr/lib/libXv.so.1 (0x064d2000)
    libXvMC.so.1 => /usr/lib/libXvMC.so.1 (0x064cc000)
    libXvMCW.so.1 => /usr/lib/libXvMCW.so.1 (0x00dec000)
    libvdpau.so.1 => /usr/lib/libvdpau.so.1 (0x00df3000)
    libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x005d9000)
    libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0x004c9000)
    libXxf86dga.so.1 => /usr/lib/libXxf86dga.so.1 (0x064c4000)
    libaa.so.1 => /usr/lib/libaa.so.1 (0x00db8000)
    libcaca.so.0 => /usr/lib/libcaca.so.0 (0×00110000)
    libvga.so.1 => /usr/lib/libvga.so.1 (0×06092000)
    libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0×06934000)
    libartsc.so.0 => /usr/lib/libartsc.so.0 (0×06723000)
    libgmodule-2.0.so.0 => /lib/libgmodule-2.0.so.0 (0x00b35000)
    libgthread-2.0.so.0 => /lib/libgthread-2.0.so.0 (0x05fb9000)
    libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x0090e000)
    libesd.so.0 => /usr/lib/libesd.so.0 (0x03fca000)
    libaudiofile.so.0 => /usr/lib/libaudiofile.so.0 (0x03f9d000)
    libopenal.so.0 => /usr/lib/libopenal.so.0 (0x06d07000)
    libfaac.so.0 => /usr/lib/libfaac.so.0 (0x00b40000)
    libx264.so.107 => /usr/lib/libx264.so.107 (0x06d49000)
    libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0×06365000)
    libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x00dfe000)
    libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x00c39000)
    libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x00d52000)
    libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x00bce000)
    libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x00b53000)
    libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x00d11000)
    libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00b5e000)
    libgobject-2.0.so.0 => /lib/libgobject-2.0.so.0 (0x009ae000)
    liblirc_client.so.0 => /usr/lib/liblirc_client.so.0 (0x00b3a000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00a2f000)
    libc.so.6 => /lib/libc.so.6 (0x001e0000)
    libgif.so.4 => /usr/lib/libgif.so.4 (0x00a3d000)
    libGL.so.1 => /usr/lib/nvidia/libGL.so.1 (0x0662a000)
    libexpat.so.0 => /lib/libexpat.so.0 (0x0057a000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0×04954000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x0049c000)
    libnsl.so.1 => /lib/libnsl.so.1 (0x05f9e000)
    libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x05f24000)
    libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x05d1f000)
    libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x05db8000)
    libcom_err.so.2 => /lib/libcom_err.so.2 (0x004b3000)
    libldap-2.3.so.0 => /usr/lib/libldap-2.3.so.0 (0x064d9000)
    liblber-2.3.so.0 => /usr/lib/liblber-2.3.so.0 (0x00da8000)
    liblcms.so.1 => /usr/lib/liblcms.so.1 (0x00d70000)
    librt.so.1 => /lib/librt.so.1 (0x005de000)
    /lib/ld-linux.so.2 (0x004d9000)
    libltdl.so.3 => /usr/lib/libltdl.so.3 (0x0626a000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0×00563000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x0055b000)
    libncurses.so.5 => /usr/lib/libncurses.so.5 (0x038e3000)
    libslang.so.2 => /usr/lib/libslang.so.2 (0x05fc0000)
    libgpm.so.1 => /usr/lib/libgpm.so.1 (0x00a13000)
    libncursesw.so.5 => /usr/lib/libncursesw.so.5 (0×06312000)
    libGLU.so.1 => /usr/lib/libGLU.so.1 (0×06290000)
    libglut.so.3 => /usr/lib/libglut.so.3 (0x0033a000)
    libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x067ad000)
    libvorbisfile.so.3 => /usr/lib/libvorbisfile.so.3 (0x067da000)
    libXrender.so.1 => /usr/lib/libXrender.so.1 (0x005ce000)
    libXi.so.6 => /usr/lib/libXi.so.6 (0x00be7000)
    libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0×00908000)
    libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x008fc000)
    libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x005e9000)
    libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x00ce2000)
    libnvidia-tls.so.295.20 => /usr/lib/nvidia/tls/libnvidia-tls.so.295.20 (0x004c3000)
    libnvidia-glcore.so.295.20 => /usr/lib/nvidia/libnvidia-glcore.so.295.20 (0×41775000)
    libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x004b8000)
    libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00df7000)
    libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x03acb000)
    libssl.so.6 => /lib/libssl.so.6 (0x05f54000)
    libcrypto.so.6 => /lib/libcrypto.so.6 (0x05de1000)
    libselinux.so.1 => /lib/libselinux.so.1 (0x00cc8000)
    libsepol.so.1 => /lib/libsepol.so.1 (0x00bf1000)
    [root@chow Desktop]#

  14. 接着 ldd /usr/lib/libass.so.4

    先把退出的问题搞定。

    另外加了选项后字幕对了么?

    • [root@chow ~]# ldd /usr/lib/libass.so.4
      linux-gate.so.1 => (0×00870000)
      libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0×00110000)
      libenca.so.0 => /usr/lib/libenca.so.0 (0×06441000)
      libm.so.6 => /lib/libm.so.6 (0x004f8000)
      libc.so.6 => /lib/libc.so.6 (0x005f1000)
      /lib/ld-linux.so.2 (0x004d9000)
      ————————–
      加了-subcp gbk这个 字幕可以对了,只是有一些字还是乱码;另外有些电影没有出现字幕是因为影片没有字幕吗?

  15. 嗯,你机器上有enca库
    which enca的结果?

    没有出现字幕就是因为射手网上没有,比如你的大魔术师;等有空了我在加个提示信息

  16. [root@chow ~]# ldd `which enca`
    linux-gate.so.1 => (0x00a3d000)
    libenca.so.0 => /usr/lib/libenca.so.0 (0×06441000)
    libm.so.6 => /lib/libm.so.6 (0x004f8000)
    libc.so.6 => /lib/libc.so.6 (0x005f1000)
    /lib/ld-linux.so.2 (0x004d9000)
    [root@chow ~]# which enca
    /usr/bin/enca
    [root@chow ~]#
    ——————————-
    可以做一个东西,如果你的代码更新了,就发邮件给别人?

    • 现在将自动检测字幕编码并转化为utf8

      代码更新的自动通知可以订阅github上的rss

  17. 我看到你的新功能了,有提示正在下载字幕;不过好像搜索不到后不会重复搜索,还有我遇到某个电影他没有提示下载字幕。

  18. 还有字幕的编码好像还得用-subcp utf8指定才能正常显示

    • 是的,我自己都是把-subcp utf8写在配置文件里的

      计划自动转化所有字幕文件的编码到utf8(包括硬盘上已有的字幕),并强制使用-subcp utf8。

      过两天再搞了。

  19. 这是没有提示下载字幕的信息
    [root@chow Desktop]# python mplayer.py /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv -dry-run
    DEBUG: /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    Fullpath: /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv
    Seekable: True
    Video: True
    Dim(pixel): 1280×536 @ 12/5
    Dim(display): 1280×536 @ 12/5
    Subtitles: embedded text

    DEBUG: Final command:
    /usr/bin/mplayer -subfont-autoscale 0 -subfont-osd-scale 18 -subpos 98 -subfont-text-scale 27.0 -vf-pre expand=1280::::1:8/5 -input file=/tmp/tmpD2kkX8/mplayer_fifo /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv

    • Subtitles: embedded text
      这行表示已经有内嵌字幕了,所以不会自动下载。

      内嵌字幕不是中文的?

      • 我仔细看了一会,内嵌字幕是英文的,但那是对里面法语才给出的字幕,所以当他们说法语的时候才显示英文字幕。
        你的脚本不是从射手上下字幕的吗?用射手播放器他下的字幕明显很多,是不是存在什么制约导致你的脚本下载不到更多字幕?

        • 嗯,我再加个检测内嵌字幕语言的功能吧

          • [root@chow Desktop]# python mplayer.py /mnt/Movie/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE/Special.Forces.2011.720p.BluRay.x264-CiNEFiLE.mkv -dry-run
            Traceback (most recent call last):
            File “mplayer.py”, line 810, in
            run()
            File “mplayer.py”, line 795, in run
            media = MediaContext(f)
            File “mplayer.py”, line 665, in __init__
            self.__gen_subtitle_info(info)
            File “mplayer.py”, line 725, in __gen_subtitle_info
            self.subtitles.extend(info["ID_SUBTITLE_FILENAME"])
            KeyError: ‘ID_SUBTITLE_FILENAME’
            好像不能正常播放有内嵌字幕的

          • [root@chow Desktop]# python mplayer.py /mnt/Movie/War.Horse.2011.720p.BluRay.x264-Felony/f-war.horse.720.mkv -dry-run
            Traceback (most recent call last):
            File “mplayer.py”, line 810, in
            run()
            File “mplayer.py”, line 795, in run
            media = MediaContext(f)
            File “mplayer.py”, line 665, in __init__
            self.__gen_subtitle_info(info)
            File “mplayer.py”, line 735, in __gen_subtitle_info
            self.subtitles.extend(info["ID_VOBSUB_FILENAME"])
            KeyError: ‘ID_VOBSUB_FILENAME’

          • 嗯,无脑ctrl-v了

          • 是不是检测到有内嵌字幕就不再下载字幕了?这样的话内嵌字幕不是中文不是很不方便?

          • 现在是检测到有内嵌字幕就不再下载

            会加个检测内嵌字幕语言的功能的

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

Switch to our mobile site