
Recherche avancée
Médias (21)
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (54)
-
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 -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (8226)
-
How can I dynamically update metadata in audio output with libav so that updates appear in MPV ?
9 mars, par TeddyMy ultimate goal is to proxy an internet radio station and programmatically add metadata to it during the stream that can be displayed and updated in MPV, the media player playing the audio.


The metadata I would like to add is primarily the song title, but ideally additional information including artist, composer, and album.


I envision running the proxy program like this :


$ curl https://example.com/stream.mp3 | ./proxy_add_metadata | mpv -



or maybe this :


$ ./proxy_add_metadata &
#=> <output>
$ mpv <output>
</output></output>


How could I make song metadata updates dynamically over time using libav ?


I’m using FFmpeg version 7.1.


I first tried changing the metadata dictionary shortly before writing a frame with a few different container formats :


av_dict_set(&output_ctx->metadata, "title", "Title 1", 0);
/* [...] */
av_interleaved_write_frame(output_ctx, packet);



Setting metadata with
av_dict_set(&output_ctx->metadata, "title", "Title 1", 0);
only appears to work when done before writing the output header.

My next idea was to try setting metadata in
AVPacket
side data, but I’m unclear which container formats support this for the kind of metadata I’m working with.

I’m open to any output media container format or FFmpeg-originated network stream.


It’s unclear to me whether the metadata should be written to a separate stream within the media container or whether it should be written as side data in the output packets.


If what I’m trying to do is impossible, please explain why.


What I have so far reads audio from standard input and writes it to standard output. The input audio can be assumed to be in MP3 format. Non-working sections for metadata updates are commented out.


/* proxy_add_metadata.c */
#include 

#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>

int main() {
 int _err;

 /* MP3 input */
 AVFormatContext *input_ctx = avformat_alloc_context();
 _err = avformat_open_input(&input_ctx, "pipe:0", NULL, NULL);
 _err = avformat_find_stream_info(input_ctx, NULL);

 AVFormatContext *output_ctx;
 _err = avformat_alloc_output_context2(&output_ctx, NULL, "matroska", "pipe:1");

 AVStream *input_stream = input_ctx->streams[0];
 AVStream *output_stream = avformat_new_stream(output_ctx, NULL);

 _err = avcodec_parameters_copy(output_stream->codecpar, input_stream->codecpar);
 _err = avio_open(&output_ctx->pb, "pipe:1", AVIO_FLAG_WRITE);

 _err = avformat_write_header(output_ctx, NULL);

 AVPacket *packet = av_packet_alloc();

 /* Set up packet side data. */
 /*
 AVDictionary *packet_side_data_dict;
 av_dict_set(&packet_side_data_dict, "title", "Title 1", 0);

 size_t packet_side_data_size = 0;
 uint8_t *packet_side_data = av_packet_pack_dictionary(
 packet_side_data_dict,
 &packet_side_data_size
 );
 av_dict_free(&packet_side_data_dict);
 */

 while (1) {
 _err = av_read_frame(input_ctx, packet);
 if (_err < 0) {
 break;
 }

 /* Can metadata updates be made here? */

 /* Option 1: Attempt to write metadata to the container. */
 /*
 _err = av_dict_set(&output_ctx->metadata, "title", "Title 1", 0);
 if (_err < 0) {
 fprintf(stderr, "error: can't set metadata title in stream: %s\n", av_err2str(_err));
 break;
 }
 */

 /* Option 2: Attempt to write metadata to packet side data. */
 /*
 _err = av_packet_add_side_data(
 packet,
 AV_PKT_DATA_METADATA_UPDATE,
 packet_side_data,
 packet_side_data_size
 );
 if (_err < 0) {
 fprintf(stderr, "error: can't add side data to packet: %s\n", av_err2str(_err));
 break;
 }
 */

 AVStream *input_stream = input_ctx->streams[packet->stream_index];
 AVStream *output_stream = output_ctx->streams[packet->stream_index];

 av_packet_rescale_ts(packet, input_stream->time_base, output_stream->time_base);
 packet->pos = -1;

 _err = av_interleaved_write_frame(output_ctx, packet);
 if (_err < 0) {
 fprintf(stderr, "error: packet write: %s\n", av_err2str(_err));
 break;
 }
 }

 av_write_trailer(output_ctx);

 av_packet_free_side_data(packet);
 av_packet_free(&packet);

 avio_closep(&output_ctx->pb);
 avformat_free_context(output_ctx);

 avformat_close_input(&input_ctx);

 return 0;
}



cc \
 -Wall \
 -g \
 -I/.../ffmpeg7/include \
 -o proxy_add_metadata \
 proxy_add_metadata.c \
 -L/.../ffmpeg7/lib -lavformat -lavcodec



$ < sample.mp3 ./proxy_add_metadata | mpv -



-
ffmpeg produced .wav reads only zeros with scipy.io.wavfile
8 janvier 2015, par question_markHi everyone and thanks for reading.
I wanted to do some analysis on a song using Python’s scipy.io.wavfile. Since I only have the song as .mp3 I converted the file to .wav using ffmpeg the following way :
ffmpeg -i test.mp3 test.wav
The .wav file plays perfectly well with vlc player, but wavfile shows only zeroes when reading it :
from scipy.io import wavfile as wf
data = wf.read("test.wav")
C:\Program Files\Anaconda\lib\site-packages\scipy\io\wavfile.py:42: WavFileWarning: Unknown wave file format
warnings.warn("Unknown wave file format", WavFileWarning)
data
(44100, array([[0, 0],
[0, 0],
[0, 0],
...,
[0, 0],
[0, 0],
[0, 0]], dtype=int16))I tried getting the data with Python’s built-in wave module before to the same effect (only zeros).
I am using the 64bit version of ffmpeg (ffmpeg-20140218-git-61d5970-win64-static).Any help is appreciated :-)
Edit : Included .wav header and tried forcing ffmpeg output format
I guess the header information of the .wav file is included here :
ffmpeg -i .\test.wav
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from '.\test.wav':
Metadata:
artist : Joe Cocker
copyright : (C) 1987 Capitol Records, Inc.
date : 1987
genre : Pop
title : Unchain My Heart
album : Unchain My Heart
track : 1/10
encoder : Lavf55.33.100
Duration: 00:05:04.33, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/sIf I try to specify the ffmpeg output format explicitly for the .mp3 conversion :
ffmpeg -i .\test.mp3 -f s16le -ar 44100 -ac 2 test.wav
Input #0, mp3, from '.\test.mp3':
Metadata:
title : Unchain My Heart
artist : Joe Cocker
album : Unchain My Heart
genre : Pop
composer : Bobby Sharp
track : 1/10
disc : 1/1
album_artist : Joe Cocker
copyright : (C) 1987 Capitol Records, Inc.
date : 1987
Duration: 00:05:04.35, start: 0.025056, bitrate: 240 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 235 kb/s
Stream #0:1: Video: mjpeg, yuvj420p(pc), 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
title :
comment : Cover (front)
Output #0, s16le, to 'test.wav':
Metadata:
title : Unchain My Heart
artist : Joe Cocker
album : Unchain My Heart
genre : Pop
composer : Bobby Sharp
track : 1/10
disc : 1/1
album_artist : Joe Cocker
copyright : (C) 1987 Capitol Records, Inc.
date : 1987
encoder : Lavf55.33.100
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 -> pcm_s16le)
Press [q] to stop, [?] for help
video:0kB audio:52425kB subtitle:0 data:0 global headers:0kB muxing overhead 0.000000%
size= 52425kB time=00:05:04.32 bitrate=1411.2kbits/sBut in this case (forced format), both ffmpeg and wavfile are not able to read the file :
ffmpeg -i .\test.wav
.\test.wav: Invalid data found when processing inputand
data = wf.read("test2.wav")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in <module>()
----> 1 data = wf.read("test2.wav")
C:\Program Files\Anaconda\lib\site-packages\scipy\io\wavfile.pyc in read(filename, mmap)
152
153 try:
--> 154 fsize = _read_riff_chunk(fid)
155 noc = 1
156 bits = 8
C:\Program Files\Anaconda\lib\site-packages\scipy\io\wavfile.pyc in _read_riff_chunk(fid)
98 _big_endian = True
99 elif str1 != b'RIFF':
--> 100 raise ValueError("Not a WAV file.")
101 if _big_endian:
102 fmt = '>I'
ValueError: Not a WAV file.
</module> -
ffmpeg probesize and analyzeduration flags
7 mai 2014, par XerphielCould someone explain to me in simple terms what these flags/options do ?
Running "ffmpeg -h full | grep probesize/analyzeduration" yields the following documentation :
-probesize <int> .D.... set probing size (from 32 to INT_MAX) (default 5e+06)
-analyzeduration <int> .D.... specify how many microseconds are analyzed to probe the input (from 0 to INT_MAX) (default 5e+06)
</int></int>This is beyond my understanding, so am hoping for a simpler explanation.
All the discussions on this subject I’ve found via googling do not describe the basic function of the options.
Any help is appreciated.
Thank you.