Skip to content

Commit a76f652

Browse files
authored
* Fixed the way to throw an exception when we open the file in the Concat media.
1 parent fe47ab7 commit a76f652

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/FFMpeg/Media/Concat.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,24 @@ public function saveFromSameCodecs($outputPathfile, $streamCopy = TRUE)
9191
$sourcesFile = $fs->createTemporaryFile('ffmpeg-concat');
9292

9393
// Set the content of this file
94-
$fileStream = fopen($sourcesFile, 'w') or die("Cannot open file.");
94+
$fileStream = @fopen($sourcesFile, 'w');
95+
96+
if($fileStream === false) {
97+
throw new ExecutionFailureException('Cannot open the temporary file.');
98+
}
99+
95100
$count_videos = 0;
96101
if(is_array($this->sources) && (count($this->sources) > 0)) {
97102
foreach ($this->sources as $videoPath) {
98103
$line = "";
99-
104+
100105
if($count_videos != 0)
101106
$line .= "\n";
102-
107+
103108
$line .= "file ".$videoPath;
104-
109+
105110
fwrite($fileStream, $line);
106-
111+
107112
$count_videos++;
108113
}
109114
}
@@ -193,7 +198,7 @@ public function saveFromDifferentCodecs(FormatInterface $format, $outputPathfile
193198
$complex_filter .= '['.$i.':v:0] ['.$i.':a:0] ';
194199
}
195200
$complex_filter .= 'concat=n='.$nbSources.':v=1:a=1 [v] [a]';
196-
201+
197202
$commands[] = $complex_filter;
198203
$commands[] = '-map';
199204
$commands[] = '[v]';

0 commit comments

Comments
 (0)