
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Sur d’autres sites (1907)
-
Unhandled stream error in pipe : write EPIPE in Node.js
28 novembre 2013, par Michael RomanenkoThe idea is to serve screenshots of RTSP video stream with Express.js server. There is a continuously running spawned openRTSP process in flowing mode (it's stdout is consumed by another ffmpeg process) :
function spawnProcesses (camera) {
var openRTSP = spawn('openRTSP', ['-c', '-v', '-t', camera.rtsp_url]),
encoder = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vcodec', 'libvpx', '-r', 10, '-f', 'webm', 'pipe:1']);
openRTSP.stdout.pipe(encoder.stdin);
openRTSP.on('close', function (code) {
if (code !== 0) {
console.log('Encoder process exited with code ' + code);
}
});
encoder.on('close', function (code) {
if (code !== 0) {
console.log('Encoder process exited with code ' + code);
}
});
return { rtsp: openRTSP, encoder: encoder };
}
...
camera.proc = spawnProcesses(camera);There is an Express server with single route :
app.get('/cameras/:id.jpg', function(req, res){
var camera = _.find(cameras, {id: parseInt(req.params.id, 10)});
if (camera) {
res.set({'Content-Type': 'image/jpeg'});
var ffmpeg = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vframes', '1', '-s', '800x600', '-f', 'image2', 'pipe:1']);
camera.proc.rtsp.stdout.pipe(ffmpeg.stdin);
ffmpeg.stdout.pipe(res);
} else {
res.status(404).send('Not found');
}
});
app.listen(3333);When i request
http://localhost:3333/cameras/1.jpg
i get desired image, but from time to time app breaks with error :stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: write EPIPE
at errnoException (net.js:901:11)
at Object.afterWrite (net.js:718:19)Strange thing is that sometimes it successfully streams image to
res
stream and closes child process without any error, but, sometimes, streams image and falls down.I tried to create
on('error', ...)
event handlers on every possible stream, tried to changepipe(...)
calls toon('data',...)
constructions, but could not succeed.My environment : node v0.10.22, OSX Mavericks 10.9.
UPDATE :
I wrapped
spawn('ffmpeg',...
block with try-catch :app.get('/cameras/:id.jpg', function(req, res){
....
try {
var ffmpeg = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vframes', '1', '-s', '800x600', '-f', 'image2', 'pipe:1']);
camera.proc.rtsp.stdout.pipe(ffmpeg.stdin);
ffmpeg.stdout.pipe(res);
} catch (e) {
console.log("Gotcha!", e);
}
....
});... and this error disappeared, but log is silent, it doesn't catch any errors. What's wrong ?
-
Variable size for ffmpeg filter
15 novembre 2013, par DrakaSANI am creating a bunch of script to easily use ffmpeg.
All my scripts now work, but a lot of value are hardcoded, which make them wanting exact size for the video (854x240, size of my tests videos)
A good example is better than long explanation :
ffmpeg -i 0.mp4 -vf "
scale=854/2:-1 [low];
color=c=black@1.0:s=854x240:r=29.97:d=30.0 [bg];
movie=1.mp4, scale=854/2:-1 [high];
[bg][high] overlay=0:0 [bgh];
[bgh][low] overlay=854/2:-1" leftright.mp4It take 0.mp4 and 1.mp4 and put them side by side in the same video. But the dimension value are hardcoded. But it work.
I know I can use iw and ih as "input width" and "input height" for the first scale filter, but when I try to put anything else as dimension for the color background, it just throw me a error :
Unable to parse option value "iw:ih" as image size
Unable to parse option value "iw:240" as image size
Unable to parse option value "860*2:240" as image sizeand I end up to put 1720x240 again, which is really bad.
Is there a way to bypass this, or to put input-dependent value ?
Edit :
Starting with video 1.mp4 (854x240) and 2.mp4 (520x520) (example value), put them side by side in out.mp4 (which in this case will have the dimension max(height)x(2xmax(width)), so in this case 854x1040), with black background.
ax
<---->
.____.^
| ||
| 1 ||
| ||ay
| ||
|____|V
bx
<-------->
.________.^
| 2 ||by
|________|VWill end up as
ay>ax
bx>by
bx bx
<--------><-------->
xx.____.xxxxxxxxxxxx^
xx| |xxxxxxxxxxxx|
xx| 1 |xx.________.|
xx| |xx| 2 ||ay
xx| |xx|________||
xx|____|xxxxxxxxxxxxV -
using overlay video filter in ffmpeg guardian project (android)
29 juillet 2016, par Blaze TamaFirst, im a beginner in FFMPEG so please bear with me.
Im using this library and successfully combined an audio and a video :D
However, i keep failing when i tried to insert an image/watermark over a video.
This is the code im using :
public MediaDesc combineVideoAndImage (MediaDesc videoIn, MediaDesc image, MediaDesc out, ShellCallback sc) throws Exception
{
ArrayList<string> cmd = new ArrayList<string>();
cmd.add(ffmpegBin);
cmd.add("-i");
cmd.add(new File(videoIn.path).getCanonicalPath());
cmd.add("-vf");
cmd.add("movie=" + new File(image.path).getAbsolutePath() + " [logo];[in][logo] overlay=10:10 [out]");
cmd.add("-strict");
cmd.add("-2");
File fileOut = new File(out.path);
cmd.add(fileOut.getCanonicalPath());
execFFMPEG(cmd, sc);
return out;
}
</string></string>Those code will generate this cmd :
ffmpeg -i VIDEONAME.mp4 -vf "movie=LOGONAME.png [logo];[in][logo] overlay=10:10 [out]"
-strict -2 OUTPUTNAME.MP4I have tested this CMD on ubuntu 13.10 64bit, with latest FFMPEG installed and t succeed.
But it does not in my android project. It does not catch/throw any error/exception, the program running normally and the file is created but has nothing in it (0 byte)
Any help is appreciated. Thanks for your help :D