Skip to content

Commit

Permalink
[UPDATE] fixed that fail when filename contains special chars like \' "
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinleeex committed Jul 3, 2019
1 parent 387f7b9 commit 8e55ad4
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

<div align="center"><img style="display:inline-block" width='150' src="./assets/logo.png"/><p>
<span style="font-size: 14px">Version: 0.4.6</span><br>
<span style="font-size: 14px">Version: 0.4.9</span><br>
<span>"A Simple Beat Time Marks Generator"</span><br>
<span style="font-size: 12px;color= #95dafc">-- Created by <a>Kevin T. Lee</a> --</span>
</p>
<a href="./LICENSE"><img alt="MIT" src="https://img.shields.io/github/license/mashape/apistatus.svg?&url=LICENSE&longCache=true&style=for-the-badge"></a>
<a href="http://lidengju.com"><img alt="Code" src="https://img.shields.io/badge/Code%20with-Love-red.svg?longCache=true&style=for-the-badge"></a>
<a href="https://github.com/kevinleeex/dj-beat/"><img alt="Version" src="https://img.shields.io/badge/Version-0.4.6-blue.svg?longCache=true&style=for-the-badge"></a>
<a href="https://github.com/kevinleeex/dj-beat/"><img alt="Version" src="https://img.shields.io/badge/Version-0.4.9-blue.svg?longCache=true&style=for-the-badge"></a>
</div>

# DJ-beat
Expand Down
8 changes: 5 additions & 3 deletions djbeat/djbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# author: Kevin T. Lee<[email protected]>
# description: DJ-beat is available to detect the beat from the audio and generate time marks for FCPX and premiere.

__version__ = '0.4.7'
__version__ = '0.4.9'

import madmom
import librosa
Expand All @@ -11,6 +11,7 @@
import os
import datetime
import numpy as np
import re
from tqdm import tqdm
from pyfiglet import Figlet
from string import Template
Expand Down Expand Up @@ -54,7 +55,7 @@ def proc_data(self):
self.file_time = (1.0 * len(self.y) / self.audio_sr)
self.file_real_length = int(self.file_time * 1000)
self.file_length = int(self.file_time) * 1000
proc = madmom.features.beats.DBNBeatTrackingProcessor(fps=self.fps)
proc = madmom.features.beats.DBNBeatTrackingProcessor(look_ahead=0.4, fps=self.fps)
act = madmom.features.beats.RNNBeatProcessor()(self.filepath)

beat_times = proc(act)
Expand All @@ -76,10 +77,11 @@ def gen_fcpxml(self):

self.beat_marks = '\n'.join(markers)

new_file_name = re.sub(r'\W','_',self.file_name)
_dict = {'build_version': self.build_version,
'date_time': self.date_time,
'frame_rate': self.frame_rate,
'file_name': self.file_name,
'file_name': new_file_name,
'file_path': pathname2url(self.abs_filepath),
'file_length': self.file_length,
'file_real_length': self.file_real_length,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
entry_points={
"console_scripts": ['djbeat = djbeat.djbeat:main']
},
version='0.4.7',
version='0.4.9',
description="A simple CLI tool for generating beat marks of music for FCPX and PRE",
license="MIT",
install_requires=[
Expand Down
42 changes: 42 additions & 0 deletions test/treasure-trimed Project.fcpxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>

<fcpxml version="1.8">
<resources>
<format id="r1" name="FFVideoFormat1080p30" frameDuration="100/3000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
<asset id="r2" name="中文 测试&quot;" uid="F554540157F2DDDD141252517F34AA6E" src="file:///Users/kevin/Projects/GitHub/dj-beat/test/%E4%B8%AD%E6%96%87%20%E6%B5%8B%E8%AF%95%22.wav" start="0s" duration="241531/44100s" hasAudio="1" audioSources="1" audioChannels="2" audioRate="44100">
<bookmark>Ym9vazQDAAAAAAQQMAAAAGmRsqvaJ4K/qcAGPjgdMvst076Mb9cX1iFox0ENEVbpMAIAAAQAAAADAwAAABgAKAUAAAABAQAAVXNlcnMAAAAFAAAAAQEAAGtldmluAAAACAAAAAEBAABQcm9qZWN0cwYAAAABAQAAR2l0SHViAAAHAAAAAQEAAGRqLWJlYXQABAAAAAEBAAB0ZXN0EgAAAAEBAADkuK3mlocg5rWL6K+VIi53YXYAABwAAAABBgAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAbAAAAAgAAAAEAwAAo2cGAAAAAAAIAAAABAMAALWlCQAAAAAACAAAAAQDAAA22xoAAQAAAAgAAAAEAwAAEU1VAQEAAAAIAAAABAMAANShRAIBAAAACAAAAAQDAADUokQCAQAAAAgAAAAEAwAAoEa8AgEAAAAcAAAAAQYAAKwAAAC8AAAAzAAAANwAAADsAAAA/AAAAAwBAAAIAAAAAAQAAEHBX5gR4RSYGAAAAAECAAABAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAIAAAABAMAAAUAAAAAAAAABAAAAAMDAAD1AQAACAAAAAEJAABmaWxlOi8vLwwAAAABAQAATWFjaW50b3NoIEhECAAAAAQDAAAAoCBodAAAAAgAAAAABAAAQb6DYoIAAAAkAAAAAQEAADBENjJCNzdELUQ1RkItMzQzQy05NzYyLTg0NzdDQTFCQzk1QRgAAAABAgAAgQAAAAEAAADvEwAAAQAAAAAAAAAAAAAAAQAAAAEBAAAvAAAAAAAAAAEFAADMAAAA/v///wEAAAAAAAAAEAAAAAQQAACIAAAAAAAAAAUQAAAcAQAAAAAAABAQAABQAQAAAAAAAEAQAABAAQAAAAAAAAIgAAAcAgAAAAAAAAUgAACMAQAAAAAAABAgAACcAQAAAAAAABEgAADQAQAAAAAAABIgAACwAQAAAAAAABMgAADAAQAAAAAAACAgAAD8AQAAAAAAADAgAAAoAgAAAAAAAAHAAABwAQAAAAAAABHAAAAgAAAAAAAAABLAAACAAQAAAAAAABDQAAAEAAAAAAAAAA==</bookmark>
</asset>
</resources>
<library location="file:///Users/kevin/Movies/Kevin.fcpbundle/">
<event name="treasure-trimed Event" uid="7A9FF238-349D-4B45-BC12-4DFB9BC87747">
<project name="treasure-trimed Project" uid="A1409274-B5B3-4B99-ADCA-39AC09FC04ED" modDate="2019-07-03 13:45:07 +0800">
<sequence duration="16400/3000s" format="r1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip name="中文 测试&quot;" offset="0s" ref="r2" duration="16400/3000s" audioRole="dialogue">
<marker start="395519/240000s" duration="1/48000s" value="Marker 3"/>
<marker start="1743283/720000s" duration="1/48000s" value="Marker 1"/>
<marker start="141837/40000s" duration="1/48000s" value="Marker 2"/>
</asset-clip>
</spine>
</sequence>
</project>
</event>
<smart-collection name="项目" match="all">
<match-clip rule="is" type="project"/>
</smart-collection>
<smart-collection name="所有视频" match="any">
<match-media rule="is" type="videoOnly"/>
<match-media rule="is" type="videoWithAudio"/>
</smart-collection>
<smart-collection name="仅音频" match="all">
<match-media rule="is" type="audioOnly"/>
</smart-collection>
<smart-collection name="静止图像" match="all">
<match-media rule="is" type="stills"/>
</smart-collection>
<smart-collection name="个人收藏" match="all">
<match-ratings value="favorites"/>
</smart-collection>
</library>
</fcpxml>
File renamed without changes.
39 changes: 39 additions & 0 deletions test/中文 测试"$#&*^!~.wav.fcpxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>

<!-- DJ-beat @2019 Kevin T. Lee - Build Version: 0.4.8 -->
<!-- Build Date Time: 2019-07-03 14:37 -->

<fcpxml version="1.6">
<resources>
<format id='k1' name='FFVideoFormat1080p30' frameDuration='1/30s'/>
<asset id="k2" name="中文_测试________" src="file:/Users/kevin/Projects/GitHub/dj-beat/test/%E4%B8%AD%E6%96%87%20%E6%B5%8B%E8%AF%95%22%24%23%26%2A%5E%21%7E.wav" start='0/1000s' duration='5476/1000s' hasAudio="1" audioSources="1" audioRate="22050">
</asset>
</resources>
<library>
<event name="中文_测试________ Event">
<project name="中文_测试________ Project">
<sequence duration='5000/1000s' format="k1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip name='中文_测试________' lane='0' offset='0/1000s' ref='k2' duration='5000/1000s' audioRole='Music'>
<marker start='7/30s' duration='1/48000s' value='beat_at_0.25' completed='0'/>
<marker start='23/30s' duration='1/48000s' value='beat_at_0.77' completed='0'/>
<marker start='38/30s' duration='1/48000s' value='beat_at_1.28' completed='0'/>
<marker start='54/30s' duration='1/48000s' value='beat_at_1.8' completed='0'/>
<marker start='69/30s' duration='1/48000s' value='beat_at_2.32' completed='0'/>
<marker start='85/30s' duration='1/48000s' value='beat_at_2.84' completed='0'/>
<marker start='100/30s' duration='1/48000s' value='beat_at_3.35' completed='0'/>
<marker start='116/30s' duration='1/48000s' value='beat_at_3.87' completed='0'/>
<marker start='131/30s' duration='1/48000s' value='beat_at_4.39' completed='0'/>
<marker start='147/30s' duration='1/48000s' value='beat_at_4.91' completed='0'/>
<marker start='162/30s' duration='1/48000s' value='beat_at_5.42' completed='0'/>

<audio-channel-source role='music.music-1' srcCh='1, 2'/>
</asset-clip>

</spine>
</sequence>
</project>
</event>
</library>
</fcpxml>
39 changes: 39 additions & 0 deletions test/中文 测试".wav.fcpxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>

<!-- DJ-beat @2019 Kevin T. Lee - Build Version: 0.4.8 -->
<!-- Build Date Time: 2019-07-03 13:46 -->

<fcpxml version="1.6">
<resources>
<format id='k1' name='FFVideoFormat1080p30' frameDuration='1/30s'/>
<asset id="k2" name="中文 测试"" src="file:/Users/kevin/Projects/GitHub/dj-beat/test/%E4%B8%AD%E6%96%87%20%E6%B5%8B%E8%AF%95%22.wav" start='0/1000s' duration='5476/1000s' hasAudio="1" audioSources="1" audioRate="22050">
</asset>
</resources>
<library>
<event name="中文 测试" Event">
<project name="中文 测试" Project">
<sequence duration='5000/1000s' format="k1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip name='中文 测试"' lane='0' offset='0/1000s' ref='k2' duration='5000/1000s' audioRole='Music'>
<marker start='7/30s' duration='1/48000s' value='beat_at_0.25' completed='0'/>
<marker start='23/30s' duration='1/48000s' value='beat_at_0.77' completed='0'/>
<marker start='38/30s' duration='1/48000s' value='beat_at_1.28' completed='0'/>
<marker start='54/30s' duration='1/48000s' value='beat_at_1.8' completed='0'/>
<marker start='69/30s' duration='1/48000s' value='beat_at_2.32' completed='0'/>
<marker start='85/30s' duration='1/48000s' value='beat_at_2.84' completed='0'/>
<marker start='100/30s' duration='1/48000s' value='beat_at_3.35' completed='0'/>
<marker start='116/30s' duration='1/48000s' value='beat_at_3.87' completed='0'/>
<marker start='131/30s' duration='1/48000s' value='beat_at_4.39' completed='0'/>
<marker start='147/30s' duration='1/48000s' value='beat_at_4.91' completed='0'/>
<marker start='162/30s' duration='1/48000s' value='beat_at_5.42' completed='0'/>
<audio-channel-source role='music.music-1' srcCh='1, 2'/>
</asset-clip>
</spine>
</sequence>
</project>
</event>
</library>
</fcpxml>
4 changes: 2 additions & 2 deletions test/中文 测试.wav.fcpxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>

<!-- DJ-beat @2019 Kevin T. Lee - Build Version: 0.4.6 -->
<!-- Build Date Time: 2019-06-23 12:04 -->
<!-- DJ-beat @2019 Kevin T. Lee - Build Version: 0.4.8 -->
<!-- Build Date Time: 2019-06-23 22:28 -->

<fcpxml version="1.6">
<resources>
Expand Down

0 comments on commit 8e55ad4

Please sign in to comment.