
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (27)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...) -
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" (...)
Sur d’autres sites (3400)
-
ffmpeg exit code 429496724 when opening file with {} in name
16 février, par Holly WilsonI'm trying to write a program that will read the names of files in a directory, and parse them for info which it will then write into that file's metadata (seems pointless, I know, but it's more of a trial run for a larger project. If I can figure this out, then I'll be ready to move on to what I actually want to do).
All of my filenames are formatted :


Title, Article* - Subtitle* Cut* [Year]
*if present


The four test videos I'm using are titled :


Test Video 1 [2000]


Test Video 2, A [2000]


Test Video 3 Test Cut [2000]


Test Video 4 - The Testening [2000]


The code seems to be working fine on videos 1, 2, & 4 ; but video 3 is causing me a lot of headache.


//node C:\Users\User\Documents\Coding\Tools\testMDG.js
const fs = require('fs');
const path = require('path');
const ffmpeg = require('fluent-ffmpeg');
const async = require('async');
const directory = path.normalize('F:\\Movies & TV\\Movies\\testDir');
let x = 0;
const fileArray = [];
const succArray = [];
const failArray = [];
// Set the path to the ffmpeg executable
ffmpeg.setFfmpegPath(path.normalize('C:\\ffmpeg\\bin\\ffmpeg.exe'));

// Add this near the start of your script
const tempDir = path.join(directory, 'temp');
if (!fs.existsSync(tempDir)) {
 fs.mkdirSync(tempDir, { recursive: true });
}

const progresscsv = path.normalize('C:\\Users\\User\\Documents\\Coding\\Tools\\progress.csv');
if (fs.existsSync(progresscsv)) {
 fs.unlinkSync(progresscsv);
};

const csvStream = fs.createWriteStream(progresscsv);
csvStream.write('File Name,Status\n');

const CONCURRENCY_LIMIT = 3; // Adjust based on your system capabilities

// Add at the start of your script
const processedFiles = new Set();

function sanitizeFilePath(filePath) {
 return filePath.replace(/([{}])/g, '\\$1');
}

// Create a queue
const queue = async.queue(async (task, callback) => {
 const { file, filePath, tempFilePath, movieMetadata } = task;
 try {
 await new Promise((resolve, reject) => {
 console.log(`ffmpeg reading: ${sanitizeFilePath(filePath)}`);
 ffmpeg(sanitizeFilePath(filePath))
 .outputOptions([
 '-y',
 '-c', 'copy',
 '-map', '0',
 '-metadata', `title=${movieMetadata.title}`,
 '-metadata', `subtitle=${movieMetadata.subtitle || ''}`,
 '-metadata', `comment=${movieMetadata.cut || ''}`,
 '-metadata', `year=${movieMetadata.year}`
 ])
 .on('error', (err) => reject(err))
 .on('end', () => resolve())
 .saveToFile(tempFilePath);
 });
 
 // Handle success
 console.log(`Successfully processed: ${file}`);
 succArray.push(file);
 // Only call callback once
 if (callback && typeof callback === 'function') {
 callback();
 }
 } catch (err) {
 // Handle error
 console.error(`Error processing ${file}: ${err.message}`);
 failArray.push(file);
 // Only call callback once with error
 if (callback && typeof callback === 'function') {
 callback(err);
 }
 }
}, CONCURRENCY_LIMIT);

fs.readdir(directory, (err, files) => {
 if (err) {
 console.error(`Error reading directory: ${err.message}`);
 return;
 }
 console.log(directory);

 // Filter for files only
 files = files.filter(file => fs.statSync(path.join(directory, file)).isFile());
 console.log(files);

 for (const file of files) {
 x++;
 const filePath = path.join(directory, file);
 let desort = file.replace(/(.*),\s(the\s|an\s|a\s)/i, '$2'+'$1 ') || file;
 
 // Create task object for queue
 const task = {
 file,
 filePath: filePath,
 tempFilePath: path.join(directory, 'temp', `temp_${x}_${path.parse(file).name
 .replace(/[^a-zA-Z0-9]/g, '_')}${path.extname(file)}`),
 movieMetadata: {
 title: desort.replace(/(\s[\-\{\[].*)/gi, ``),
 subtitle: desort.includes('-') ? desort.replace(/(.*)\-\s(.*?)[\{\[].*/gi, '$2') : null,
 cut: desort.includes('{') ? desort.replace(/.*\{(.*)\}.*/gi, '$1') : null,
 year: desort.replace(/.*\[(.*)\].*/gi, '$1')
 }
 };
 
 // Add to processing queue
 queue.push(task, (err) => {
 if (!processedFiles.has(task.file)) {
 processedFiles.add(task.file);
 if (err) {
 csvStream.write(`${task.file},Failed\n`);
 } else {
 csvStream.write(`${task.file},Processed\n`);
 }
 }
 });
 }
});

// Add queue completion handler
queue.drain(() => {
 console.log('All files have been processed');
 console.log(`Success: ${succArray.length} files: ${succArray}`);
 console.log(`Failed: ${failArray.length} files: ${failArray}`);
});

//node C:\Users\User\Documents\Coding\Tools\testMDG.js



And the console is logging :


PS C:\Users\User> node C:\Users\User\Documents\Coding\Tools\testMDG.js
F:\Movies & TV\Movies\testDir
[
 'Test Video 1 [2020].mp4',
 'Test Video 2, A [2020].mp4',
 'Test Video 3 {Test Cut} [2020].mp4',
 'Test Video 4 - The Testening [2020].mp4'
]
ffmpeg reading: F:\Movies & TV\Movies\testDir\Test Video 1 [2020].mp4
ffmpeg reading: F:\Movies & TV\Movies\testDir\Test Video 2, A [2020].mp4
ffmpeg reading: F:\Movies & TV\Movies\testDir\Test Video 3 \{Test Cut\} [2020].mp4
Error processing Test Video 3 {Test Cut} [2020].mp4: ffmpeg exited with code 4294967294: Error opening input file F:\Movies & TV\Movies\testDir\Test Video 3 \{Test Cut\} [2020].mp4.
Error opening input files: No such file or directory

ffmpeg reading: F:\Movies & TV\Movies\testDir\Test Video 4 - The Testening [2020].mp4
Successfully processed: Test Video 1 [2020].mp4
Successfully processed: Test Video 2, A [2020].mp4
Successfully processed: Test Video 4 - The Testening [2020].mp4
All files have been processed
Success: 3 files: Test Video 1 [2020].mp4,Test Video 2, A [2020].mp4,Test Video 4 - The Testening [2020].mp4
Failed: 1 files: Test Video 3 {Test Cut} [2020].mp4



I've tried so many different solutions in the sanitizeFilePath function. Escaping the {} characters (as included below), escaping all non-alphanumeric characters, putting the filepath in quotes, etc. VSCode's CoPilot is just pulling me round in circles, suggesting solutions I've already tried.


-
MJPEG decoding is 3x slower when opening a V4L2 input device [closed]
26 octobre 2024, par XenonicI'm trying to decode a MJPEG video stream coming from a webcam, but I'm hitting some performance blockers when using FFmpeg's C API in my application. I've recreated the problem using the example video decoder, where I just simply open the V4L2 input device, read packets, and push them to the decoder. What's strange is if I try to get my input packets from the V4L2 device instead of from a file, the
avcodec_send_packet
call to the decoder is nearly 3x slower. After further poking around, I narrowed the issue down to whether or not I open the V4L2 device at all.

Let's look at a minimal example demonstrating this behavior :


extern "C"
{
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>opt.h>
#include <libavdevice></libavdevice>avdevice.h>
}

#define INBUF_SIZE 4096

static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt)
{
 if (avcodec_send_packet(dec_ctx, pkt) < 0)
 exit(1);
 
 int ret = 0;
 while (ret >= 0) {
 ret = avcodec_receive_frame(dec_ctx, frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 return;
 else if (ret < 0)
 exit(1);

 // Here we'd save off the decoded frame, but that's not necessary for the example.
 }
}

int main(int argc, char **argv)
{
 const char *filename;
 const AVCodec *codec;
 AVCodecParserContext *parser;
 AVCodecContext *c= NULL;
 FILE *f;
 AVFrame *frame;
 uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 uint8_t *data;
 size_t data_size;
 int ret;
 int eof;
 AVPacket *pkt;

 filename = argv[1];

 pkt = av_packet_alloc();
 if (!pkt)
 exit(1);

 /* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
 memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);

 // Use MJPEG instead of the example's MPEG1
 //codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
 codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
 if (!codec) {
 fprintf(stderr, "Codec not found\n");
 exit(1);
 }

 parser = av_parser_init(codec->id);
 if (!parser) {
 fprintf(stderr, "parser not found\n");
 exit(1);
 }

 c = avcodec_alloc_context3(codec);
 if (!c) {
 fprintf(stderr, "Could not allocate video codec context\n");
 exit(1);
 }

 if (avcodec_open2(c, codec, NULL) < 0) {
 fprintf(stderr, "Could not open codec\n");
 exit(1);
 }

 c->pix_fmt = AV_PIX_FMT_YUVJ422P;

 f = fopen(filename, "rb");
 if (!f) {
 fprintf(stderr, "Could not open %s\n", filename);
 exit(1);
 }

 frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }

 avdevice_register_all();
 auto* inputFormat = av_find_input_format("v4l2");
 AVDictionary* options = nullptr;
 av_dict_set(&options, "input_format", "mjpeg", 0);
 av_dict_set(&options, "video_size", "1920x1080", 0);

 AVFormatContext* fmtCtx = nullptr;


 // Commenting this line out results in fast encoding!
 // Notice how fmtCtx is not even used anywhere, we still read packets from the file
 avformat_open_input(&fmtCtx, "/dev/video0", inputFormat, &options);


 // Just parse packets from a file and send them to the decoder.
 do {
 data_size = fread(inbuf, 1, INBUF_SIZE, f);
 if (ferror(f))
 break;
 eof = !data_size;

 data = inbuf;
 while (data_size > 0 || eof) {
 ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
 data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
 if (ret < 0) {
 fprintf(stderr, "Error while parsing\n");
 exit(1);
 }
 data += ret;
 data_size -= ret;

 if (pkt->size)
 decode(c, frame, pkt);
 else if (eof)
 break;
 }
 } while (!eof);

 return 0;
}



Here's a histogram of the CPU time spent in that
avcodec_send_packet
function call with and without opening the device by commenting out thatavformat_open_input
call above.

Without opening the V4L2 device :




With opening the V4L2 device :




Interestingly we can see a significant number of function calls are in that 25ms time bin ! But most of them are 78ms... why ?


So what's going on here ? Why does opening the device destroy my decode performance ?


Additionally, if I try and run a seemingly equivalent pipeline through the ffmpeg tool itself, I don't hit this problem. Running this command :


ffmpeg -f v4l2 -input_format mjpeg -video_size 1920x1080 -r 30 -c:v mjpeg -i /dev/video0 -c:v copy out.mjpeg



Is generating an output file with a reported speed of just barely over 1.0x, aka. 30 FPS. Perfect, why doesn't the C API give me the same results ? One thing to note is I do get periodic errors from the MJPEG decoder (about every second), not sure if these are a concern or not :


[mjpeg @ 0x5590d6b7b0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 27 >= 27
[mjpeg @ 0x5590d6b7b0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 30 >= 30
...



I'm running on a Raspberry Pi CM4 with FFmpeg 6.1.1


-
FFPEG : Errors opening audio input stream on MacOs
22 septembre 2024, par XaviI am encountering the following warning (from Audio Toolbox ?) very often when opening an external microphone audio stream with ffmpeg's
libavformat
on macOS :

CMIO_Unit_Converter_Audio.cpp:590:RebuildAudioConverter AudioConverterSetProperty(dbca) failed (1886547824)


This warning results on the codec id of the stream not being properly detected and it defaulting to the dummy
AV_CODEC_ID_FIRST_AUDIO
, which defaults toAV_CODEC_ID_PCM_S16LE
, and results on distorted audio decoding the packet when this is not the correct codec.

You can observe the error with the following code, where I open and close and input audio stream 10 times in a row. Except for the internal macbook microphone, all the other ones I tried error more times than succeed, some only succeeding on the first call. From what I can tell, all these microphones correct detected codec with this code is
AV_CODEC_ID_PCM_F32LE
.

#include "libavdevice/avdevice.h"
#include "libavformat/avformat.h"
#include 

const char inputDevice[] = ":0";

int main(int argc, char *argv[]) {
 const AVInputFormat *inputFormat;
 AVStream *inputStream = NULL;
 AVFormatContext *inputFormatContext = NULL;
 int ret;
 int i, j;

 // Initialize the input
 avdevice_register_all();

 inputFormat = av_find_input_format("avfoundation");

 for (i = 0; i < 10; i++) {
 ret = avformat_open_input(&inputFormatContext, inputDevice, inputFormat,
 NULL);
 if (ret != 0) {
 fprintf(stderr, "Couldn't open input audio device");
 break;
 }

 ret = avformat_find_stream_info(inputFormatContext, NULL);
 if (ret < 0) {
 fprintf(stderr, "Couldn't find stream information.");
 break;
 }

 for (j = 0; j < inputFormatContext->nb_streams; j++) {
 if (inputFormatContext->streams[j]->codecpar->codec_type ==
 AVMEDIA_TYPE_AUDIO) {
 inputStream = inputFormatContext->streams[j];
 break;
 }
 }
 if (!inputStream) {
 fprintf(stderr, "Couldn't find a audio stream.");
 break;
 }
 printf("codecID: %s\n",
 inputStream->codecpar->codec_id == AV_CODEC_ID_FIRST_AUDIO
 ? "Incorrect"
 : "Correct");
 avformat_close_input(&inputFormatContext);
 }
 return 0;
}



Example output :


codecID: Correct
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Correct
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Correct



How can avoid the warning ? What am I doing wrong ?