
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (20)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Submit enhancements and plugins
13 avril 2011If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.
Sur d’autres sites (5765)
-
Install openCV with ffmpeg support on OS X
4 janvier 2017, par saulspatzI’m trying to install openCV with ffmpeg support on Yosemite. I had just successfully installed openCV, but video didn’t work properly, and I was advised to rebuild it with ffmpeg support. So, I installed ffmpeg with
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype -- with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265
Then I used the following script to run
cmake
:PYTHON3_DIR=`python3-config --prefix` # Get python 3 path
VIRTUAL_ENV=`python3-config --prefix`
FFMPEG_INCLUDE_DIR=/usr/local/Cellar/ffmpeg/3.2.2/include/
FFMPEG_LIB_DIR=/usr/local/Cellar/ffmpeg/3.2.2/lib/
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV \
-D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python3 \
-D PYTHON3_PACKAGES_PATH=$VIRTUAL_ENV/lib/python3.5/site-packages \
-D PYTHON3_INCLUDE_DIR=$VIRTUAL_ENV/include/python3.5m \
-D PYTHON3_LIBRARY=$PYTHON3_DIR/lib/libpython3.5m.dylib \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$VIRTUAL_ENV/lib/python3.5/site-packages/numpy/core/include/ \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D WITH_FFMPEG=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..This was the same script that I’d used before, with the addition of the two FFMPEG_ directories and the
-D WITH_FFMPEG=ON
flag. Now when I runmake
it fails with a bunch of errors relating to freeType.Scanning dependencies of target opencv_video
[ 24%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_KNN.cpp.o
[ 24%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/mappergradshift.cpp.o
[ 24%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix2.cpp.o
[ 25%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/mappergradsimilar.cpp.o
[ 25%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/mapperpyramid.cpp.o
[ 25%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/camshift.cpp.o
[ 25%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/mapprojec.cpp.o
[ 25%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/compat_video.cpp.o
[ 25%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/mapshift.cpp.o
[ 25%] Building CXX object modules/reg/CMakeFiles/opencv_reg.dir/src/precomp.cpp.o
[ 25%] Linking CXX shared library ../../lib/libopencv_reg.dylib
[ 25%] Built target opencv_reg
[ 25%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/ecc.cpp.o
[ 25%] Generating opencl_kernels_dnn.cpp, opencl_kernels_dnn.hpp
Scanning dependencies of target opencv_dnn
[ 25%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/attr_value.pb.cc.o
[ 25%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/function.pb.cc.o
[ 25%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/kalman.cpp.o
[ 25%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/lkpyramid.cpp.o
[ 25%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/graph.pb.cc.o
[ 26%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/optflowgf.cpp.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/op_def.pb.cc.o
[ 26%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/tvl1flow.cpp.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/tensor.pb.cc.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/tensor_shape.pb.cc.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/types.pb.cc.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/versions.pb.cc.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/caffe.pb.cc.o
[ 26%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/opencl_kernels_video.cpp.o
[ 26%] Linking CXX shared library ../../lib/libopencv_video.dylib
[ 26%] Built target opencv_video
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/blob.cpp.o
[ 26%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/caffe/caffe_importer.cpp.o
[ 27%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/caffe/caffe_io.cpp.o
[ 27%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/caffe/layer_loaders.cpp.o
[ 28%] Building CXX object modules/freetype/CMakeFiles/opencv_freetype.dir/src/freetype.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/dnn.cpp.o
[ 28%] Linking CXX shared library ../../lib/libopencv_freetype.dylib
Undefined symbols for architecture x86_64:
"_FT_Done_Face", referenced from:
cv::freetype::FreeType2Impl::~FreeType2Impl() in freetype.cpp.o
cv::freetype::FreeType2Impl::loadFontData(cv::String, int) in freetype.cpp.o
"_FT_Done_FreeType", referenced from:
cv::freetype::FreeType2Impl::~FreeType2Impl() in freetype.cpp.o
"_FT_Init_FreeType", referenced from:
cv::freetype::FreeType2Impl::FreeType2Impl() in freetype.cpp.o
cv::freetype::FreeType2Impl::FreeType2Impl() in freetype.cpp.o
cv::freetype::createFreeType2() in freetype.cpp.o
"_FT_Load_Glyph", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_FT_New_Face", referenced from:
cv::freetype::FreeType2Impl::loadFontData(cv::String, int) in freetype.cpp.o
"_FT_Outline_Decompose", referenced from:
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_FT_Outline_Transform", referenced from:
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_FT_Outline_Translate", referenced from:
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_FT_Render_Glyph", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
"_FT_Set_Pixel_Sizes", referenced from:
cv::freetype::FreeType2Impl::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, cv::Scalar_<double>, int, int, bool) in freetype.cpp.o
"_hb_buffer_add_utf8", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_hb_buffer_create", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_hb_buffer_destroy", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_hb_buffer_get_glyph_infos", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_hb_buffer_guess_segment_properties", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
"_hb_font_destroy", referenced from:
cv::freetype::FreeType2Impl::~FreeType2Impl() in freetype.cpp.o
cv::freetype::FreeType2Impl::loadFontData(cv::String, int) in freetype.cpp.o
"_hb_ft_font_create", referenced from:
cv::freetype::FreeType2Impl::loadFontData(cv::String, int) in freetype.cpp.o
"_hb_shape", referenced from:
cv::freetype::FreeType2Impl::putTextBitmapBlend(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextBitmapMono(cv::_InputOutputArray const&) in freetype.cpp.o
cv::freetype::FreeType2Impl::putTextOutline(cv::_InputOutputArray const&) in freetype.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_freetype.3.2.0.dylib] Error 1
make[1]: *** [modules/freetype/CMakeFiles/opencv_freetype.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/init.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/concat_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/convolution_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/crop_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/detection_output_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/elementwise_layers.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/eltwise_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/flatten_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/fully_connected_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/layers_common.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/lrn_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/mvn_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/normalize_bbox_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/op_blas.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/op_im2col.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/permute_layer.cpp.o
[ 28%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/pooling_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/prior_box_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/recurrent_layers.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/reshape_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/shift_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/slice_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/softmax_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/split_layer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/tensorflow/tf_importer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/tensorflow/tf_io.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THDiskFile.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THFile.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THGeneral.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/torch_importer.cpp.o
[ 29%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/opencl_kernels_dnn.cpp.o
[ 29%] Linking CXX shared library ../../lib/libopencv_dnn.dylib
[ 29%] Built target opencv_dnn
make: *** [all] Error 2
</double></int>I don’t have a clue what’s wrong. Any suggestions ?
-
Saying Goodbye To Old Machines
I recently sent a few old machines off for recycling. Both had relevance to the early days of the FATE testing effort. As is my custom, I photographed them (poorly, of course).
First, there’s the PowerPC-based Mac Mini I procured thanks to a Craigslist ad in late 2006. I had plans to develop automated FFmpeg building and testing and was already looking ahead toward testing multiple CPU architectures. Again, this was 2006 and PowerPC wasn’t completely on the outs yet– although Apple’s MacTel transition was in full swing, the entire new generation of video game consoles was based on PowerPC.
I remember trying to find a Mac Mini PPC on Craigslist. Many were to be found, but all asked more than the price of even a new Mac Mini Intel, always because the seller was leaving all of last year’s applications and perhaps including a monitor, neither of which I needed. Fortunately, I found this bare Mac Mini. Also fortunate was the fact that it was far easier to install Linux on it than the first PowerPC machine I owned.
After FATE operation transitioned away from me, I still kept the machine in service as an edge server and automated backup machine. That is, until the hard drive failed on reboot one day. Thus, when it was finally time to recycle the computer, I felt it necessary to disassemble the machine and remove the hard drive for possible salvage and then for destruction.
If you’ve ever attempted to upgrade or otherwise service this style of Mac Mini, you will no doubt recognize the pictured paint scraper tool as standard kit. I have had that tool since I first endeavored to upgrade the RAM to 1 GB from the standard 1/2 GB. Performing such activities on a Mac Mini is tedious, but only if you care about putting it back together afterwards.
The next machine is a bit older. I put it together nearly a decade ago, early in 2005. This machine’s original duty was “download agent”– this would be more specifically called a BitTorrent machine in modern tech parlance. Back then, I placed it on someone else’s woefully underutilized home broadband connection (with their permission, of course) when I was too cheap to upgrade from dialup.
This is a small form factor system from VIA that was clearly designed with home theater PC (HTPC) use cases in mind. It has a VIA C3 x86-compatible CPU (according to my notes, Centaur VIA Samuel 2 stepping 03, flags : fpu de tsc msr cx8 mtrr pge mmx 3dnow) and 128 MB of RAM (initially ; I upgraded it to 512 MB some years later, just for the sake of doing it). And then there was the 120 GB PATA HD for all that downloaded goodness.
I have specific memories of a time when my main computer at home wasn’t working correctly for one reason or another. Instead, I logged into this machine remotely via SSH to make several optimizations and fixes on FFmpeg’s VP3/Theora video decoder, all from the terminal, without being able to see the decoded images with my own eyes (which is why I insist that even blind people could work on video codecs).
By the time I got my own broadband, I had become inspired to attempt the automated build and test system for FFmpeg. This was the machine I used for prototyping early brainstorms of FATE. By the time I put a basic build/test system into place in early 2008, I had much faster computers that could build and test the project– obvious limitation of this machine is that it could take at least 1/2 hour to build the entire codebase, and that was the project from 8 years ago.
So the machine got stuffed in a closet somewhere along the line. The next time I pulled it out was in 2010 when I wanted to toy with Dreamcast programming once more (the machine appears in one of the photos in this post). This was the only machine I still owned which still had an RS-232 serial port (I didn’t know much about USB serial converters yet), plus it still had a bunch of pre-compiled DC homebrew binaries (I was having trouble getting the toolchain to work right).
The next time I dusted off this machine was late last year when I was trying some experiments with the Microsoft Xbox’s IDE drive (a photo in that post also shows the machine ; this thing shows up a lot on this blog). The VIA machine was the only machine I still owned which had 40-pin IDE connectors which was crucial to my experiment.
At this point, I was trying to make the machine more useful which meant replacing the ancient Gentoo Linux distribution as well as simply interacting with it via a keyboard and mouse. I have a long Evernote entry documenting a comedy of errors revolving around this little box. The interaction troubles were due to the fact that I didn’t have any PS/2 keyboards left and I couldn’t make a USB keyboard work with it. Diego was able to explain that I needed to flip a bit in the BIOS to address this which worked. As for upgrading the OS, I tried numerous Linux distributions large and small, mostly focusing on the small. None worked. I eventually learned that, while I was trying to use i686 distributions, this machine did not actually qualify as an i686 CPU ; installations usually booted but failed because the default kernel required the cmov instruction. I was advised to try i386 distros instead. My notes don’t indicate whether I had any luck on this front before I gave up and moved on.
I just made the connection that this VIA machine has two 40-pin IDE connectors which means that the thing was technically capable of supporting up to 4 IDE devices. Obviously, the computer couldn’t really accommodate that in terms of space or power. When I wanted to try installing a new OS, I needed take off the top and connect a rather bulky IDE CD-ROM drive. This computer’s casing was supposed to be able to support a slimline optical drive (perhaps like the type found in laptops), but I could never quite visualize how that was supposed to work, space-wise. When I disassembled the PowerPC Mac Mini, I realized I might be able to repurpose that machines optical drive for this computer. Obviously, I thought better of trying since both machines are off to the recycle pile.
I would still like to work on the Xbox project a bit more, but I procured a different, unused, much more powerful yet still old computer that has a motherboard with 1 PATA connector in addition to 6 SATA connectors. If I ever get around to toying with Linux kernel development, this should be a much more appropriate platform to use.
I thought about turning this machine into an old Windows XP (and lower, down to Windows 3.1) gaming platform ; the capabilities of the machine would probably be perfect for a huge portion of my Windows game collection. But I think the lack of an optical drive renders this idea intractable. External USB drives are likely out of the question since there is very little chance that this motherboard featured USB 2.0 (the specs don’t mention 2.0, so the USB ports are probably 1.1).
So it is with fond memories that I send off both machines, sans hard drives, to the recycle pile. I’m still deciding on an appropriate course of action for failed hard drives, though.
-
Unable to transfer continuous FFmpeg buffer to client browser using node.js
10 décembre 2016, par chintitomasudI have tried to process a Video file transcoding on demand by using FFmpeg to transfer the chunk(buffer) to the client browser as mp4 format but I failed to show the mp4 content on html5 video player . Without using ffmpeg all code run properly . I have replaced createReadSteam with ffmpeg . Using it I have faced some problems. FFmpeg is new to me and I ’m kind of confused with spawn method. When I post a url path it shows the following text on the command line
Spawning new process /samiul113039/1080.mp4:GET
piping ffmpeg output to client, pid 10016
HTTP connection disrupted, killing ffmpeg : 10016
Spawning new process /samiul113039/1080.mp4:GET
piping ffmpeg output to client, pid 4796
HTTP connection disrupted, killing ffmpeg : 4796
ffmpeg didn’t quit on q, sending signals ffmpeg has exited : 10016,
code null ffmpeg didn’t quit on q, sending signals ffmpeg has exited :
4796, code nul=
var fs=require('fs');
var url=require("url");
var urlvalue="http://csestudents.uiu.ac.bd/samiul113039/1080.mp4";
var parseurl=url.parse(urlvalue);
var HDHomeRunIP = parseurl.hostname;
var HDHomeRunPort = parseurl.port;
var childKillTimeoutMs = 1000;
var parseArgs = require('minimist')(process.argv.slice(2));
// define startsWith for string
if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str){
return this.indexOf(str) == 0;
};
}
// Called when the response object fires the 'close' handler, kills ffmpeg
function responseCloseHandler(command) {
if (command.exited != true) {
console.log('HTTP connection disrupted, killing ffmpeg: ' + command.pid);
// Send a 'q' which signals ffmpeg to quit.
// Then wait half a second, send a nice signal, wait another half second
// and send SIGKILL
command.stdin.write('q\n');
command.stdin.destroy();
// install timeout and wait
setTimeout(function() {
if (command.exited != true) {
console.log('ffmpeg didn\'t quit on q, sending signals');
// still connected, do safe sig kills
command.kill();
try {
command.kill('SIGQUIT');
} catch (err) {}
try {
command.kill('SIGINT');
} catch (err) {}
// wait some more!
setTimeout(function() {
if (command.exited != true) {
console.log('ffmpeg didn\'t quit on signals, sending SIGKILL');
// at this point, just give up and whack it
try {
command.kill('SIGKILL');
} catch (err) {}
}
}, childKillTimeoutMs);
}
}, childKillTimeoutMs);
}
}
// Performs a proxy. Copies data from proxy_request into response
function doProxy(request,response,http,options) {
var proxy_request = http.request(options, function (proxy_response) {
proxy_response.on('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.on('end', function() {
response.end();
});
response.writeHead(proxy_response.statusCode, proxy_response.headers);
});
request.on('data', function(chunk) {
proxy_request.write(chunk, 'binary');
});
// error handler
proxy_request.on('error', function(e) {
console.log('problem with request: ' + e.message);
response.writeHeader(500);
response.end();
});
proxy_request.end();
}
var child_process = require('child_process');
var auth = require('./auth');
// Performs the transcoding after the URL is validated
function doTranscode(request,response) {
//res.setHeader("Accept-Ranges", "bytes");
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("Content-Type", "video/mp4");
response.setHeader("Connection","close");
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
// always write the header
response.writeHeader(200);
// if get, spawn command stream it
if (request.method == 'GET') {
console.log('Spawning new process ' + request.url + ":" + request.method);
var command = child_process.spawn('ffmpeg',
['-i','http://csestudents.uiu.ac.bd/samiul113039/1080.mp4','-f','mpegts','-'],
{ stdio: ['pipe','pipe','ignore'] });
command.exited = false;
// handler for when ffmpeg dies unexpectedly
command.on('exit',function(code,signal) {
console.log('ffmpeg has exited: ' + command.pid + ", code " + code);
// set flag saying we've quit
command.exited = true;
response.end();
});
command.on('error',function(error) {
console.log('ffmpeg error handler - unable to kill: ' + command.pid);
// on well, might as well give up
command.exited = true;
try {
command.stdin.close();
} catch (err) {}
try {
command.stdout.close();
} catch (err) {}
try {
command.stderr.close();
} catch (err) {}
response.end();
});
// handler for when client closes the URL connection - stop ffmpeg
response.on('end',function() {
responseCloseHandler(command);
});
// handler for when client closes the URL connection - stop ffmpeg
response.on('close',function() {
responseCloseHandler(command);
});
// now stream
console.log('piping ffmpeg output to client, pid ' + command.pid);
command.stdout.pipe(response);
command.stdin.on('error',function(err) {
console.log("Weird error in stdin pipe ", err);
response.end();
});
command.stdout.on('error',function(err) {
console.log("Weird error in stdout pipe ",err);
response.end();
});
}
else {
// not GET, so close response
response.end();
}
}
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
//console.log("New connection from " + request.socket.remoteAddress + ":" + request.url);
if (auth.validate(request,response)) {
// first send a HEAD request to our HD Home Run with the same url to see if the address is valid.
// This prevents an ffmpeg instance to spawn when clients request invalid things - like robots.txt/etc
var options = {method: 'HEAD', hostname: HDHomeRunIP, port: HDHomeRunPort, path: request.url};
var req = http.request(options, function(res) {
// if they do a get, and it returns good status
if (request.method == "GET" &&
res.statusCode == 200 &&
res.headers["content-type"] != null &&
res.headers["content-type"].startsWith("video")) {
// transcode is possible, start it now!
doTranscode(request,response);
}
else {
// no video or error, cannot transcode, just forward the response from the HD Home run to the client
if (request.method == "HEAD") {
response.writeHead(res.statusCode,res.headers);
response.end();
}
else {
// do a 301 redirect and have the device response directly
// just proxy it, that way browser doesn't redirect to HDHomeRun IP but keeps the node.js server IP
options = {method: request.method, hostname: HDHomeRunIP, /* port: HDHomeRunPort, */path: request.url};
doProxy(request,response,http,options);
}
}
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
response.writeHeader(500);
response.end();
});
// finish the client request, rest of processing done in the async callbacks
req.end();
}
});
// turn on no delay for tcp
server.on('connection', function (socket) {
socket.setNoDelay(true);
});
server.listen(7000);stdio : [’pipe’,’pipe’,’ignore’]
Actually the code was written by someone. i have just modified the code.
[’pipe’,’pipe’,’ignore’] what does pipe,pipe.ignore mean here,