
Recherche avancée
Médias (91)
-
Spitfire Parade - Crisis
15 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Wired NextMusic
14 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (99)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (10485)
-
How do I write audio and video to the same file using FFMPEG and C ?
29 juin 2018, par benwizI am consuming an audio file and a video file using ffmpeg in a C program. I am modifying both the audio and the video data. In working the code below I write both each of these streams to its own file. How can I write both streams to the same file ?
#include
#include
#include
// Video resolution
#define W 1280
#define H 720
// Allocate a buffer to store one video frame
unsigned char video_frame[H][W][3] = {0};
int main()
{
// Audio pipes
FILE *audio_pipein = popen("ffmpeg -i data/daft-punk.mp3 -f s16le -ac 1 -", "r");
FILE *audio_pipeout = popen("ffmpeg -y -f s16le -ar 44100 -ac 1 -i - out/daft-punk.mp3", "w");
// Video pipes
FILE *video_pipein = popen("ffmpeg -i data/daft-punk.mp4 -f image2pipe -vcodec rawvideo -pix_fmt rgb24 -", "r");
FILE *video_pipeout = popen("ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 1280x720 -r 25 -i - -f mp4 -q:v 5 -an -vcodec mpeg4 out/daft-punk.mp4", "w");
// Audio vars
int16_t audio_sample;
int audio_count;
int audio_n = 0;
// Video vars
int x = 0;
int y = 0;
int video_count = 0;
// Read, modify, and write one audio_sample and video_frame at a time
while (1)
{
// Audio
audio_count = fread(&audio_sample, 2, 1, audio_pipein); // read one 2-byte audio_sample
if (audio_count == 1)
{
++audio_n;
audio_sample = audio_sample * sin(audio_n * 5.0 * 2 * M_PI / 44100.0);
fwrite(&audio_sample, 2, 1, audio_pipeout);
}
// Video
video_count = fread(video_frame, 1, H * W * 3, video_pipein); // Read a frame from the input pipe into the buffer
if (video_count == H * W * 3) // Only modify and write if frame exists
{
for (y = 0; y < H; ++y) // Process this frame
for (x = 0; x < W; ++x) // Invert each colour component in every pixel
{
video_frame[y][x][0] = 255 - video_frame[y][x][0]; // red
video_frame[y][x][1] = 255 - video_frame[y][x][1]; // green
video_frame[y][x][2] = 255 - video_frame[y][x][2]; // blue
}
fwrite(video_frame, 1, H * W * 3, video_pipeout); // Write this frame to the output pipe
}
// Break if both complete
if (audio_count != 1 && video_count != H * W * 3)
break;
}
// Close audio pipes
pclose(audio_pipein);
pclose(audio_pipeout);
// Close video pipes
fflush(video_pipein);
fflush(video_pipeout);
pclose(video_pipein);
pclose(video_pipeout);
return 0;
}I took the base for this code from this article.
Thanks !
-
How to import and use FFmpegInteropX.FFmpegUWP ?
14 janvier, par BorisI am writing a WinUI3 app. I need it to play a .mkv video file using MediaPlayerElement control. Out of box, .mkv file types are not supported. So I came upon a package FFmpegInteropX.FFmpegUWP (current v5.1.100) and installed it to the solution via Visual Studio NuGet Package Manager. The installation went fine and the package is definitely part of the project :


<packagereference include="FFmpegInteropX.FFmpegUWP" version="5.1.100"></packagereference>


The problem I have is that when I type
using FFmpegInteropX;
it is not recognized and I cannot use it. I've noticed there is also a FFmpegInteropX package (so without the ".FFmpegUWP" part) and I tried installing that one too, as I was trying to make the using statement work. However, it appears that that package is not intended for WinUI3 projects and NuGet removed it.

Now, I am clueless on how to use the FFmpegInteropX.FFmpegUWP in the project. Could anyone please explain why I might be experiencing this problem ?


-
libav live transcode to SFML SoundStream, garbled and noise
20 juin 2021, par William LohanI'm so close to have this working but playing with the output sample format or codec context doesn't seem to solve and don't know where to go from here.


#include <iostream>
#include <sfml></sfml>Audio.hpp>
#include "MyAudioStream.h"

extern "C"
{
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>avutil.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>audio_fifo.h>
#include <libswresample></libswresample>swresample.h>
}

void setupInput(AVFormatContext *input_format_context, AVCodecContext **input_codec_context, const char *streamURL)
{
 // av_find_input_format("mp3");
 avformat_open_input(&input_format_context, streamURL, NULL, NULL);
 avformat_find_stream_info(input_format_context, NULL);

 AVDictionary *metadata = input_format_context->metadata;
 AVDictionaryEntry *name = av_dict_get(metadata, "icy-name", NULL, 0);
 if (name != NULL)
 {
 std::cout << name->value << std::endl;
 }
 AVDictionaryEntry *title = av_dict_get(metadata, "StreamTitle", NULL, 0);
 if (title != NULL)
 {
 std::cout << title->value << std::endl;
 }

 AVStream *stream = input_format_context->streams[0];
 AVCodecParameters *codec_params = stream->codecpar;
 AVCodec *codec = avcodec_find_decoder(codec_params->codec_id);
 *input_codec_context = avcodec_alloc_context3(codec);

 avcodec_parameters_to_context(*input_codec_context, codec_params);
 avcodec_open2(*input_codec_context, codec, NULL);
}

void setupOutput(AVCodecContext *input_codec_context, AVCodecContext **output_codec_context)
{
 AVCodec *output_codec = avcodec_find_encoder(AV_CODEC_ID_PCM_S16LE); // AV_CODEC_ID_PCM_S16LE ?? AV_CODEC_ID_PCM_S16BE
 *output_codec_context = avcodec_alloc_context3(output_codec);
 (*output_codec_context)->channels = 2;
 (*output_codec_context)->channel_layout = av_get_default_channel_layout(2);
 (*output_codec_context)->sample_rate = input_codec_context->sample_rate;
 (*output_codec_context)->sample_fmt = output_codec->sample_fmts[0]; // AV_SAMPLE_FMT_S16 ??
 avcodec_open2(*output_codec_context, output_codec, NULL);
}

void setupResampler(AVCodecContext *input_codec_context, AVCodecContext *output_codec_context, SwrContext **resample_context)
{
 *resample_context = swr_alloc_set_opts(
 *resample_context,
 output_codec_context->channel_layout,
 output_codec_context->sample_fmt,
 output_codec_context->sample_rate,
 input_codec_context->channel_layout,
 input_codec_context->sample_fmt,
 input_codec_context->sample_rate,
 0, NULL);
 swr_init(*resample_context);
}

MyAudioStream::MyAudioStream()
{
 input_format_context = avformat_alloc_context();
 resample_context = swr_alloc();
}

MyAudioStream::~MyAudioStream()
{
 // clean up
 avformat_close_input(&input_format_context);
 avformat_free_context(input_format_context);
}

void MyAudioStream::load(const char *streamURL)
{

 setupInput(input_format_context, &input_codec_context, streamURL);
 setupOutput(input_codec_context, &output_codec_context);
 setupResampler(input_codec_context, output_codec_context, &resample_context);

 initialize(output_codec_context->channels, output_codec_context->sample_rate);
}

bool MyAudioStream::onGetData(Chunk &data)
{

 // init
 AVFrame *input_frame = av_frame_alloc();
 AVPacket *input_packet = av_packet_alloc();
 input_packet->data = NULL;
 input_packet->size = 0;

 // read
 av_read_frame(input_format_context, input_packet);
 avcodec_send_packet(input_codec_context, input_packet);
 avcodec_receive_frame(input_codec_context, input_frame);

 // convert
 uint8_t *converted_input_samples = (uint8_t *)calloc(output_codec_context->channels, sizeof(*converted_input_samples));
 av_samples_alloc(&converted_input_samples, NULL, output_codec_context->channels, input_frame->nb_samples, output_codec_context->sample_fmt, 0);
 swr_convert(resample_context, &converted_input_samples, input_frame->nb_samples, (const uint8_t **)input_frame->extended_data, input_frame->nb_samples);

 data.sampleCount = input_frame->nb_samples;
 data.samples = (sf::Int16 *)converted_input_samples;

 // av_freep(&converted_input_samples[0]);
 // free(converted_input_samples);
 av_packet_free(&input_packet);
 av_frame_free(&input_frame);

 return true;
}

void MyAudioStream::onSeek(sf::Time timeOffset)
{
 // no op
}

sf::Int64 MyAudioStream::onLoop()
{
 // no loop
 return -1;
}

</iostream>


Called with


#include <iostream>

#include "./MyAudioStream.h"

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

const char *streamURL = "http://s5radio.ponyvillelive.com:8026/stream.mp3";

int main(int, char **)
{

 MyAudioStream myStream;

 myStream.load(streamURL);

 std::cout << "Hello, world!" << std::endl;

 myStream.play();

 while (myStream.getStatus() == MyAudioStream::Playing)
 {
 sf::sleep(sf::seconds(0.1f));
 }

 return 0;
}
</iostream>