Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to stream frames from ffmpeg to a process ?
7 mars, par VoracI would like to encrypt camera frames before transmitting. For that purpose the encrypting process needs to get the raw frames through some mode of IPC. I tried reading through the steaming API docs but got lost. This is an "what approach" question instead of a "working solution" one.
-
FFMpeg D3D11 decoded image to OpenCV UMat
7 mars, par SpurigaI would like to copy FFMpeg decoded image data to an UMat WITHOUT copying it to the CPU RAM:
Is there any way to do it? What if there are two or more GPU card in the PC?
I have this code for av_image_copy_to_buffer, works fine:
int copy_frame_to_buffer(void* handle, void* buffer, int bufferSize) { int ret = 0; int calculatedBufferSize; VideoDecoderContext* context = static_cast(handle); calculatedBufferSize = av_image_get_buffer_size(static_cast
(context->frame->format), context->frame->width, context->frame->height, 1); if (calculatedBufferSize != bufferSize) { fprintf(stderr, "Calculated buffer (%d) is not equal to bufferSize (%d).\n", calculatedBufferSize, bufferSize); return -1; } uint8_t* byte_buffer = static_cast(buffer); ret = av_image_copy_to_buffer(byte_buffer, calculatedBufferSize, (const uint8_t* const*)context->frame->data, (const int*)context->frame->linesize, static_cast (context->frame->format), context->frame->width, context->frame->height, 1); if (ret < 0) { fprintf(stderr, "Can not copy image to buffer\n"); return ret; } return ret; } ...but if I change the context->frame to context->hwFrame it is not working.
-
ffmpeg command not found but pip list shows ffmpeg
7 mars, par your_doomsday07I have been trying to install ffmpeg using the command
pip install ffmpeg
and I am doing this in a server where we dont have sudo permissions. On writing ffmpeg I get ffmpeg: command not found. Then I checked withpip list
and it showed ffmpeg. Please help me. -
rtsp feed fails intermittently using node js
7 mars, par Prem KumarI am new to node.js and was debugging a code written by another developer. We have a an IP camera which provides rtsp feed which is being displayed on a webpage. I can view the camera feed using the rtsp url in VLC but the web viewer of camera feed usually gives white screen although it somehow works intermittently.
I was told that it used to work properly when the machine was on Ubuntu 20.04 now it has been updated to Ubuntu 24.
Index.js
const Stream = require("node-rtsp-stream-jsmpeg"); const fs = require("fs"); const https = require("https"); const httpsServer = https.createServer({ key: fs.readFileSync("./cert/ssl.key"), cert: fs.readFileSync("./cert/ssl.crt"), }); const options = { name: "streamName", url: "rtsp://10.20.xxx.xx/profile1", wsPort: 3333, httpsServer: httpsServer }; let stream = new Stream(options); stream.start();
index.html
<script src="https://jsmpeg.com/jsmpeg.min.js"></script>
<script type="text/javascript">
 var url = "ws://localhost:3333";
 var canvas = document.getElementById('video-canvas');
 var player = new JSMpeg.Player(url, {canvas: canvas});
 </script>
I tried reinstalling the node modules but it didn't make any difference. I am sure that there is no hardware issue as rtsp connection always works in VLC.
Following is the console log when it fails
Following is the console log when it works
-
how to add effect to audio, sound like a phone call phone, inner monologue, or sounds like a man/woman ? [closed]
7 mars, par MathewI'm trying to apply different audio effects, such as making audio sound like a phone call. Below is my current approach. As you can see, I'm using multiple filters and simple algorithms to achieve this effect, but the output quality isn't ideal.
I've looked into FFmpeg filters and noticed mentions of LADSPA/LV2 plugins. Are these viable solutions? Any other suggestions would be greatly appreciated.
public static void applySceneEffect(String inputPath, String outputPath, int sceneType) { LOGGER.info("apply scene effect {} to {}", sceneType, inputPath); try (FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputPath); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputPath, grabber.getAudioChannels())) { grabber.setOption("vn", ""); grabber.start(); recorder.setAudioCodec(avcodec.AV_CODEC_ID_PCM_S16LE); recorder.setSampleRate(grabber.getSampleRate()); recorder.setAudioChannels(grabber.getAudioChannels()); recorder.setAudioBitrate(grabber.getAudioBitrate()); recorder.setFormat("wav"); String audioFilter = String.join(",", "aresample=8000", "highpass=f=300, lowpass=f=3400", "acompressor=threshold=-15dB:ratio=4:attack=10:release=100", "volume=1.5", "aecho=0.9:0.4:10:0.6" ); FFmpegFrameFilter f1 = new FFmpegFrameFilter(audioFilter, grabber.getAudioChannels()); f1.setSampleRate(grabber.getSampleRate()); f1.start(); recorder.start(); Random random = new Random(); double noiseLevel = 0.02; while (true) { var frame = grabber.grabFrame(true, false, true, true); if (frame == null) { break; } ShortBuffer audioBuffer = (ShortBuffer) frame.samples[0]; short[] audioData = new short[audioBuffer.remaining()]; audioBuffer.get(audioData); applyElectricNoise(audioData, grabber.getSampleRate()); audioData = applyDistortion(audioData, 1.5, 30000); audioBuffer.rewind(); audioBuffer.put(audioData); audioBuffer.flip(); f1.push(frame); Frame filteredFrame; while ((filteredFrame = f1.pull()) != null) { recorder.record(filteredFrame); } } recorder.stop(); recorder.release(); grabber.stop(); grabber.release(); } catch (FrameGrabber.Exception | FrameRecorder.Exception | FFmpegFrameFilter.Exception e) { throw new RuntimeException(e); } } private static final double NOISE_LEVEL = 0.005; private static final int NOISE_FREQUENCY = 60; public static void applyElectricNoise(short[] audioData, int sampleRate) { Random random = new Random(); for (int i = 0; i < audioData.length; i++) { double noise = Math.sin(2 * Math.PI * NOISE_FREQUENCY * i / sampleRate); double electricNoise = random.nextGaussian() * NOISE_LEVEL * Short.MAX_VALUE + noise; audioData[i] = (short) Math.max(Math.min(audioData[i] + electricNoise, Short.MAX_VALUE), Short.MIN_VALUE); } } public static short[] applyTremolo(short[] audioData, int sampleRate, double frequency, double depth) { double phase = 0.0; double phaseIncrement = 2 * Math.PI * frequency / sampleRate; for (int i = 0; i < audioData.length; i++) { double modulator = 1.0 - depth + depth * Math.sin(phase); audioData[i] = (short) (audioData[i] * modulator); phase += phaseIncrement; if (phase > 2 * Math.PI) { phase -= 2 * Math.PI; } } return audioData; } public static short[] applyDistortion(short[] audioData, double gain, double threshold) { for (int i = 0; i < audioData.length; i++) { double sample = audioData[i] * gain; if (sample > threshold) { sample = threshold; } else if (sample < -threshold) { sample = -threshold; } audioData[i] = (short) sample; } return audioData; }