
Recherche avancée
Médias (17)
-
Matmos - Action at a Distance
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Danger Mouse & Jemini - What U Sittin’ On ? (starring Cee Lo and Tha Alkaholiks)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Cornelius - Wataridori 2
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Rapture - Sister Saviour (Blackstrobe Remix)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Chuck D with Fine Arts Militia - No Meaning No
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (49)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
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" (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs
Sur d’autres sites (7660)
-
How to dump ALL metadata from a media file, including cover image title ? [closed]
9 avril, par UnidealI have an MP3 song :


# ffprobe -hide_banner -i filename.mp3
Input #0, mp3, from 'filename.mp3':
 Metadata:
 composer : Music Author
 title : Song Name
 artist : Singer
 encoder : Lavf61.7.100
 genre : Rock
 date : 2025
 Duration: 00:03:14.04, start: 0.023021, bitrate: 208 kb/s
 Stream #0:0: Audio: mp3 (mp3float), 48000 Hz, stereo, fltp, 192 kb/s
 Metadata:
 encoder : Lavc61.19
 Stream #0:1: Video: png, rgb24(pc, gbr/unknown/unknown), 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
 Metadata:
 title : Cover
 comment : Cover (front)



The task is to save its metadata to a text file and restore from that file later. Both goals should be accomplished with ffmpeg.


The simpliest method is to run :


# ffmpeg -i filename.mp3 -f ffmetadata metadata.txt



After that,
metadata.txt
contains :

;FFMETADATA1
composer=Music Author
title=Song Name
artist=Singer
date=2025
genre=Rock
encoder=Lavf61.7.100



I got global metadata only, but stream-specific info (cover image title and comment in my case) are missing.


Google suggested a more complex form of the command above to extract all metadata fields without any exclusions :


# ffmpeg -y -i filename.mp3 -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -f ffmetadata metadata.txt



But the output is exactly the same :


;FFMETADATA1
composer=Music Author
title=Song Name
artist=Singer
date=2025
genre=Rock
encoder=Lavf61.7.100



Again, no info about the attached image.


Please explain what am I doing wrong.


-
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>


-
libav live transcode to SFML SoundStream, grabbled and noise
19 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>