
Recherche avancée
Autres articles (86)
-
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 -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (6187)
-
Duplicate a signal with FFmpeg library [on hold]
22 septembre 2016, par MeugiwaraI’m using the FFmpeg library to develop a program in C/C++. At this time, my aim is to duplicate the signal when I open an audio file. My scheme is the next : read an audio file, transform the stereo signal in mono signal and duplicate this mono signal to get two mono signal exactly the same.
I watched in the Doxygen documentation on the official website, but I don’t find something interesting. Do someone know a good way to do this ?
Here’s what I have so far :
#include
#include
#include
#define __STDC_CONSTANT_MACROS
#ifdef _WIN32
extern "C" /* Windows */
{
#include "libswresample/swresample.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "SDL2/SDL.h"
};
#else
#ifdef __cplusplus
extern "C" /* Linux */
{
#endif /* __cplusplus */
#include <libswresample></libswresample>swresample.h>
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <sdl2></sdl2>SDL.H>
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* _WIN32 */
#define MAX_AUDIO_FRAME_SIZE 192000 /* 1 second of 48 kHz 32 bits audio*/
#define OUTPUT_PCM 1 /* Output PCM */
#define USE_SDL 1 /* Use SDL */
/* Les incrémentations */
static Uint32 audio_len;
static Uint8 *audio_chunk;
static Uint8 *audio_pos;
void fill_audio(void *udata, Uint8 *stream, int len)
{
SDL_memset(stream, 0, len); /* SDL 2.0 */
if (audio_len == 0)
return;
len = (len > audio_len ? audio_len : len);
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
audio_pos = audio_pos + len;
audio_len = audio_len - len;
}
int reading_sound(char *str)
{
SDL_AudioSpec wanted_spec;
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVSampleFormat out_sample_fmt;
AVPacket *packet;
AVFrame *pFrame;
AVCodec *pCodec;
uint64_t out_channel_layout;
uint8_t *out_buffer;
int64_t in_channel_layout;
struct SwrContext *au_convert_ctx;
int out_sample_rate;
int out_buffer_size;
int out_nb_samples;
int out_channels;
int audioStream;
int got_picture;
int index = 0;
int ret;
int i;
FILE *pFile = NULL;
/*
//char *sound = "WavinFlag.aac";
*/
av_register_all();
avformat_network_init();
pFormatCtx = avformat_alloc_context();
if (avformat_open_input(&pFormatCtx, str, NULL, NULL) != 0) /* Ouverture du fichier */
{
fprintf(stderr, "%s\n", "Couldn't open input stream");
return (-1);
}
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) /* Récupérer les informations */
{
fprintf(stderr, "Couldn't find stream information\n");
return (-1);
}
av_dump_format(pFormatCtx, 0, str, false); /* Envoyer les informations utiles sur la sortie d'erreur */
audioStream = -1;
for (i = 0; i < pFormatCtx->nb_streams; i++) /* Trouver le début du son */
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
audioStream = i;
break;
}
if (audioStream == -1)
{
fprintf(stderr, "%s\n", "Didn't find an audio stream");
return (-1);
}
pCodecCtx = pFormatCtx->streams[audioStream]->codec;
pCodec = avcodec_find_decoder(pCodecCtx->codec_id); /* Trouver le décodeur du fichier (.aac, .mp3, ...) */
if (pCodec == NULL)
{
fprintf(stderr, "%s\n", "Codec not found");
return (-1);
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) /* Ouvrir le décodeur du fichier */
{
fprintf(stderr, "%s\n", "Couldn't open codec");
return (-1);
}
#if OUTPUT_PCM
pFile = fopen("output.pcm", "wb"); /* Créer et écrire tout ce qui se passe dans ce fichier */
#endif /* OUTPUT_PCM */
packet = (AVPacket *)av_malloc(sizeof(AVPacket)); /* Allouer taille */
av_init_packet(packet);
out_channel_layout = AV_CH_LAYOUT_MONO; /* Canaux de sortie */
out_nb_samples = pCodecCtx->frame_size; /* L'échantillonnage - Le nombre de samples*/
out_sample_fmt = AV_SAMPLE_FMT_S16; /* Format */
out_sample_rate = 44100; /* Fréquence */
out_channels = av_get_channel_layout_nb_channels(out_channel_layout); /* Récupérer le nombre de canaux */
/*
// printf("%d\n", out_channels);
// system("PAUSE");
*/
out_buffer_size = av_samples_get_buffer_size(NULL, out_channels, out_nb_samples, out_sample_fmt, 1); /* Taille du buffer */
out_buffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE * 2); /* Allouer taille */
pFrame = av_frame_alloc(); /* Allouer taille */
#if USE_SDL
if (SDL_Init(SDL_INIT_VIDEO |SDL_INIT_AUDIO | SDL_INIT_TIMER)) /* Initialiser SDL */
{
fprintf(stderr, "%s - %s\n", "Couldn't initialize SDL", SDL_GetError());
return (-1);
}
/*
// Attribution des valeurs avec les variables au-dessus
*/
wanted_spec.freq = out_sample_rate;
wanted_spec.format = AUDIO_S16SYS;
wanted_spec.channels = out_channels;
wanted_spec.silence = 0;
wanted_spec.samples = out_nb_samples;
wanted_spec.callback = fill_audio;
wanted_spec.userdata = pCodecCtx;
if (SDL_OpenAudio(&wanted_spec, NULL) < 0)
{
fprintf(stderr, "%s\n", "Can't open audio");
return (-1);
}
#endif /* USE_SDL */
in_channel_layout = av_get_default_channel_layout(pCodecCtx->channels);
au_convert_ctx = swr_alloc();
au_convert_ctx = swr_alloc_set_opts(au_convert_ctx, out_channel_layout, out_sample_fmt, out_sample_rate,
in_channel_layout, pCodecCtx->sample_fmt, pCodecCtx->sample_rate, 0, NULL);
swr_init(au_convert_ctx);
while (av_read_frame(pFormatCtx, packet) >= 0) /* Lecture du fichier */
{
if (packet->stream_index == audioStream)
{
ret = avcodec_decode_audio4(pCodecCtx, pFrame, &got_picture, packet); /* Décoder les packets */
if (ret < 0)
{
fprintf(stderr, "%s\n", "Error in decoding audio frame");
return (-1);
}
if (got_picture > 0)
{
swr_convert(au_convert_ctx, &out_buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **)pFrame->data, pFrame->nb_samples);
#if 1
printf("Index : %5d\t Points : %lld\t Packet size : %d\n", index, packet->pts, packet->size); /* Affichage des informations sur la console */
#endif /* 1 */
#if OUTPUT_PCM
fwrite(out_buffer, 1, out_buffer_size, pFile); /* Faire l'écriture dans le fichier */
#endif /* OUTPUT_PCM */
index = index + 1;
}
#if USE_SDL
while (audio_len > 0)
SDL_Delay(1);
audio_chunk = (Uint8 *)out_buffer;
audio_len = out_buffer_size;
audio_pos = audio_chunk;
SDL_PauseAudio(0);
#endif /* USE_SDL */
}
av_free_packet(packet); /* Libérer les packets */
}
swr_free(&au_convert_ctx); /* Libérer la taille de conversion */
#if USE_SDL
SDL_CloseAudio(); /* Arrêter le son dans SDL */
SDL_Quit(); /* Quitter SDL */
#endif /* USE_SDL */
#if OUTPUT_PCM
fclose(pFile); /* Fermer le fichier d'écriture */
#endif /* OUTPUT_PCM */
av_free(out_buffer);
avcodec_close(pCodecCtx); /* Fermer le décodeur */
avformat_close_input(&pFormatCtx); /* Fermer le fichier lu */
return (0);
}
int main(int argc, char **argv)
{
if (argc != 2)
{
fprintf(stderr, "%s\n", "Usage : ./BASELFI [File]");
system("PAUSE");
return (-1);
}
else
{
reading_sound(argv[1]);
return (0);
}
return (0);
} -
Evolution #3071 : Performance boucle DATA sur CSV
15 octobre 2013, par esj -De l’utilité de faire "svn cp" et non une copie dans éditeur perso pour que l’historique d’un code soit facile à retrouver.
Ce code est apparu en 2007 dans r10948 qui répondait à une difficulté signalée dans Spip-contrib, à laquelle il fut répondu par un code, documenté sur spipnet comme il se doit :
http://contrib.spip.net/Creer-de-grands-tableaux-dans-SPIP,9#forum401060Cette fonction faisait alors 3 lignes, c’était plus rapide à écrire que de regarder si PHP avait l’équivalent en magasin.
Ensuite, il y a eu quantités de signalements de problèmes, ce format propriétaire à l’origine ayant un RFC tardif et imprécis dont tout le monde se fout,
d’où un code qui n’a pas cessé de croître avec les années (r11111, r11113, r13859, r14013 surtout). Au vu du commentaire dans la doc PHP de fgetcsv, ce code semble toujours d’actualité. En tout cas il y a intérêt à vérifier que les cas signalés dans les logs des commit ci-dessous sont bien pris en compte par cette fonction avant de mettre le code des autres à la poubelle sans chercher à comprendre, marque de fabrique de SPIP3. -
FFmpeg : How to create rotating 3D(haas) effect in mp3 using ffmpeg ?
30 octobre 2018, par AnkushI want to add a rotating 3d effect(Haas effect) in mp3. I mean that the audio will seem to change its directions from left to right and vice versa periodically(as shown below) when listened through the headphone. For this, I searched on the Internet and tried to achieve it in the following ways :
- Firstly, I thought, if I change the audio of the left and right channel periodically( Like when the Right channel has full volume(100%), Left channel has low volume(20%) and vice versa) then I can achieve it but it’s not like 3D.
- Secondly, When I researched more than found that It is done by creating a delay between the two channels. I found that I can create a delay of 0.0 to 0.8 milliseconds according to requirement.
To do this, I use the following commands in FFmpeg :
Step 1 : Splitting Audio Channels :
ffmpeg -i D:\ffmpeg\Down.mp3 -map_channel 0.0.0 D:\ffmpeg\L.mp3 -map_channel 0.0.1 D:\ffmpeg\R.mp3
Stem 2 : Splitting Left channel into parts :
Note : We will only change the speed of Left channel so we split Left
channel into 4 seconds parts.ffmpeg -i D:\ffmpeg\L.mp3 -f segment -segment_time 4 D:\ffmpeg\Split\%03d.mp3
Step 3 : Changing the tempo of each part
Now We change the tempo (speed) of each part so it may feel like the sound
is moving from left to right and vice versaffmpeg -y -i D:\ffmpeg\Split\000.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\000.mp3
ffmpeg -y -i D:\ffmpeg\Split\001.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\001.mp3
ffmpeg -y -i D:\ffmpeg\Split\002.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\002.mp3
ffmpeg -y -i D:\ffmpeg\Split\003.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\003.mp3
ffmpeg -y -i D:\ffmpeg\Split\004.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\004.mp3
ffmpeg -y -i D:\ffmpeg\Split\005.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\005.mp3
ffmpeg -y -i D:\ffmpeg\Split\006.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\006.mp3
ffmpeg -y -i D:\ffmpeg\Split\007.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\007.mp3
ffmpeg -y -i D:\ffmpeg\Split\008.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\008.mp3
ffmpeg -y -i D:\ffmpeg\Split\009.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\009.mp3
ffmpeg -y -i D:\ffmpeg\Split\010.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\010.mp3
ffmpeg -y -i D:\ffmpeg\Split\011.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\011.mp3
ffmpeg -y -i D:\ffmpeg\Split\012.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\012.mp3
ffmpeg -y -i D:\ffmpeg\Split\013.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\013.mp3
ffmpeg -y -i D:\ffmpeg\Split\014.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\014.mp3
ffmpeg -y -i D:\ffmpeg\Split\015.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\015.mp3
ffmpeg -y -i D:\ffmpeg\Split\016.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\016.mp3
ffmpeg -y -i D:\ffmpeg\Split\017.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\017.mp3
ffmpeg -y -i D:\ffmpeg\Split\018.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\018.mp3
ffmpeg -y -i D:\ffmpeg\Split\019.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\019.mp3
ffmpeg -y -i D:\ffmpeg\Split\020.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\020.mp3
ffmpeg -y -i D:\ffmpeg\Split\021.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\021.mp3
ffmpeg -y -i D:\ffmpeg\Split\022.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\022.mp3
ffmpeg -y -i D:\ffmpeg\Split\023.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\023.mp3
ffmpeg -y -i D:\ffmpeg\Split\024.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\024.mp3
ffmpeg -y -i D:\ffmpeg\Split\025.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\025.mp3
ffmpeg -y -i D:\ffmpeg\Split\026.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\026.mp3
ffmpeg -y -i D:\ffmpeg\Split\027.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\027.mp3
ffmpeg -y -i D:\ffmpeg\Split\028.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\028.mp3
ffmpeg -y -i D:\ffmpeg\Split\029.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\029.mp3
ffmpeg -y -i D:\ffmpeg\Split\030.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\030.mp3
ffmpeg -y -i D:\ffmpeg\Split\031.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\031.mp3
ffmpeg -y -i D:\ffmpeg\Split\032.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\032.mp3
ffmpeg -y -i D:\ffmpeg\Split\033.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\033.mp3
ffmpeg -y -i D:\ffmpeg\Split\034.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\034.mp3
ffmpeg -y -i D:\ffmpeg\Split\035.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\035.mp3
ffmpeg -y -i D:\ffmpeg\Split\036.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\036.mp3
ffmpeg -y -i D:\ffmpeg\Split\037.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\037.mp3
ffmpeg -y -i D:\ffmpeg\Split\038.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\038.mp3
ffmpeg -y -i D:\ffmpeg\Split\039.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\039.mp3
ffmpeg -y -i D:\ffmpeg\Split\040.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\040.mp3
ffmpeg -y -i D:\ffmpeg\Split\041.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\041.mp3
ffmpeg -y -i D:\ffmpeg\Split\042.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\042.mp3
ffmpeg -y -i D:\ffmpeg\Split\043.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\043.mp3
ffmpeg -y -i D:\ffmpeg\Split\044.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\044.mp3
ffmpeg -y -i D:\ffmpeg\Split\045.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\045.mp3
ffmpeg -y -i D:\ffmpeg\Split\046.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\046.mp3
ffmpeg -y -i D:\ffmpeg\Split\047.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\047.mp3
ffmpeg -y -i D:\ffmpeg\Split\048.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\048.mp3
ffmpeg -y -i D:\ffmpeg\Split\049.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\049.mp3
ffmpeg -y -i D:\ffmpeg\Split\050.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\050.mp3
ffmpeg -y -i D:\ffmpeg\Split\051.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\051.mp3
ffmpeg -y -i D:\ffmpeg\Split\052.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\052.mp3
ffmpeg -y -i D:\ffmpeg\Split\053.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\053.mp3
ffmpeg -y -i D:\ffmpeg\Split\054.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\054.mp3Here I used 1.0000 for normal speed
and 1.0008 for increased speed
and 0.9992 for decreased speedSpet 4 : Merging small pieces of audio
ffmpeg -f concat -safe 0 -i D:\ffmpeg\f.txt -c copy D:\ffmpeg\output.mp3
where f.txt contains :
file 'D:\ffmpeg\Modi\000.mp3'
file 'D:\ffmpeg\Modi\001.mp3'
file 'D:\ffmpeg\Modi\002.mp3'
file 'D:\ffmpeg\Modi\003.mp3'
file 'D:\ffmpeg\Modi\004.mp3'
file 'D:\ffmpeg\Modi\005.mp3'
file 'D:\ffmpeg\Modi\006.mp3'
file 'D:\ffmpeg\Modi\007.mp3'
file 'D:\ffmpeg\Modi\008.mp3'
file 'D:\ffmpeg\Modi\009.mp3'
file 'D:\ffmpeg\Modi\010.mp3'
file 'D:\ffmpeg\Modi\011.mp3'
file 'D:\ffmpeg\Modi\012.mp3'
file 'D:\ffmpeg\Modi\013.mp3'
file 'D:\ffmpeg\Modi\014.mp3'
file 'D:\ffmpeg\Modi\015.mp3'
file 'D:\ffmpeg\Modi\016.mp3'
file 'D:\ffmpeg\Modi\017.mp3'
file 'D:\ffmpeg\Modi\018.mp3'
file 'D:\ffmpeg\Modi\019.mp3'
file 'D:\ffmpeg\Modi\020.mp3'
file 'D:\ffmpeg\Modi\021.mp3'
file 'D:\ffmpeg\Modi\022.mp3'
file 'D:\ffmpeg\Modi\023.mp3'
file 'D:\ffmpeg\Modi\024.mp3'Step 5 : The last operation is combining the both channels :
ffmpeg -i D:\ffmpeg\L.mp3 -i D:\ffmpeg\output.mp3 -filter_complex [0:a][1:a]amerge=inputs=2[aout] -map [aout] D:\ffmpeg\LRM.mp3
But even then the result is very poor. It looks like FFmpeg combines audio in Step 4 took a delay after each audio.
I think there may be some bug in my solution. I don’t think that I can change tempo like this in audio without splitting the audio(Let me know if I am wrong).
Does anyone have a different solution to achieve this ?
Please help me in this. Thanks in advance...