Used in FFmpeg Nodejs

Source: Internet
Author: User

1. Get to the push stream address
2. Go to cmd, enter command ffmpeg-re-i xxxxx.flv-c copy-f flv "Xxxxurl"
which
xxxxx.flv for local video files, Sioeye push stream needs to be compliant with video H264, audio ACC Code
"Xxxxxrul" is the push-stream address

////////////////////////////////////////////////////////////////////////////////

Used in Ffmpe Nodejs

var exec = require (' child_process '). exec;
var Ffmpeg = require (' fluent-ffmpeg ');
var config = require ('.. /config ')
Module.exports = {
function Generattsfile (activity,sourcefile) {
var source
var commandstr = ' ffmpeg-i ';
Commandstr + = config.videodirectory + videofile;
Commandstr + = '-y-vcodec copy-acodec copy-map 0-f segment-segment_list ';
Commandstr +=+ config.videodirectory + "
var commandstr = ' ffmpeg-i d:/desktop/testfile/1.flv-y-vcodec copy-acodec copy-map 0-f segment-segment_list D:/des Ktop/testfile/test1.m3u8-segment_time D:/desktop/testfile/test-%03d.ts '

var command = Ffmpeg (' d:/desktop/testfile/454224124c08470a90a9eaa0b3cb885a/123224124c08470a90a9eaa0b3cb6666/ Sourcevideo/1080p_3_2.mp4 ')
. Save (' d:/desktop/testfile/454224124c08470a90a9eaa0b3cb885a/123224124c08470a90a9eaa0b3cb6666/ts/1080p_3_2-%0 3d.ts ')
. outputoptions ([
'-y ',
'-vcodec copy ',
'-acodec copy ',
'-map 0 ',
'-F segment ',
'-segment_list d:/desktop/testfile/454224124c08470a90a9eaa0b3cb885a/123224124c08470a90a9eaa0b3cb6666/ Sourcevideo/1080p_3_2.m3u8 ',
'-segment_time 10 ']
)

. Takescreenshots ({timemarks: [' 00:00:02.000 '],
Size: ' 150x100 ',
FileName: ' thumbnail-at-%s-%00i-seconds.jpg '
// }
, ' D:/desktop/testfile ');

Command
. On (' Progress ', function (info) {
Console.log (' progress ' + info.percent + '% ');
})
. On (' Filenames ', function (filenames) {
Console.log (' screenshots is ' + filenames.join (', '));
})
. On (' Error ', function (err) {
Console.log (' An error occurred: ' + err.message);
})
. On (' End ', function () {
Console.log (' merging finished! ');
})
}

var num = 0;
function Generateimage (i) {

Console.log (i,num++);
var commandstr = ' ffmpeg-i d:/desktop/testfile/1.mp4-f image2-vf fps=fps=1/2-q:v 0 d:/desktop/testfile/test-%02d.jp G ';

var command = Ffmpeg (' d:/desktop/testfile/454224124c08470a90a9eaa0b3cb885a/123224124c08470a90a9eaa0b3cb6666/ts/ 1080p_3_2-' +i+ '. ts ')
. Save (' d:/desktop/testfile/454224124c08470a90a9eaa0b3cb885a/123224124c08470a90a9eaa0b3cb6666/thumbnailtmp/ 1080p_3_2-' +i+ '-%02d.jpg ')
. outputoptions ([
'-y ',
'-F image2 ',
'-vf fps=fps=1/2 ',
'-q:v 0 '
])
. Videofilter (' FPS=FPS=1/2 ')
. takescreenshots ({
Timemarks: [' 00:00:02.000 '],
Size: ' 150x100 ',
FileName: ' thumbnail-at-%s-%00i-seconds.jpg '
// }
, ' D:/desktop/testfile ');

Command
. On (' Progress ', function (info) {
Console.log (' progress ' + info.percent + '% ');
})
. On (' Filenames ', function (filenames) {
Console.log (' screenshots is ' + filenames.join (', '));
})
. On (' Error ', function (err) {
Console.log (' An error occurred: ' + err.message);
})
. On (' End ', function () {
Console.log (' merging finished! ');
})


}
Generattsfile ()



//
var count = 0;
function Generate () {
SetTimeout (function () {

var str = count.tostring (). length = = 1? ' xx ' +count: ' 0 ' +count;
Generateimage (str)
Count + +;
Console.log (COUNT,STR);
if (count<32)
Generate ();

},10000)
}

Generate ();





Slice Create picture
var exec = require (' child_process '). exec;
var commandstr = ' ffmpeg-i d:/desktop/testfile/1.mp4-f image2-vf fps=fps=1/2 d:/desktop/testfile/test-%02d.jpg& Exit ';
var time = new Date ();
EXEC (Commandstr,function (err,data,data1) {
Console.log (New Date ()-time);
// })


var tsstr = ' ffmpeg-i d:/desktop/testfile/1.mp4-c:v libx264-c:a aac-strict-2-F HLS output.m3u8 ';
//
Generate slices
var generaltsstr = ' ffmpeg-i d:/desktop/testfile/1.flv-y-vcodec copy-acodec copy-map 0-f segment-segment_list D :/desktop/testfile/test1.m3u8-segment_time d:/desktop/testfile/test-%03d.ts '
//
var time = new Date ();
EXEC (generaltsstr,function (Error, stdout, stderr) {
Console.log (New Date ()-time);
// })

var spawn = require (' child_process '). Spawn;

Set the path to where FFmpeg is installed
Proc.setffmpegpath ("D:\\ffmpeg-3.0\\vs2013_build\\bin\\ffmpeg.exe"); I forgot to include "Ffmpeg.exe"


FFmpeg (' D:/desktop/testfile/1.mp4 ')
. Videocodec (' libx264 ')
. Audiocodec (' Libmp3lame ')
. Size (' + + ')
. On (' Error ', function (err) {
Console.log (' An error occurred: ' + err.message);
// })
. On (' End ', function () {
Console.log (' processing finished! ');
// })
. Save (' D:/desktop/testfile/output.mp4 ');

FFmpeg (' D:/desktop/testfile/1.mp4 ')
. On (' stderr ', function (stderrline) {
Console.log (' Stderr output: ' + stderrline);
// })
. On (' Progress ', function (progress) {
Console.log (' Processing: ' + progress.percent + '% done ');
// })
. On (' Error ', function (err, stdout, stderr) {
Console.log (' Cannot process video: ' + err.message);
// })
. On (' End ', function (stdout, stderr) {
Console.log (' transcoding succeeded! ');
// });;;

var command = ffmpeg (' D:/desktop/testfile/1.mp4 ')
. Audiocodec (' LIBFAAC ')
. Videocodec (' libx264 ')
. Format (' mp4 ');
//
Command.clone ()
. Size (' 320x200 ')
. Save (' D:/desktop/testfile/11.mp4 ');


FFmpeg (' D:/desktop/testfile/1.mp4 ')
. Screenshots ({
Timestamps: [30.5, ' 50% ', ' 00:10.123 '],
FileName: ' Thumbnail-at-%s-seconds.png ',
Folder: ' D:/desktop/testfile/output ',
Size: ' + + '
// });
// //

Used in FFmpeg Nodejs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.