
Recherche avancée
Médias (91)
-
Head down (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Echoplex (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Discipline (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Letting you (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
1 000 000 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
999 999 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (111)
-
Les notifications de la ferme
1er décembre 2010, parAfin d’assurer une gestion correcte de la ferme, il est nécessaire de notifier plusieurs choses lors d’actions spécifiques à la fois à l’utilisateur mais également à l’ensemble des administrateurs de la ferme.
Les notifications de changement de statut
Lors d’un changement de statut d’une instance, l’ensemble des administrateurs de la ferme doivent être notifiés de cette modification ainsi que l’utilisateur administrateur de l’instance.
À la demande d’un canal
Passage au statut "publie"
Passage au (...) -
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...)
Sur d’autres sites (6357)
-
How to blur side of horizontal video with ffmpeg
4 janvier 2023, par GetroI would like to find a way to blur the top and the bottom of an horizontal video with the same video.


At the moment I have the code to do the opposite :


ffmpeg -i test.mp4 -lavfi "[0:v]scale=1920*2:1080*2,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[0:v]scale=-1:1080[ov];[bg][ov]overlay=(W-w)/2:(H-h)/2,crop=w=1920:h=1080" outpt.mp4



So I have this :
1
And I would like to have this :
2


-
How to decode mp3 to raw sample data for FFMpeg using FFMediaToolkit
28 décembre 2022, par LeeMy objective is to create a video slideshow with audio using a database as the source. The final implementation video and audio inputs need to be memory streams or byte arrays, not a file system path. The sample code is file based for portability. It's just trying to read a file based mp3 then write it to the output.


I've tried a few FFMpeg wrappers and I'm open to alternatives. This code is using FFMediaToolkit. The video portion of the code works. It's the audio that I can't get to work.


The input is described as "A 2D jagged array of multi-channel sample data with NumChannels rows and NumSamples columns." The datatype is float[][].


My mp3 source is mono. I'm using NAudio.Wave to decode the mp3. It is then split into chunks equal to the frame size for the sample rate. It is then converted into the jagged float with the data on channel 0.


The FFMpeg decoder displays a long list of "buffer underflow" and "packet too large, ignoring buffer limits to mux it". C# returns "Specified argument was out of the range of valid values." The offending line of code being "file.Audio.AddFrame(frameAudio)".


The source is 16 bit samples. The PCM_S16BE codec is the only one that I could get to accept 16 bit sample format. I could only get the MP3 encoder to work with "Signed 32-bit integer (planar)" as the sample format. I'm not certain if the source data needs to be converted from 16 to 32 bit to use the codec.


`


using FFMediaToolkit;
using FFMediaToolkit.Decoding;
using FFMediaToolkit.Encoding;
using FFMediaToolkit.Graphics;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FFMediaToolkit.Audio;
using NAudio.Wave;
using FFmpeg.AutoGen;

 internal class FFMediaToolkitTest
 {
 const int frameRate = 30;
 const int vWidth = 1920;
 const int vHeight = 1080;
 const int aSampleRate = 24_000; // source sample rate
 //const int aSampleRate = 44_100;
 const int aSamplesPerFrame = aSampleRate / frameRate;
 const int aBitRate = 32_000;
 const string dirInput = @"D:\Websites\Vocabulary\Videos\source\";
 const string pathOutput = @"D:\Websites\Vocabulary\Videos\example.mpg";

 public FFMediaToolkitTest()
 {
 try
 {
 FFmpegLoader.FFmpegPath = "."; // FFMpeg DLLs in root project directory
 var settings = new VideoEncoderSettings(width: vWidth, height: vHeight, framerate: frameRate, codec: VideoCodec.H264);
 settings.EncoderPreset = EncoderPreset.Fast;
 settings.CRF = 17;

 //var settingsAudio = new AudioEncoderSettings(aSampleRate, 1, (AudioCodec)AVCodecID.AV_CODEC_ID_PCM_S16BE); // Won't run with low bitrate.
 var settingsAudio = new AudioEncoderSettings(aSampleRate, 1, AudioCodec.MP3); // mpg runs with SampleFormat.SignedDWordP
 settingsAudio.Bitrate = aBitRate;
 //settingsAudio.SamplesPerFrame = aSamplesPerFrame;
 settingsAudio.SampleFormat = SampleFormat.SignedDWordP;

 using (var file = MediaBuilder.CreateContainer(pathOutput).WithVideo(settings).WithAudio(settingsAudio).Create())
 {
 var files = Directory.GetFiles(dirInput, "*.jpg");
 foreach (var inputFile in files)
 {
 Console.WriteLine(inputFile);
 var binInputFile = File.ReadAllBytes(inputFile);
 var memInput = new MemoryStream(binInputFile);
 var bitmap = Bitmap.FromStream(memInput) as Bitmap;
 var rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitmap.Size);
 var bitLock = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
 var bitmapData = ImageData.FromPointer(bitLock.Scan0, ImagePixelFormat.Bgr24, bitmap.Size);

 for (int i = 0; i < 60; i++)
 file.Video.AddFrame(bitmapData); 
 bitmap.UnlockBits(bitLock);
 }

 var mp3files = Directory.GetFiles(dirInput, "*.mp3");
 foreach (var inputFile in mp3files)
 {
 Console.WriteLine(inputFile);
 var binInputFile = File.ReadAllBytes(inputFile);
 var memInput = new MemoryStream(binInputFile);

 foreach (float[][] frameAudio in GetFrames(memInput))
 {
 file.Audio.AddFrame(frameAudio); // encode the frame
 }
 }
 //Console.WriteLine(file.Audio.CurrentDuration);
 Console.WriteLine(file.Video.CurrentDuration);
 Console.WriteLine(file.Video.Configuration);
 }
 }
 catch (Exception e)
 {
 Vocab.LogError("FFMediaToolkitTest", e.StackTrace + " " + e.Message);
 Console.WriteLine(e.StackTrace + " " + e.Message);
 }

 Console.WriteLine();
 Console.WriteLine("Done");
 Console.ReadLine();
 }


 public static List GetFrames(MemoryStream mp3stream)
 {
 List output = new List();
 
 int frameCount = 0;

 NAudio.Wave.StreamMediaFoundationReader smfReader = new StreamMediaFoundationReader(mp3stream);
 Console.WriteLine(smfReader.WaveFormat);
 Console.WriteLine(smfReader.WaveFormat.AverageBytesPerSecond); //48000
 Console.WriteLine(smfReader.WaveFormat.BitsPerSample); // 16
 Console.WriteLine(smfReader.WaveFormat.Channels); // 1 
 Console.WriteLine(smfReader.WaveFormat.SampleRate); //24000

 Console.WriteLine("PCM bytes: " + smfReader.Length);
 Console.WriteLine("Total Time: " + smfReader.TotalTime);

 int samplesPerFrame = smfReader.WaveFormat.SampleRate / frameRate;
 int bytesPerFrame = samplesPerFrame * smfReader.WaveFormat.BitsPerSample / 8;
 byte[] byteBuffer = new byte[bytesPerFrame];

 while (smfReader.Read(byteBuffer, 0, bytesPerFrame) != 0)
 {
 float[][] buffer = Convert16BitToFloat(byteBuffer);
 output.Add(buffer);
 frameCount++;
 }
 return output;
 }

 public static float[][] Convert16BitToFloat(byte[] input)
 {
 // Only works with single channel data
 int inputSamples = input.Length / 2;
 float[][] output = new float[1][]; 
 output[0] = new float[inputSamples];
 int outputIndex = 0;
 for (int n = 0; n < inputSamples; n++)
 {
 short sample = BitConverter.ToInt16(input, n * 2);
 output[0][outputIndex++] = sample / 32768f;
 }
 return output;
 }

 }





`


I've tried multiple codecs with various settings. I couldn't get any of the codecs to accept a mp4 output file extension. FFMpeg will run but error out with mpg as the output file.


-
Xubuntu ffmpeg screen capturing very slow when no display connected
8 décembre 2022, par fre_derI use ffmpeg on an Intel Nuc with Xubuntu 22.04 (XFCE4, lightdm), with x11grab for screen capturing the desktop, and sending output to a multicast UDP stream (which is shown on different IPTV sets in the network).
The system uses autologin, and autostarts Firefox in kiosk mode, rendering a html5 video.


Everything works fine when a display is attached, but from the moment the hdmi cable is detached, the output video is extremely slow (very shaky, looks like 1 fps, audio is OK although it has occasional hickups).


CPU and memory usage doesn't seem to be affected whether a display is attached or not.


This runs fine on Xubuntu 18.04, although there might be small config changes that I'm not aware of.


To be able to display output when no display is attached, I created a VIRTUAL1 display :


xrandr -d :0 --verbose --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr -d :0 --verbose --addmode VIRTUAL1 "1920x1080_60.00"



my /usr/share/X11/xorg.conf.d/20-intel.conf looks like :


Section "Device"
 Identifier "Intel Graphics"
 Driver "intel"
 Option "VirtualHeads" "1"
 Option "TearFree" "true"
 Option "TripleBuffer" "true"
 Option "DRI" "false"
EndSection



The ffmpeg command :


ffmpeg -r 25 -thread_queue_size 512 -f x11grab -s 1920x1080 -i :0 -thread_queue_size 512 -f alsa -i default -c:a mp2 -f mpegts udp://239.255.255.8:50000?pkt_size=1316



(during trial/error I tested various ffmpeg command line options to no avail)


Output with hdmi cable attached :


ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
 built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
 configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
 WARNING: library configuration mismatch
 avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient
 libavutil 56. 70.100 / 56. 70.100
 libavcodec 58.134.100 / 58.134.100
 libavformat 58. 76.100 / 58. 76.100
 libavdevice 58. 13.100 / 58. 13.100
 libavfilter 7.110.100 / 7.110.100
 libswscale 5. 9.100 / 5. 9.100
 libswresample 3. 9.100 / 3. 9.100
 libpostproc 55. 9.100 / 55. 9.100
[x11grab @ 0x55f1fdfa18c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
 Duration: N/A, start: 1670501458.257764, bitrate: 1658880 kb/s
 Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1658880 kb/s, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
 Duration: N/A, start: 1670501459.560180, bitrate: 1536 kb/s
 Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
 Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://239.255.255.8:50000?pkt_size=1316':
 Metadata:
 encoder : Lavf58.76.100
 Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1920x1080, q=2-31, 200 kb/s, 25 fps, 90k tbn
 Metadata:
 encoder : Lavc58.134.100 mpeg2video
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
 Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
 Metadata:
 encoder : Lavc58.134.100 mp2
frame= 1041 fps= 25 q=31.0 Lsize= 12451kB time=00:00:41.56 bitrate=2454.3kbits/s speed=1.01x
video:9955kB audio:1920kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.847125%
Exiting normally, received signal 2.



Output without hdmi cable attached :


ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
 built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
 configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
 WARNING: library configuration mismatch
 avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient
 libavutil 56. 70.100 / 56. 70.100
 libavcodec 58.134.100 / 58.134.100
 libavformat 58. 76.100 / 58. 76.100
 libavdevice 58. 13.100 / 58. 13.100
 libavfilter 7.110.100 / 7.110.100
 libswscale 5. 9.100 / 5. 9.100
 libswresample 3. 9.100 / 3. 9.100
 libpostproc 55. 9.100 / 55. 9.100
[x11grab @ 0x56325816a8c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
 Duration: N/A, start: 1670501334.907900, bitrate: 1658880 kb/s
 Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1658880 kb/s, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
 Duration: N/A, start: 1670501336.193971, bitrate: 1536 kb/s
 Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
 Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://239.255.255.8:50000?pkt_size=1316':
 Metadata:
 encoder : Lavf58.76.100
 Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1920x1080, q=2-31, 200 kb/s, 25 fps, 90k tbn
 Metadata:
 encoder : Lavc58.134.100 mpeg2video
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
 Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
 Metadata:
 encoder : Lavc58.134.100 mp2
frame= 1020 fps= 26 q=31.0 Lsize= 11802kB time=00:00:40.72 bitrate=2374.3kbits/s speed=1.02x
video:9378kB audio:1873kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.892235%
Exiting normally, received signal 2.



xrandr output with display connected (if no display connected then DP1 just says disconnected as the other outputs)


Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 530mm x 300mm
 1920x1080 60.00*+ 74.97 50.00 59.94
 1920x1080i 60.00 50.00 59.94
 1680x1050 59.88
 1280x1024 75.02 60.02
 1440x900 59.90
 1280x960 60.00
 1280x720 60.00 50.00 59.94
 1024x768 75.03 70.07 60.00
 832x624 74.55
 800x600 72.19 75.00 60.32 56.25
 720x576 50.00
 720x480 60.00 59.94
 640x480 75.00 72.81 66.67 60.00 59.94
 720x400 70.08
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
DP4 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
 1920x1080_60.00 59.96*
VIRTUAL2 disconnected (normal left inverted right x axis y axis)