
Recherche avancée
Médias (1)
-
1 000 000 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (76)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)
Sur d’autres sites (3642)
-
if there is a way to add text to each image used to create video using ffmpeg ?
1er mai 2020, par Mahmood HussainI have successfully created a video (slide show) using FFmpeg from images and an additional text to it. Now I want the timestamp to be added as overlay text to each image.



If the image is named 20191224133501.jpg I want 24 Dec 2019 01:35 PM as text over the image.


-
Some H264-mp4 videos can't be loaded by any non-Chromium based web browser
3 mai 2020, par LaizrodI regularly use ffmpeg to encode some videos, blu-ray etc in mp4 files (encoded in H264 and AAC) in order to be played on web browsers.
Chromium based browsers such as Google Chrome or the new Microsoft Edge can play all of my files flawlessly.
But today I noticed that some video files couldn't be loaded by some web browsers. It looks like they can't be loaded by any non-Chromium based web browser. (Safari, Firefox etc..)



So I decided to check out and compare the specs of files that work with any web browser, and files that doesn't work with non-Chromium based browsers.



There's what I got :



- 

- Playable by any web browser :





General
Complete name : /storage/100.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/iso2/avc1/mp41)
File size : 624 MiB
Duration : 23 min 54 s
Overall bit rate : 3 648 kb/s
Encoded date : UTC 2019-10-02 22:15:27
Tagged date : UTC 2019-10-02 22:15:27
Writing application : HandBrake 1.2.2 2019022300

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 1 frame
Format settings, GOP : M=3, N=24
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 23 min 54 s
Bit rate : 3 481 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 23.976 (24000/1001) FPS
Minimum frame rate : 23.974 FPS
Maximum frame rate : 23.981 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.070
Stream size : 595 MiB (95%)
Encoded date : UTC 2019-10-02 22:15:27
Tagged date : UTC 2019-10-02 22:15:27
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 23 min 54 s
Bit rate mode : Constant
Bit rate : 160 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 27.4 MiB (4%)
Title : Stereo
Language : Japanese
Default : Yes
Alternate group : 1
Encoded date : UTC 2019-10-02 22:15:27
Tagged date : UTC 2019-10-02 22:15:27




- 

- Unplayable by non-chromium based web browsers :





General
Complete name : /storage/DL/test.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 329 MiB
Duration : 23 min 52 s
Overall bit rate : 1 926 kb/s
Writing application : Lavf58.20.100

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 23 min 52 s
Bit rate : 1 792 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.036
Stream size : 306 MiB (93%)
Writing library : x264 core 155 r2917 0a84d98
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=34 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : Japanese
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 23 min 52 s
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 21.9 MiB (7%)
Language : Japanese
Default : Yes
Alternate group : 1




My knowledge is limited and I'm unable to understand why and which differences are causing my issue.
Can someone identify the problem and help me fix it with ffmpeg ?



Thank you


-
FFmpeg Opus choppy sound UPDATED DESCRIPTION
2 juin 2020, par easy_breezyI'm using FFmpeg and try to encode and decode a raw PCM sound to Opus using a built-in FFmpeg "opus" codec. My input samples are raw PCM 8000 Hz 16 bit mono, in AV_SAMPLE_FMT_S16 format. Since Opus requires sample format AV_SAMPLE_FMT_FLTP and sample rate 48000 Hz only, so I resample my samples before encode them.



I have two instances of
ResamplerAudio
class that does the work of resampling audio samples and has a member ofSwrContext
, I use the first instance ofResamplerAudio
for resampling a raw PCM input audio before encoding and the second for resampling decoded audio to get it's format and sample rate the same as source values of input raw audio.


ResamplerAudio class has a function that init it's SwrContext member like this :



void ResamplerAudio::init(AVCodecContext *codecContext, int inSampleRate, int outSampleRate, AVSampleFormat inSampleFmt, AVSampleFormat outSampleFmt)
{
 swrContext = swr_alloc();
 if (!swrContext)
 {
 LOGE(TAG, "[init] Couldn't allocate swr context");
 return;
 }

 av_opt_set_int(swrContext, "in_channel_layout", (int64_t) codecContext->channel_layout, 0);
 av_opt_set_int(swrContext, "out_channel_layout", (int64_t) codecContext->channel_layout, 0);

 av_opt_set_int(swrContext, "in_channel_count", codecContext->channels, 0);
 av_opt_set_int(swrContext, "out_channel_count", codecContext->channels, 0);

 av_opt_set_int(swrContext, "in_sample_rate", inSampleRate, 0);
 av_opt_set_int(swrContext, "out_sample_rate", outSampleRate, 0);

 av_opt_set_sample_fmt(swrContext, "in_sample_fmt", inSampleFmt, 0);
 av_opt_set_sample_fmt(swrContext, "out_sample_fmt", outSampleFmt, 0);

 int ret = swr_init(swrContext);
 if (ret < 0)
 {
 LOGE(TAG, "[init] swr_init error: %s", av_err2str(ret));
 return;
 }

 LOGD(TAG, "[init] success codecContext->channel_layout: %d; inSampleRate: %d; outSampleRate: %d; inSampleFmt: %d; outSampleFmt: %d", (int) codecContext->channel_layout, inSampleRate, outSampleRate, inSampleFmt, outSampleFmt);
}




And I call
ResamplerAudio::init
function for the first instance ofResamplerAudio
(this instance do resamping a raw PCM input audio before encoding and I called itresamplerEncoder
) with the following args :


resamplerEncoder->init(contextEncoder, 8000, 48000, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP);




The second instance of
ResamplerAudio
(this instance do resamping after decoding audio from Opus and I called itresamplerDecoder
) I init with the following args :


resamplerDecoder->init(contextDecoder, 48000, 8000, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16);




The function of
ResamplerAudio
that does resampling looks like this :


std::vector ResamplerAudio::convert(uint8_t **inData, int inSamplesCount, int outChannels, int outFormat)
{
 std::vector result;
 uint8_t *dstData = NULL;
 const int dstNbSamples = swr_get_out_samples(swrContext, inSamplesCount);
 av_samples_alloc(&dstData, NULL, outChannels, dstNbSamples, AVSampleFormat(outFormat), 1);
 int resampledSize = swr_convert(swrContext, &dstData, dstNbSamples, (const uint8_t **)inData, inSamplesCount);
 int dstBufSize = av_samples_get_buffer_size(NULL, outChannels, resampledSize, AVSampleFormat(outFormat), 1);

 if (dstBufSize <= 0) return result;

 std::copy(&dstData[0], &dstData[dstBufSize], std::back_inserter(result));

 return result;
}




And I call
ResamplerAudio::convert
function before encoding with the following args :


// data - an array of raw pcm audio
// dataLength - the length of data array
// getSamplesCount() - function that calculates samples count
// frameEncode - AVFrame that using for encode audio
std::vector resampledData = resamplerEncoder->convert(&data, getSamplesCount(dataLength, frameEncode->channels, AV_SAMPLE_FMT_S16), frameEncode->channels, frameEncode->format);




getSamplesCount()
function looks like this :


getSamplesCount(int bytesCount, int channels, AVSampleFormat format)
{
 return bytesCount / av_get_bytes_per_sample(format) / channels;
}




After that I fill my
frameEncode
with resampled samples :


memcpy(&frame->data[0][0], &resampledData[0], sizeof(uint8_t) * resampledDataLength);




And pass
frameEncode
to encoding like thisencodeFrame(resampledDataLength)
:


void encodeFrame(int dataLength)
{
 /* send the frame for encoding */
 int ret = avcodec_send_frame(contextEncoder, frameEncode);
 if (ret < 0)
 {
 LOGE(TAG, "[encodeFrame] avcodec_send_frame error: %s", av_err2str(ret));
 return;
 }

 /* read all the available output packets (in general there may be any number of them */
 while (ret >= 0)
 {
 ret = avcodec_receive_packet(contextEncoder, packetEncode);
 if (ret < 0 && ret != AVERROR(EAGAIN)) LOGE(TAG, "[encodeFrame] error in avcodec_receive_packet: %s", av_err2str(ret));
 if (ret < 0) break;

 // encodedData - std::vector that stores encoded data
 std::copy(&packetEncode->data[0], &packetEncode->data[dataLength], std::back_inserter(encodedData));
 av_packet_unref(packetEncode);
 }
}




Then I decode my encoded samples and do resampling to get back them in source sample format and sample rate so I call
ResamplerAudio::convert
function forresamplerDecoder
with the following args :


// frameDecode - AVFrame that holds decoded audio
std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);




And result sound is choppy and I also noticed that the decoded array size is bigger than the source array size with raw pcm audio.



Please any ideas what I'm doing wrong ?



UPD 18.05.2020



I tested my resampling logic, I did resampling of raw pcm sound without any encoding and decoding routines. First I tried to convert the sample rate of input sound from 8000 Hz to 48000 Hz than I took resampled samples from step above and convert it's sample rate from 48000 Hz to 8000 Hz and the result sound is perfect and clean, also I did the same steps but I converted not a sample rate but a sample format from AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_FLTP and vice versa and again the result sound is perfect and clean, also I got the same result when I coverted both a sample rate and a sample format.
So I assume that the problem of distorted and choppy sound is in my encoding or decoding routine, I think most likely in decoding routine because after decoding I ALWAYS get AVFrame with 960 nb_samples despite what was the size of input sound.



My decoding routine looks like this :



std::vector decode(uint8_t *data, unsigned int dataLength)
{
 decodedData.clear();

 int dataSize = dataLength;

 while (dataSize > 0)
 {
 if (!frameDecode)
 {
 frameDecode = av_frame_alloc();
 if (!frameDecode)
 {
 LOGE(TAG, "[decode] Couldn't allocate the frame");
 return EMPTY_DATA;
 }
 }

 ret = av_parser_parse2(parser, contextDecoder, &packetDecode->data, &packetDecode->size, &data[0], dataSize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
 if (ret < 0) {
 LOGE(TAG, "[decode] av_parser_parse2 error: %s", av_err2str(ret));
 return EMPTY_DATA;
 }

 data += ret;
 dataSize -= ret;

 doDecode();
 }
 return decodedData;
}

void doDecode()
{
 if (packetDecode->size) {
 /* send the packet with the compressed data to the decoder */
 int ret = avcodec_send_packet(contextDecoder, packetDecode);
 if (ret < 0) LOGE(TAG, "[decode] avcodec_send_packet error: %s", av_err2str(ret));

 /* read all the output frames (in general there may be any number of them */
 while (ret >= 0)
 {
 ret = avcodec_receive_frame(contextDecoder, frameDecode);
 if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) LOGE(TAG, "[decode] avcodec_receive_frame error: %s", av_err2str(ret));
 if (ret < 0) break;

 std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);
 if (!resampledData.size()) continue;
 std::copy(&resampledData.data()[0], &resampledData.data()[resampledData.size()], std::back_inserter(decodedData));
 }
 }
}




UPD 30.05.2020



I decided to refuse to use FFmpeg in my project and use libopus 1.3.1 instead, so I made a wrapper around it and it works fine.