Skip to content

Various remarks on the command line tool

Hi,

I've been using your tool to resynchronize subtitles after they get downloaded by Bazarr and to be honest, it's a great piece of code!
Thanks a lot for it!

I'm using your active branch "various_fixes" in a debian buster LXC container.

I have a few remarks/requests if you allow me:

  1. I'm only using the resync function with something like: pipenv run autosync-ui --sub "${SubtitleFile}" "${VideoFile}"
    The log produced by the execution is quite verbose (with even some warnings from python version).
    Is it possible to limit the verbosity?
pipenv run autosync-ui --sub "${SubtitleFile}" "${VideoFile}"                                                        
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])                                                                                                                                                                   
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.                                                                                                                                           
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])                                                                                                                                                                   
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.                                                                                                                                           
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])                                                                                                                                                                
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.                                                                                                                                           
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])                                                                                                                                                                   
/opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a fu
ture version of numpy, it will be understood as (type, (1,)) / '(1,)type'.                                                                                                                                           
  np_resource = np.dtype([("resource", np.ubyte, 1)])                                                                                                                                                                
DEBUG:matplotlib:CONFIGDIR=/opt/bazarr/.config/matplotlib                                                                                                                                                            
DEBUG:matplotlib:matplotlib data path: /opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/matplotlib/mpl-data                                                                        
DEBUG:matplotlib:loaded rc file /opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc                                                                  
DEBUG:matplotlib:matplotlib version 3.2.0rc1                                                                                                                                                                         
DEBUG:matplotlib:interactive is False                                                                                                                                                                                
DEBUG:matplotlib:platform is linux                                                                                                                                                                                   
DEBUG:matplotlib:loaded modules: ['sys', 'builtins', '_frozen_importlib', '_imp', '_thread', '_warnings', '_weakref', 'zipimport', '_frozen_importlib_external', '_io', 'marshal', 'posix', 
<...LOTS OF LINES...>
'cycler', 'matplotlib._version', 'matplotlib.ft2font', 'kiwisolver']                                                                                                                                         
DEBUG:matplotlib:CACHEDIR=/opt/bazarr/.cache/matplotlib                                                                                                                                                              
DEBUG:matplotlib.font_manager:Using fontManager instance from /opt/bazarr/.cache/matplotlib/fontlist-v310.json                                                                                                       
DEBUG:matplotlib.pyplot:Loaded backend qt5agg version unknown.                                                                                                                                                       
DEBUG:matplotlib.pyplot:Loaded backend qt4agg version unknown.                                                                                                                                                       
DEBUG:matplotlib.pyplot:Loaded backend agg version unknown.                                                                                                                                                          
DEBUG:matplotlib.pyplot:Loaded backend agg version unknown.                                                                                                                                                          
2020-01-07 21:05:12.249467: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA                                        
2020-01-07 21:05:12.282897: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2299965000 Hz                                                                                                   
2020-01-07 21:05:12.283567: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x1ad78c0 executing computations on platform Host. Devices:                                                                
2020-01-07 21:05:12.283601: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>                                                                                  
WARNING:tensorflow:From /opt/autosync/autosync/sync.py:34: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.
Instructions for updating:                                                                                                                                                                                 [680/1924]
This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorf
low 2.0.                                                                                                                                                                                                             
WARNING:tensorflow:From /opt/bazarr/.local/share/virtualenvs/autosync-nDe0fzYZ/lib/python3.7/site-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_ma
nagement) is deprecated and will be removed in a future version.                                                                                                                                                     
Instructions for updating:                                                                                                                                                                                           
Use standard file APIs to check for files with this prefix.                                                                                                                                                          
INFO:tensorflow:Restoring parameters from /opt/autosync/saved_models/m17_dataclean_300k_balanced/variables/variables                                                                                                 
Running CLI                                                                                                                                                                                                          
Running CLI                                                                                                                                                                                                          
{'video': '${VideoFile}', 'sub': '${SubtitleFile}', 'lang': 'english'}                                                                                                                                                          
Extracting audio...                                                                                                                                                                                                  
Each block (32 ms) contains 512 samples                                                                                                                                                                              
Loading ${VideoFile}                                                                                            
Saving audio to temp file: /tmp/tmpc2up5r6o/${VideoFile%.*}.wav                                                                                                       
MoviePy - Writing audio in /tmp/tmpc2up5r6o/${VideoFile%.*}.wav                                                                                                       
MoviePy - Done.                                                                                                                                                                                                      
Computing MFCC features for video 0...                                                                                                                                                                               
Feats min/max: -598.5703125/203.27346801757812                                                                                                                                                                       
Analyzing audio...  
Model signature: {'serving_default': inputs {                                                                                                                                                              [659/1924]
  key: "audio_mfcc"                                                                                                                                                                                                  
  value {                                                                                                                                                                                                            
    name: "IteratorGetNext_2:0"                                                                                                                                                                                      
    dtype: DT_FLOAT                                                                                                                                                                                                  
    tensor_shape {                                                                                                                                                                                                   
      dim {                                                                                                                                                                                                          
        size: -1                                                                                                                                                                                                     
      }                                                                                                                                                                                                              
      dim {                                                                                                                                                                                                          
        size: 14                                                                                                                                                                                                     
      }                                                                                                                                                                                                              
      dim {                                                                                                                                                                                                          
        size: 1                                                                                                                                                                                                      
      }                                                                                                                                                                                                              
    }                                                                                                                                                                                                                
  }                                                                                                                                                                                                                  
}                                                                                                                                                                                                                    
outputs {                                                                                                                                                                                                            
  key: "has_speech"                                                                                                                                                                                                  
  value {
    name: "sequential_2/lambda/truediv:0"                                                                                                                                                                  [638/1924]
    dtype: DT_FLOAT                                                                                                                                                                                                  
    tensor_shape {                                                                                                                                                                                                   
      dim {                                                                                                                                                                                                          
        size: -1                                                                                                                                                                                                     
      }                                                                                                                                                                                                              
      dim {                                                                                                                                                                                                          
        size: 1                                                                                                                                                                                                      
      }                                                                                                                                                                                                              
    }                                                                                                                                                                                                                
  }                                                                                                                                                                                                                  
}                                                                                                                                                                                                                    
method_name: "tensorflow/serving/predict"                                                                                                                                                                            
}                                                                                                                                                                                                                    
Parsing subtitle...                                                                                                                                                                                                  
Loading sub: ${SubtitleFile}                                                                                    
Dumping 6400 points at start/end                                                                                                                                                                                     
Synchronizing...                                                                                                                                                                                                     
Range: (slice(-5625.0, 5625.0, 93.75), slice(0.9, 1.1, 0.05))                                                                                                                                                        
Loss: 1.75 | Delay: -5625 | FPS ratio: 0.90
<...LOTS OF LINES...>
Loss: 0.94 | Delay: 0 | FPS ratio: 1.00
Loss: 0.94 | Delay: 0 | FPS ratio: 1.00
Optimization result (blocks | ratio): [6.24847412e-05 1.00000610e+00]
Sub is off by 1.9995117187500003e-06s
Subtitle synced (delay: 0.00s | fps: 1.00) and saved.
Just open VLC, select it in the sub list and you're all set.
File: ${VideoFileNoLangNoExt}_english_synced.srt
  1. The subtitle file name produced is fixed.
    So files get changed like this: Filename.en.sub ->> Filename_english_synced.srt
    We also loose the extension (srt is fixed)
    Would it be possible to force a replace or let us choose the naming scheme?
    It's this part of the code I think (not well versed in python, sorry :') ):
# Build final sub name so that it's automatically picked up by media players
    filename, ext = os.path.splitext(settings['video'])
    sub_name = '{}_{}_{}.srt'.format(
        filename,
        settings['lang'],
        'synced'
    )

Anyway, again thank you, it works quite well otherwise (it takes between 1 and 2 mn to proceed an espisode) and all these issues (maybe only for me) can easily be solved by some bash scripting (which is what I did !)