Skip to content

Commit d00c8ab

Browse files
committed
fix ffmpeg crash.
1 parent b9d4bab commit d00c8ab

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "gonwan <gonwan@gmail.com>",
55
"license": "Apache-2.0",
66
"homepage": "https://github.com/gonwan/m3u8-downloader",
7-
"version": "0.8.1",
7+
"version": "0.8.2",
88
"type": "module",
99
"private": true,
1010
"main": "dist-electron/main.js",

src/views/HomeView.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ const onGo = async () => {
8282
return;
8383
}
8484
localStorage.setItem('md.downloadFilePath', form.downloadFilePath);
85-
let downloadFilePath = await window.$electron.checkFileExists(form.downloadFilePath);
86-
if (downloadFilePath !== form.downloadFilePath) {
85+
/*
86+
* Use unbind value, or ffmpeg crashes after changing the file path.
87+
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/861
88+
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/1316
89+
*/
90+
let formDownloadFilePath = form.downloadFilePath;
91+
let downloadFilePath = await window.$electron.checkFileExists(formDownloadFilePath);
92+
if (downloadFilePath !== formDownloadFilePath) {
8793
ElMessage({
8894
type: 'warning',
8995
dangerouslyUseHTMLString: true,
@@ -118,7 +124,7 @@ const onGo = async () => {
118124
break;
119125
}
120126
/* check playlist */
121-
let videoInfo = await window.$electron.m3u8CheckPlaylist(form.m3u8Url, form.downloadFilePath, downloadOptions);
127+
let videoInfo = await window.$electron.m3u8CheckPlaylist(form.m3u8Url, formDownloadFilePath, downloadOptions);
122128
let videoUrl = '';
123129
let videoCodecs = '';
124130
let audioUrl = '';
@@ -152,7 +158,7 @@ const onGo = async () => {
152158
let videoPartFiles: string[] = [];
153159
let audioPartFiles: string[] = [];
154160
if (videoUrl !== '') {
155-
let prom = window.$electron.m3u8Download(videoUrl, form.downloadFilePath, downloadOptions, true, (audioUrl === ''));
161+
let prom = window.$electron.m3u8Download(videoUrl, formDownloadFilePath, downloadOptions, true, (audioUrl === ''));
156162
startPollingTimer(true);
157163
let res = await prom;
158164
if (res instanceof Error) {
@@ -164,7 +170,7 @@ const onGo = async () => {
164170
}
165171
/* download audio */
166172
if (!isCancelDownloading.value && audioUrl !== '') {
167-
let prom = window.$electron.m3u8Download(audioUrl, form.downloadFilePath, downloadOptions, false, false);
173+
let prom = window.$electron.m3u8Download(audioUrl, formDownloadFilePath, downloadOptions, false, false);
168174
startPollingTimer(false);
169175
let res = await prom;
170176
if (res instanceof Error) {
@@ -179,8 +185,8 @@ const onGo = async () => {
179185
/* concat all */
180186
if (!isCancelDownloading.value && videoPartFiles.length > 0) {
181187
downloadSpeed.value = 'Running ffmpeg concat...';
182-
let dot = form.downloadFilePath.lastIndexOf('.');
183-
let workingDir = (dot == -1) ? form.downloadFilePath : form.downloadFilePath.slice(0, dot);
188+
let dot = formDownloadFilePath.lastIndexOf('.');
189+
let workingDir = (dot == -1) ? formDownloadFilePath : formDownloadFilePath.slice(0, dot);
184190
let res = await window.$electron.m3u8ConcatStreams(
185191
videoPartFiles, audioPartFiles ?? [], downloadFilePath, workingDir, downloadOptions, videoCodecs);
186192
if (res instanceof Error) {

0 commit comments

Comments
 (0)