trim silence option
This commit is contained in:
parent
e8de0c9c73
commit
3c18adee84
6 changed files with 49 additions and 21 deletions
|
@ -23,7 +23,8 @@ var audioFormats = [
|
|||
expressManager.app.get("/download", async (req, res) => {
|
||||
var url = req.query.url,
|
||||
quality = req.query.quality,
|
||||
format = req.query.format
|
||||
format = req.query.format,
|
||||
trimAudio = req.query.trimAudio && audioFormats.includes(format) || false
|
||||
|
||||
if (ytdl.validateURL(url) && qualityLabels.includes(quality)) {
|
||||
var needsVideo = !audioFormats.includes(format)
|
||||
|
@ -83,12 +84,18 @@ expressManager.app.get("/download", async (req, res) => {
|
|||
'-map', '0:a'
|
||||
]
|
||||
|
||||
var bonusArgs = []
|
||||
|
||||
if (needsVideo) {
|
||||
inputArgs = inputArgs.concat(['-i', 'pipe:5'])
|
||||
mapArgs = mapArgs.concat(['-map', '1:v'])
|
||||
}
|
||||
|
||||
var args = inputArgs.concat(mapArgs).concat(baseArgs)
|
||||
if (trimAudio) {
|
||||
bonusArgs = bonusArgs.concat(['-af', 'silenceremove=1:0:-50dB'])
|
||||
}
|
||||
|
||||
var args = inputArgs.concat(mapArgs).concat(bonusArgs).concat(baseArgs)
|
||||
|
||||
const ffmpegProcess = cp.spawn(ffmpeg, args, {
|
||||
windowsHide: true,
|
||||
|
|
18
package-lock.json
generated
18
package-lock.json
generated
|
@ -1,15 +1,15 @@
|
|||
{
|
||||
"name": "univerter",
|
||||
"version": "3.2.0",
|
||||
"version": "4.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "univerter",
|
||||
"version": "3.2.0",
|
||||
"version": "4.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@distube/ytdl-core": "^4.13.5",
|
||||
"@distube/ytdl-core": "^4.13.7",
|
||||
"child_process": "^1.0.2",
|
||||
"express": "^4.18.2",
|
||||
"ffmpeg-static": "^5.2.0"
|
||||
|
@ -30,9 +30,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@distube/ytdl-core": {
|
||||
"version": "4.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.5.tgz",
|
||||
"integrity": "sha512-g+4UJIR/auAJbia7iB0aWvaJDbs22P53NySWa47b1NT4xMTDJYguxHFArPrvRkcJrb/AgKjv/XoSZGghpL0CJA==",
|
||||
"version": "4.13.7",
|
||||
"resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.7.tgz",
|
||||
"integrity": "sha512-xpovwZVPwQ0R4Mrwt/fhh1rqmBjiZ5qj30ck5kz+mQJ5XPzW9dUiTDz89qCxO3YvgbCAqaC5BNNnWiFC2uCV5Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"http-cookie-agent": "^6.0.5",
|
||||
|
@ -970,9 +970,9 @@
|
|||
}
|
||||
},
|
||||
"@distube/ytdl-core": {
|
||||
"version": "4.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.5.tgz",
|
||||
"integrity": "sha512-g+4UJIR/auAJbia7iB0aWvaJDbs22P53NySWa47b1NT4xMTDJYguxHFArPrvRkcJrb/AgKjv/XoSZGghpL0CJA==",
|
||||
"version": "4.13.7",
|
||||
"resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.7.tgz",
|
||||
"integrity": "sha512-xpovwZVPwQ0R4Mrwt/fhh1rqmBjiZ5qj30ck5kz+mQJ5XPzW9dUiTDz89qCxO3YvgbCAqaC5BNNnWiFC2uCV5Q==",
|
||||
"requires": {
|
||||
"http-cookie-agent": "^6.0.5",
|
||||
"m3u8stream": "^0.8.6",
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/Violets-puragtory/YoutubeConverter#readme",
|
||||
"dependencies": {
|
||||
"@distube/ytdl-core": "^4.13.5",
|
||||
"@distube/ytdl-core": "^4.13.7",
|
||||
"child_process": "^1.0.2",
|
||||
"express": "^4.18.2",
|
||||
"ffmpeg-static": "^5.2.0"
|
||||
|
|
|
@ -56,14 +56,18 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
<!-- <input style="display: inline-block" type="checkbox" id="adv"> -->
|
||||
<!-- <p style="display: inline-block" for="adv">Enable Advanced options? (Beta)</p> -->
|
||||
<div id="audioOnly">
|
||||
<input style="display: inline-block" type="checkbox" id="trim" name="trimAudio">
|
||||
<p style="display: inline-block" for="trim">Trim Silence (mp3)</p>
|
||||
</div>
|
||||
<div id="videoAndAudio">
|
||||
<!-- <input style="display: inline-block" type="checkbox" id="trim" checked>
|
||||
<p style="display: inline-block" for="trim">Trim BALLS (mp4 only)</p> -->
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
<br>
|
||||
<!-- <br> -->
|
||||
|
||||
<p>Inspired by <a href="https://cobalt.tools">Cobalt</a></p>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
var audioFormats = ["mp3"]
|
||||
|
||||
function updateOptions() {
|
||||
var format = $("#format").val()
|
||||
if (audioFormats.includes(format)) {
|
||||
$("#audioOnly > input").attr("disabled", false)
|
||||
$("#videoAndAudio > input").attr("disabled", true)
|
||||
} else {
|
||||
$("#audioOnly > input").attr("disabled", true)
|
||||
$("#videoAndAudio > input").attr("disabled", false)
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
updateOptions()
|
||||
$("#format").on("change", updateOptions)
|
||||
|
||||
$("#quality").val(Cookies.get("quality") || "720")
|
||||
$("#trim").prop("checked", Cookies.get("trim") == "true" || false)
|
||||
$("form").submit(() => {
|
||||
Cookies.set("quality", $("#quality").val())
|
||||
// $("#url").val("")
|
||||
Cookies.set("trim", $("#trim").prop("checked"))
|
||||
})
|
||||
})
|
|
@ -131,10 +131,10 @@ option {
|
|||
background-color: rgba(0, 0, 20);
|
||||
}
|
||||
|
||||
#adv {
|
||||
input[type="checkbox"] {
|
||||
accent-color: var(--primary-color);
|
||||
width: 1.15rem;
|
||||
height: 1.15rem;
|
||||
width: 1.05rem;
|
||||
height: 1.05rem;
|
||||
}
|
||||
|
||||
.error {
|
||||
|
|
Loading…
Reference in a new issue