Как преобразовать последовательность шестнадцатеричных чисел в символы в оболочке сценария?

Чтобы запустить основной поток видео DVD с mpv (вместо простого перетаскивания папки VIDEO_TS на mpv window) используйте команду:

mpv dvd://

(как указано jasonwryan в комментарии ниже) или даже (заменив имя пользователя на ваше )

mpv /media/username/*/VIDEO_TS

Итак просто используйте это с помощью сочетания клавиш или в программе запуска; или конкретный файл .desktop можно создать на рабочем столе или в ~ / .local / share / applications , например (текстовый редактор, например gedit , на ваш выбор ):

gedit ~/.local/share/applications/mpv_dvd.desktop

с

[Desktop Entry]
Categories=AudioVideo;Audio;Video;Player;TV;
Exec=mpv dvd://
Icon=/path/to/your/mpv_icon.png
MimeType=
Name=Play DVD in mpv Media Player
StartupNotify=true
Terminal=false
Type=Application

Измените также путь к значку: возможно, используйте этот ,

enter image description here

или этот .)

enter image description here

Кнопку / значок запуска можно разместить на рабочем столе, на панели или найти и запустить из «средства запуска приложений» (Dash, Synapse, Kickoff, Wisker Menu, Slingshot и т. Д.)

Для доступа больше, чем основной поток (вторичные видео, содержимое меню, изображения), можно зайти в папку DVD VIDEO_TS и поискать там больше, или вы можете попробовать другую команду (которая будет использоваться, как указано выше, в горячая клавиша или средство запуска):

mpv /dev/sr0

, который будет воспроизводить и искать по всем включенным потокам, включая меню, как если бы в одном файле. Но результаты могут варьироваться от хороших до очень плохих (по какой-то причине изображение иногда бывает ужасным при использовании этой команды).

Графический интерфейс mpv очень минималистичен, но включает две кнопки для циклического переключения аудиопотоков и субтитров, и они также работают с DVD. Кнопки «следующий / предыдущий» изменяют разделы внутри видеопотока (не разные потоки / заголовки).

enter image description here

Имеется много возможных сочетаний клавиш. Значения по умолчанию описаны следующим образом:

NAME

       mpv - a movie player

SYNOPSIS

       mpv [options] [file|URL|-]
       mpv [options] --playlist=PLAYLIST
       mpv [options] files
       mpv [options] {group of files and options}
       mpv [bd]://[title][/device] [options]
       mpv dvd://[title|[start_title]-end_title][/device] [options]
       mpv dvdnav://[longest|menu|title][/device] [options]
       mpv vcd://[/device]
       mpv tv://[channel][/input_id] [options]
       mpv radio://[channel|frequency][/capture] [options]
       mpv pvr:// [options]
       mpv dvb://[card_number@]channel [options]
       mpv mf://[filemask|@listfile] [-mf options] [options]
       mpv cdda://track[-endtrack][:speed][/device] [options]
       mpv [file|mms[t]|http|httpproxy|rt[s]p|ftp|udp|smb]://[user:pass@]URL[:port] [options]
       mpv edl://[edl specification as in edl-mpv.rst]

DESCRIPTION

       mpv is a movie player based on MPlayer and mplayer2. It supports a wide
       variety of video file formats, audio and  video  codecs,  and  subtitle
       types.  Special  input  URL  types  are  available to read input from a
       variety of sources other than disk  files.  Depending  on  platform,  a
       variety of different video and audio output methods are supported.

       Usage  examples  to  get you started quickly can be found at the end of
       this man page.

INTERACTIVE CONTROL

       mpv has a fully configurable, command-driven control layer which allows
       you  to  control  mpv using keyboard, mouse, joystick or remote control
       (with LIRC). See the --input- options for ways to customize it.

   Keyboard Control
       LEFT and RIGHT
              Seek backward/forward 10 seconds. Shift+arrow does  a  1  second
              exact seek (see --hr-seek).

       UP and DOWN
              Seek  forward/backward  1  minute.  Shift+arrow  does a 5 second
              exact seek (see --hr-seek).

       PGUP and PGDWN
              Seek forward/backward 10 minutes.

       [ and ]
              Decrease/increase current playback speed by 10%.

       { and }
              Halve/double current playback speed.

       BACKSPACE
              Reset playback speed to normal.

       < and >
              Go backward/forward in the playlist.

       ENTER  Go forward in the playlist, even over the end.

       p / SPACE
              Pause (pressing again unpauses).

       .      Step forward. Pressing once will pause movie, every  consecutive
              press will play one frame and then go into pause mode again.

       ,      Step backward. Pressing once will pause movie, every consecutive
              press will play one frame in reverse and then go into pause mode
              again.

       q / ESC
              Stop playing and quit.

       Q      Like  q,  but  store  the current playback position. Playing the
              same file later will resume at  the  old  playback  position  if
              possible.

       U      Stop playing (and quit if --idle is not used).

       + and -
              Adjust audio delay by +/- 0.1 seconds.

       / and *
              Decrease/increase volume.

       9 and 0
              Decrease/increase volume.

       ( and )
              Adjust audio balance in favor of left/right channel.

       m      Mute sound.

       _      Cycle through the available video tracks.

       #      Cycle through the available audio tracks.

       TAB (MPEG-TS and libavformat only)
              Cycle through the available programs.

       f      Toggle fullscreen (see also --fs).

       T      Toggle stay-on-top (see also --ontop).

       w and e
              Decrease/increase pan-and-scan range.

       o      Toggle  OSD  states: none / seek / seek + timer / seek + timer +
              total time.

       d      Toggle frame  dropping  states:  none  /  skip  display  /  skip
              decoding (see --framedrop).

       v      Toggle subtitle visibility.

       j and J
              Cycle through the available subtitles.

       F      Toggle displaying "forced subtitles".

       x and z
              Adjust subtitle delay by +/- 0.1 seconds.

       V      Toggle   subtitle   VSFilter   aspect  compatibility  mode.  See
              --ass-vsfilter-aspect-compat for more info.

       r and t
              Move subtitles up/down.

       s      Take a screenshot.

       S      Take  a  screenshot,  without  subtitles.  (Whether  this  works
              depends on VO driver support.)

       I      Show filename on the OSD.

       P      Show  progression  bar,  elapsed  time and total duration on the
              OSD.

       ! and @
              Seek to the beginning of  the  previous/next  chapter.  In  most
              cases,  "previous"  will  actually  go  to  the beginning of the
              current chapter; see --chapter-seek-threshold.

       D (--vo=vdpau, --vf=yadif only)
              Activate/deactivate deinterlacer.

       A      Cycle through the available DVD angles.

       c      Change YUV colorspace.

       (The following keys are valid only  when  using  a  video  output  that
       supports  the  corresponding  adjustment,  or  the  software  equalizer
       (--vf=eq).)

       1 and 2
              Adjust contrast.

       3 and 4
              Adjust brightness.

       5 and 6
              Adjust gamma.

       7 and 8
              Adjust saturation.

       (The following keys are valid only on OSX.)

       command + 0
              Resize movie window to half its original size.

       command + 1
              Resize movie window to its original size.

       command + 2
              Resize movie window to double its original size.

       command + f
              Toggle fullscreen (see also --fs).

       command + [ and command + ]
              Set movie window alpha.

       (The following keys are valid if you have a  keyboard  with  multimedia
       keys.)

       PAUSE  Pause.

       STOP   Stop playing and quit.

       PREVIOUS and NEXT
              Seek backward/forward 1 minute.

       (The following keys are only valid if you compiled with TV or DVB input
       support.)

       h and k
              Select previous/next channel.

       n      Change norm.

       u      Change channel list.

   Mouse Control
       button 3 and button 4
              Seek backward/forward 1 minute.

       button 5 and button 6
              Decrease/increase volume.

Особенно полезными я считаю:

r and t
              Move subtitles up/down.




j and J
              Cycle through the available subtitles.




 #      Cycle through the available audio tracks.


  w and e
              Decrease/increase pan-and-scan range.

Их можно настроить в

gedit ~/.config/mpv/input.conf

По умолчанию это:

# mpv keybindings
#
# Location of user-defined bindings: ~/.config/mpv/input.conf
#
# Lines starting with # are comments. Use SHARP to assign the # key.
# Copy this file and uncomment and edit the bindings you want to change.
#
# List of commands and further details: DOCS/man/input.rst
# List of special keys: --input-keylist
# Keybindings testing mode: mpv --input-test --force-window --idle
#
# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').
#
# Strings need to be quoted and escaped:
#   KEY show-text "This is a single backslash: \\ and a quote: \" !"
#
# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with
# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal).
#
# The default keybindings are hardcoded into the mpv binary.
# You can disable them completely with: --no-input-default-bindings

# Developer note:
# On compilation, this file is baked into the mpv binary, and all lines are
# uncommented (unless '#' is followed by a space) - thus this file defines the
# default key bindings.

# If this is enabled, treat all the following bindings as default.
#default-bindings start

#MOUSE_BTN0 ignore                      # don't do anything
#MOUSE_BTN0_DBL cycle fullscreen        # toggle fullscreen on/off
#MOUSE_BTN2 cycle pause                 # toggle pause on/off
#MOUSE_BTN3 seek 10
#MOUSE_BTN4 seek -10
#MOUSE_BTN5 add volume -2
#MOUSE_BTN6 add volume 2

# Mouse wheels, touchpad or other input devices that have axes
# if the input devices supports precise scrolling it will also scale the
# numeric value accordingly
#AXIS_UP    seek 10
#AXIS_DOWN  seek -10
#AXIS_LEFT  seek 5
#AXIS_RIGHT seek -5

## Seek units are in seconds, but note that these are limited by keyframes
#RIGHT seek  5
#LEFT  seek -5
#UP    seek  60
#DOWN  seek -60
# Do smaller, always exact (non-keyframe-limited), seeks with shift.
# Don't show them on the OSD (no-osd).
#Shift+RIGHT no-osd seek  1 exact
#Shift+LEFT  no-osd seek -1 exact
#Shift+UP    no-osd seek  5 exact
#Shift+DOWN  no-osd seek -5 exact
# Skip to previous/next subtitle (subject to some restrictions; see manpage)
#Ctrl+LEFT   no-osd sub-seek -1
#Ctrl+RIGHT  no-osd sub-seek  1
#PGUP add chapter 1                     # skip to next chapter
#PGDWN add chapter -1                   # skip to previous chapter
#Shift+PGUP seek 600
#Shift+PGDWN seek -600
#[ multiply speed 0.9091                # scale playback speed
#] multiply speed 1.1
#{ multiply speed 0.5
#} multiply speed 2.0
#BS set speed 1.0                       # reset speed to normal
#q quit
#Q quit-watch-later
#q {encode} quit 4
#ESC set fullscreen no
#ESC {encode} quit 4
#p cycle pause                          # toggle pause/playback mode
#. frame-step                           # advance one frame and pause
#, frame-back-step                      # go back by one frame and pause
#SPACE cycle pause
#> playlist-next                        # skip to next file
#ENTER playlist-next                    # skip to next file
#< playlist-prev                        # skip to previous file
#O no-osd cycle_values osd-level 3 1    # cycle through OSD mode
#o show-progress
#P show-progress
#I show-text "${filename}"              # display filename in osd
#z add sub-delay -0.1                   # subtract 100 ms delay from subs
#x add sub-delay +0.1                   # add
#ctrl++ add audio-delay 0.100           # this changes audio/video sync
#ctrl+- add audio-delay -0.100
#9 add volume -2
#/ add volume -2
#0 add volume 2
#* add volume 2
#m cycle mute
#1 add contrast -1
#2 add contrast 1
#3 add brightness -1
#4 add brightness 1
#5 add gamma -1
#6 add gamma 1
#7 add saturation -1
#8 add saturation 1
# toggle deinterlacer (automatically inserts or removes required filter)
#d cycle deinterlace
#r add sub-pos -1                       # move subtitles up
#t add sub-pos +1                       #                down
#v cycle sub-visibility
# stretch SSA/ASS subtitles with anamorphic videos to match historical
#V cycle ass-vsfilter-aspect-compat
# switch between applying no style overrides to SSA/ASS subtitles, and
# overriding them almost completely with the normal subtitle style
#u cycle-values ass-style-override "force" "no"
#j cycle sub                            # cycle through subtitles
#J cycle sub down                       # ...backwards
#Ctrl+A cycle audio                      # switch audio streams
#_ cycle video
#T cycle ontop                          # toggle video window ontop of other windows
#f cycle fullscreen                     # toggle fullscreen
#s screenshot                           # take a screenshot
#S screenshot video                     # ...without subtitles
#Ctrl+s screenshot window               # ...with subtitles and OSD, and scaled
#Alt+s screenshot each-frame            # automatically screenshot every frame
#w add panscan -0.1                     # zoom out with -panscan 0 -fs
#e add panscan +0.1                     #      in
#cycle video aspect ratios; "-1" is the container aspect
#A cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
#POWER quit
#PLAY cycle pause
#PAUSE cycle pause
#PLAYPAUSE cycle pause
#STOP quit
#FORWARD seek 60
#REWIND seek -60
#NEXT playlist-next
#PREV playlist-prev
#VOLUME_UP add volume 2
#VOLUME_DOWN add volume -2
#MUTE cycle mute
#CLOSE_WIN quit
#CLOSE_WIN {encode} quit 4
#E cycle edition                        # next edition
#l ab_loop                              # Set/clear A-B loop points
#L cycle-values loop "inf" "no"         # toggle infinite looping
#ctrl+c quit 4

# Apple Remote section
#AR_PLAY cycle pause
#AR_PLAY_HOLD quit
#AR_CENTER cycle pause
#AR_CENTER_HOLD quit
#AR_NEXT seek 10
#AR_NEXT_HOLD seek 120
#AR_PREV seek -10
#AR_PREV_HOLD seek -120
#AR_MENU show-progress
#AR_MENU_HOLD cycle mute
#AR_VUP add volume 2
#AR_VUP_HOLD add chapter 1
#AR_VDOWN add volume -2
#AR_VDOWN_HOLD add chapter -1

# For tv://
#h cycle tv-channel -1                  # previous channel
#k cycle tv-channel +1                  # next channel

#
# Legacy bindings (may or may not be removed in the future)
#
#! add chapter -1                       # skip to previous chapter
#@ add chapter 1                        #         next

#
# Not assigned by default
# (not an exhaustive list of unbound commands)
#

# ? add sub-scale +0.1                  # increase subtitle font size
# ? add sub-scale -0.1                  # decrease subtitle font size
# ? sub-step -1                         # immediately display next subtitle
# ? sub-step +1                         #                     previous
# ? cycle-values window-scale 0.5 2 1   # switch between 1/2, 2x, unresized window size
# ? cycle colormatrix
# ? add audio-delay 0.100               # this changes audio/video sync
# ? add audio-delay -0.100
# ? cycle angle                         # switch DVD/Bluray angle
# ? add balance -0.1                    # adjust audio balance in favor of left
# ? add balance 0.1                     #                                  right
# ? cycle sub-forced-only               # toggle DVD forced subs
# ? cycle program                       # cycle transport stream programs
# ? stop                                # stop playback (quit or enter idle mode)

Все необходимые пояснения находятся внутри этого файла.

Привязки клавиш по умолчанию жестко запрограммированы в двоичный файл mpv. Вы можете полностью отключить их с помощью: - no-input-default-bindings , но более полезно использовать новые более интуитивно понятные клавиши и действия мыши , которые можно добавить в конце этого файла, например:

Alt+a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
Ctrl+a cycle audio                      # switch audio streams
Ctrl+f cycle fullscreen        # toggle fullscreen on/off
Ctrl+s cycle sub                            # cycle through subtitles
Meta+UP add sub-pos -1                       # move subtitles up
Meta+DOWN add sub-pos +1                       #                down
Meta+Alt+s cycle sub-visibility             # show/hide subtitles
Ctrl+z add panscan +0.1                    # zoom in
Ctrl+< add panscan -0.1                    # zoom out
MOUSE_BTN0 ignore                      # don't do anything
MOUSE_BTN0_DBL cycle fullscreen        # toggle fullscreen on/off
MOUSE_BTN2 cycle pause                 # toggle pause on/off
MOUSE_BTN3 add volume 2                # increase volume with mouse wheel
MOUSE_BTN4 add volume -2               # decrease volume with mouse wheel
#MOUSE_BTN5 add volume -2
#MOUSE_BTN6 add volume 2
MOUSE_BTN1 cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
Ctrl+RIGHT seek  60
Ctrl+LEFT  seek -60
UP    add volume 2
DOWN  add volume -2

Как уже упоминалось, mpv - лучший способ добавить внешние субтитры к DVD .

1
28.03.2019, 02:38
1 ответ

Для этого я придумал следующее:

#!/bin/sh

if [ "$1" = '-' ]; then
    file='/dev/stdin'
else
    if [ ! -f "$1" ]; then
        printf 'ERROR! Cannot find file\n' >&2
        exit 1
    else
        file=$1
    fi
fi

while read -r num; do
    printf '%s\n' "$num" | xxd -r -p
    echo
done < "$file"
  • Если первый позиционный параметр равен -, мы будем читать со стандартного ввода
  • В противном случае мы проверяем, является ли первый аргумент допустимым файлом. Если это так, мы будем читать из него, если нет, мы выполним ошибку и выйдем.
  • Мы будем читать каждую строку либо из стандартного ввода, либо из файла и присваивать этой строке переменную num
  • мы передадим переменную numв xxdдля ее преобразования
  • эхо здесь, чтобы гарантировать добавление новой строки после каждого результата

С напильником:

$ cat test_number
30  31  37  20  41  41  41  20  0A
30  31  37  20  41  41  41
30 31 37 20 42 42 42
30 31 37 20 43 43 43
42 45 45 46
$./hex.sh test_number
017 AAA

017 AAA
017 BBB
017 CCC
BEEF

Из стандартного ввода:

$./hex.sh -
30  31  37  20  41  41  41  20  0A
017 AAA

42 45 45 46
BEEF
^C
$
1
27.01.2020, 23:41

Теги

Похожие вопросы