@Caribsky
Wall of text, i have both outputs.
for path_to_ffmpeg.exe -re -i camera_stream_url test.mp4
PS C:UsersAdministrator> ffmpeg -rtsp_transport tcp -re -i rtsp://xxxx:xxx@192.168.1.194/live/ch00_0.h264 test.mp4
ffmpeg version N-90649-g9825f77ac7 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: —enable-gpl —enable-version3 —enable-sdl2 —enable-bzlib —enable-fontconfig —enable-gnutls —enabl
e-iconv —enable-libass —enable-libbluray —enable-libfreetype —enable-libmp3lame —enable-libopencore-amrnb —enable-
libopencore-amrwb —enable-libopenjpeg —enable-libopus —enable-libshine —enable-libsnappy —enable-libsoxr —enable-l
ibtheora —enable-libtwolame —enable-libvpx —enable-libwavpack —enable-libwebp —enable-libx264 —enable-libx265 —en
able-libxml2 —enable-libzimg —enable-lzma —enable-zlib —enable-gmp —enable-libvidstab —enable-libvorbis —enable-l
ibvo-amrwbenc —enable-libmysofa —enable-libspeex —enable-libxvid —enable-libaom —enable-libmfx —enable-amf —enabl
e-ffnvcodec —enable-cuvid —enable-d3d11va —enable-nvenc —enable-nvdec —enable-dxva2 —enable-avisynth
libavutil 56. 13.100 / 56. 13.100
libavcodec 58. 17.100 / 58. 17.100
libavformat 58. 11.101 / 58. 11.101
libavdevice 58. 2.100 / 58. 2.100
libavfilter 7. 14.100 / 7. 14.100
libswscale 5. 0.102 / 5. 0.102
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, rtsp, from ‘rtsp://xxxx:xxxx@192.168.1.194/live/ch00_0.h264’:
Metadata:
title : Easy Rtsp 1.0
comment : Easy
Duration: N/A, start: 0.201000, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1920×1080, 25 fps, 24.83 tbr, 90k tbn, 50 tbc
File ‘test.mp4’ already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000002594598c100] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000002594598c100] profile High, level 4.0
[libx264 @ 000002594598c100] 264 — core 155 r2901 7d0ff22 — H.264/MPEG-4 AVC codec — Copyleft 2003-2018 — http://www.vid
eolan.org/x264.html — options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed
ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookah
ead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b
adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahe
ad=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to ‘test.mp4’:
Metadata:
title : Easy Rtsp 1.0
comment : Easy
encoder : Lavf58.11.101
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920×1080, q=-1—1, 24.83 fps, 19072 tbn, 24.83 tbc
Metadata:
encoder : Lavc58.17.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 535 fps= 21 q=-1.0 Lsize= 1721kB time=00:00:21.42 bitrate= 658.1kbits/s dup=417 drop=5 speed=0.843x
video:1714kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.417623%
[libx264 @ 000002594598c100] frame I:3 Avg QP:14.64 size: 87054
[libx264 @ 000002594598c100] frame P:135 Avg QP:13.92 size: 6881
[libx264 @ 000002594598c100] frame B:397 Avg QP:20.88 size: 1421
[libx264 @ 000002594598c100] consecutive B-frames: 0.6% 1.1% 1.1% 97.2%
[libx264 @ 000002594598c100] mb I I16..4: 33.8% 59.0% 7.2%
[libx264 @ 000002594598c100] mb P I16..4: 2.0% 3.1% 0.1% P16..4: 14.1% 1.1% 1.4% 0.0% 0.0% skip:78.1%
[libx264 @ 000002594598c100] mb B I16..4: 0.1% 0.0% 0.0% B16..8: 7.4% 0.1% 0.0% direct: 1.1% skip:91.3% L0:47
.2% L1:52.3% BI: 0.4%
[libx264 @ 000002594598c100] 8×8 transform intra:57.5% inter:91.8%
[libx264 @ 000002594598c100] coded y,uvDC,uvAC intra: 26.9% 54.7% 24.0% inter: 1.7% 5.1% 0.1%
[libx264 @ 000002594598c100] i16 v,h,dc,p: 54% 18% 14% 14%
[libx264 @ 000002594598c100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 10% 46% 2% 2% 2% 1% 2% 1%
[libx264 @ 000002594598c100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 17% 24% 5% 5% 5% 7% 3% 3%
[libx264 @ 000002594598c100] i8c dc,h,v,p: 58% 21% 20% 2%
[libx264 @ 000002594598c100] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002594598c100] ref P L0: 69.4% 1.5% 20.0% 9.1%
[libx264 @ 000002594598c100] ref B L0: 76.0% 20.2% 3.8%
[libx264 @ 000002594598c100] ref B L1: 91.1% 8.9%
[libx264 @ 000002594598c100] kb/s:651.42
Exiting normally, received signal 2.
and for path_to_ffmpeg.exe -i camera_stream_url test.jpg
PS C:UsersAdministrator> ffmpeg -rtsp_transport tcp -i rtsp://xxxx:xxxx@192.168.1.194/live/ch00_0.h264 test.jpg
ffmpeg version N-90649-g9825f77ac7 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: —enable-gpl —enable-version3 —enable-sdl2 —enable-bzlib —enable-fontconfig —enable-gnutls —enabl
e-iconv —enable-libass —enable-libbluray —enable-libfreetype —enable-libmp3lame —enable-libopencore-amrnb —enable-
libopencore-amrwb —enable-libopenjpeg —enable-libopus —enable-libshine —enable-libsnappy —enable-libsoxr —enable-l
ibtheora —enable-libtwolame —enable-libvpx —enable-libwavpack —enable-libwebp —enable-libx264 —enable-libx265 —en
able-libxml2 —enable-libzimg —enable-lzma —enable-zlib —enable-gmp —enable-libvidstab —enable-libvorbis —enable-l
ibvo-amrwbenc —enable-libmysofa —enable-libspeex —enable-libxvid —enable-libaom —enable-libmfx —enable-amf —enabl
e-ffnvcodec —enable-cuvid —enable-d3d11va —enable-nvenc —enable-nvdec —enable-dxva2 —enable-avisynth
libavutil 56. 13.100 / 56. 13.100
libavcodec 58. 17.100 / 58. 17.100
libavformat 58. 11.101 / 58. 11.101
libavdevice 58. 2.100 / 58. 2.100
libavfilter 7. 14.100 / 7. 14.100
libswscale 5. 0.102 / 5. 0.102
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, rtsp, from ‘rtsp://xxxx:xxxx@192.168.1.194/live/ch00_0.h264’:
Metadata:
title : Easy Rtsp 1.0
comment : Easy
Duration: N/A, start: 0.201000, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1920×1080, 25 fps, 24.83 tbr, 90k tbn, 50 tbc
File ‘test.jpg’ already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0000021b1f3cb4c0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to ‘test.jpg’:
Metadata:
title : Easy Rtsp 1.0
comment : Easy
encoder : Lavf58.11.101
Stream #0:0: Video: mjpeg, yuvj420p(pc), 1920×1080, q=2-31, 200 kb/s, 24.83 fps, 24.83 tbn, 24.83 tbc
Metadata:
encoder : Lavc58.17.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[image2 @ 0000021b1d388980] Could not get frame filename number 2 from pattern ‘test.jpg’ (either set update or use a pa
ttern like %03d within the filename pattern)
av_interleaved_write_frame(): Invalid argument
frame= 2 fps=0.0 q=3.2 Lsize=N/A time=00:00:00.08 bitrate=N/A dup=0 drop=4 speed=0.286x
video:79kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
Фон
Я подключаю функцию firebase в node. Цель состоит в том, чтобы разобрать входящий аудиоклип до заданной длины. Использование ffmpeg и fluent-ffmpeg.
Проблема
Когда функция запускается в firebase, я получаю ошибку ENOENT, когда Fluent-Ffmpeg пытается получить доступ к двоичному файлу Ffmpeg.
Выходные данные отладки Firebase
Ошибка: {Ошибка: spawn ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg ENOENT at exports._errnoException (util.js: 1018: 11) в Process.ChildProcess._handle.onexit (internal / child_process.js: 193: 32) в onErrorNT (internal / child_process.js: 367: 16) в _combinedTickCallback (internal / process / next_tick.js: 80: 11) в process._tickDomainCallback (internal / process / next_tick.js: 128: 9) code : ‘ENOENT’, номер ошибки: ‘ENOENT’, системный вызов: ‘spawn ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg’, путь: ‘./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg ‘,
spawnargs: [‘ -formats ‘]}
Ожидаемый результат
Входящий файл загружается во временный каталог, обрезается и повторно загружается в хранилище firebase как обрезанный файл.
Окружающая среда
- клиент Mac / хранилище Firebase
- узел v8.1.0
- ffmpeg v3.2.2
- fluent-ffmpeg v2.1.2
Код [обновлен с учетом изменений в Свенскунганке. Сейчас работает]
const ffmpeg = require('fluent-ffmpeg');
const PREVIEW_PREFIX = 'preview_';
exports.generatePreviewClip = functions.storage.object('audioFiles').onChange(event => {
//console.log('Times this function has run: ', run++);
const object = event.data; // The Storage object.
const fileBucket = object.bucket; // The Storage bucket that contains the file.
const filePath = object.name; // File path in the bucket.
const contentType = object.contentType; // File content type.
const resourceState = object.resourceState; // The resourceState is 'exists' or 'not_exists' (for file/folder deletions).
const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.
// Exit if this is triggered on a file that is not an audio file.
if (!contentType.startsWith('audio/')) {
console.log('This is not an audio file.');
console.log('This is the file:', filePath);
return;
}
// Get the file name.
const fileName = path.basename(filePath);
console.log('Working with filename', fileName);
// Exit if the file is already an audio clip.
if (fileName.startsWith(PREVIEW_PREFIX)) {
console.log('Already a preview clip.');
return;
}
// Exit if this is a move or deletion event.
if (event.data.resourceState === 'not_exists') {
console.log('This is a deletion event.');
return;
}
// Exit if file exists but is not new and is only being triggered
// because of a metadata change.
if (resourceState === 'exists' && metageneration > 1) {
console.log('This is a metadata change event.');
return;
}
// Download file from bucket.
const bucket = gcs.bucket(fileBucket);
const tempFilePath = path.join(os.tmpdir(), fileName);
return bucket.file(filePath).download({
destination: tempFilePath
}).then(() => {
console.log('Audio file downloaded locally to temp directory', tempFilePath);
var ffmpegPath = require("ffmpeg-binaries").ffmpegPath();
var ffprobePath = require("ffmpeg-binaries").ffprobePath();
// Generate a croped file using ffmpeg.
var command = new ffmpeg(tempFilePath);
command.setFfmpegPath(ffmpegPath);
command.setFfprobePath(ffprobePath);
command
.setStartTime('00:00:03')
.setDuration('10')
.output(tempFilePath)
.on('end', function() {
console.log('Audio Crop Done Successfully');
})
.on('error', function(err)
{
console.log('Error:', err);
}).run();
}).then(() => {
console.log('Preview file created at', tempFilePath);
// We add a 'preview_' prefix to the audio file name. that's how it will appear in firebase.
const previewFileName = PREVIEW_PREFIX + fileName;
console.log('previewFileName is', previewFileName)
const previewFilePath = path.join(path.dirname(filePath), previewFileName);
console.log('previewFilePath is', previewFilePath);
// Uploading the preview file.
return bucket.upload(tempFilePath, {destination: previewFilePath});
// Once the file has been uploaded delete the local file to free up disk space.
}).then(() => fs.unlinkSync(tempFilePath));
// [END audio file generation]
});
Содержание и структура моего каталога ffmpeg-binaries / bin
-rwxrwxrwx 1 sherpa staff 24M Dec 10 2016 ffmpeg
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffmpeg.exe
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffplay.exe
-rwxrwxrwx 1 sherpa staff 24M Dec 10 2016 ffprobe
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffprobe.exe
-rwxrwxrwx 1 sherpa staff 22M Dec 10 2016 ffserver
Что я пробовал
- Я могу выполнить ffmpeg из командной строки
- sudo chmod -R u + x ffmpeg-binaries /
- ffmpeg установлен в глобальном пути
- used ffmpeg.exe binary in setFfmpegPath, got same result
- Error: { Error: spawn ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg.exe ENOENT
- played with numerous different setFfmpegPath path structures, e.g:
- ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg
- node_modules / ffmpeg-двоичные файлы / bin / ffmpeg
- ./Cloud/functions/node_modules/ffmpeg-binaries/bin/
Спасибо за любые предложения.
Background
I am wiring up a firebase function in node. Purpose is to parse an inbound audio clip to a set length. Using ffmpeg and fluent-ffmpeg.
Problem
When the function is triggered in firebase, I am getting ENOENT error when Fluent-Ffmpeg attempts to access the Ffmpeg binary
Firebase Debug Output
Error: { Error: spawn
./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: ‘ENOENT’, errno:
‘ENOENT’, syscall: ‘spawn
./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg’, path:
‘./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg’,
spawnargs: [ ‘-formats’ ] }
Expected Outcome
Inbound file is downloaded to a temp directory, cropped, and re-uploaded to firebase storage as the cropped file.
Environment
- mac client / firebase storage
- node v8.1.0
- ffmpeg v3.2.2
- fluent-ffmpeg v2.1.2
Code [Updated To Reflect Svenskunganka’s Change. Now Works]
const ffmpeg = require('fluent-ffmpeg');
const PREVIEW_PREFIX = 'preview_';
exports.generatePreviewClip = functions.storage.object('audioFiles').onChange(event => {
//console.log('Times this function has run: ', run++);
const object = event.data; // The Storage object.
const fileBucket = object.bucket; // The Storage bucket that contains the file.
const filePath = object.name; // File path in the bucket.
const contentType = object.contentType; // File content type.
const resourceState = object.resourceState; // The resourceState is 'exists' or 'not_exists' (for file/folder deletions).
const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.
// Exit if this is triggered on a file that is not an audio file.
if (!contentType.startsWith('audio/')) {
console.log('This is not an audio file.');
console.log('This is the file:', filePath);
return;
}
// Get the file name.
const fileName = path.basename(filePath);
console.log('Working with filename', fileName);
// Exit if the file is already an audio clip.
if (fileName.startsWith(PREVIEW_PREFIX)) {
console.log('Already a preview clip.');
return;
}
// Exit if this is a move or deletion event.
if (event.data.resourceState === 'not_exists') {
console.log('This is a deletion event.');
return;
}
// Exit if file exists but is not new and is only being triggered
// because of a metadata change.
if (resourceState === 'exists' && metageneration > 1) {
console.log('This is a metadata change event.');
return;
}
// Download file from bucket.
const bucket = gcs.bucket(fileBucket);
const tempFilePath = path.join(os.tmpdir(), fileName);
return bucket.file(filePath).download({
destination: tempFilePath
}).then(() => {
console.log('Audio file downloaded locally to temp directory', tempFilePath);
var ffmpegPath = require("ffmpeg-binaries").ffmpegPath();
var ffprobePath = require("ffmpeg-binaries").ffprobePath();
// Generate a croped file using ffmpeg.
var command = new ffmpeg(tempFilePath);
command.setFfmpegPath(ffmpegPath);
command.setFfprobePath(ffprobePath);
command
.setStartTime('00:00:03')
.setDuration('10')
.output(tempFilePath)
.on('end', function() {
console.log('Audio Crop Done Successfully');
})
.on('error', function(err)
{
console.log('Error:', err);
}).run();
}).then(() => {
console.log('Preview file created at', tempFilePath);
// We add a 'preview_' prefix to the audio file name. that's how it will appear in firebase.
const previewFileName = PREVIEW_PREFIX + fileName;
console.log('previewFileName is', previewFileName)
const previewFilePath = path.join(path.dirname(filePath), previewFileName);
console.log('previewFilePath is', previewFilePath);
// Uploading the preview file.
return bucket.upload(tempFilePath, {destination: previewFilePath});
// Once the file has been uploaded delete the local file to free up disk space.
}).then(() => fs.unlinkSync(tempFilePath));
// [END audio file generation]
});
Contents and Structure of my ffmpeg-binaries/bin Directory
-rwxrwxrwx 1 sherpa staff 24M Dec 10 2016 ffmpeg
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffmpeg.exe
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffplay.exe
-rwxrwxrwx 1 sherpa staff 24M Dec 10 2016 ffprobe
-rwxr--r-- 1 sherpa staff 35M Jan 12 2017 ffprobe.exe
-rwxrwxrwx 1 sherpa staff 22M Dec 10 2016 ffserver
Things I Have Tried
- I can execute ffmpeg from the command line
- sudo chmod -R u+x ffmpeg-binaries/
- ffmpeg set in global path
- used ffmpeg.exe binary in setFfmpegPath, got same result
- Error: { Error: spawn ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg.exe ENOENT
- played with numerous different setFfmpegPath path structures, e.g:
- ./Cloud/functions/node_modules/ffmpeg-binaries/bin/ffmpeg
- node_modules/ffmpeg-binaries/bin/ffmpeg
- ./Cloud/functions/node_modules/ffmpeg-binaries/bin/
Thanks for any suggestions.