
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 (13)
-
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...) -
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 (...) -
Les thèmes de MediaSpip
4 juin 20133 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
Thèmes MediaSPIP
3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)
Sur d’autres sites (2388)
-
How do I change audio language using ffmpeg in video files contaning two or more audio tracks
19 mai 2020, par warezsoftwarezI am transcoding video files, that contain 2 audio tracks - Polish and English. Unfortunately my transcoder messes somehow with metadata, and at the output, when I'm checking video file using MediaInfo, i see that both audio tracks are described as English. I'd like to change description of 1st audio track to Polish, so accordingly to ffmpeg documentation :



To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT




Unfortunately, running command :



ffmpeg -i INPUTPATH -metadata:s:a:0 language=pol OUTPUTPATH




to overwrite input file resulted in saving file thats size is 63KB but it is described as Polish audio (no second audio track - English somehow was deleted)



When I used this command, to save output file as another file, to avoid overwriting if something misses (which is current situation), but using parameter
-metadata:s:a:4
because I thought that maybe I'm reading metadata from ffmpeg incorrectly, it resulted in saving output file as 800Mb with only English (no Polish track).


I don't know what should I change in this command to run as I want it to - just changing metadata of first audio track language to Polish.



Here is full ffmpeg output :



C:\Users\user>ffmpeg -i F:\Path\33244813_6000_1_trailer.mp4 -metadata:s:a:4 language=pol F:\Path\testtest.mp4
ffmpeg version N-91931-gb69ea742ab Copyright (c) 2000-2018 the FFmpeg developers
 built with gcc 8.2.1 (GCC) 20180813
 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enabl
e-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amr
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enab
le-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc -
-enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --e
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
 libavutil 56. 19.101 / 56. 19.101
 libavcodec 58. 30.100 / 58. 30.100
 libavformat 58. 18.100 / 58. 18.100
 libavdevice 58. 4.103 / 58. 4.103
 libavfilter 7. 29.100 / 7. 29.100
 libswscale 5. 2.100 / 5. 2.100
 libswresample 3. 2.100 / 3. 2.100
 libpostproc 55. 2.100 / 55. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\Path\33244813_6000_1_trailer.mp4':
 Metadata:
 major_brand : isom
 minor_version : 1
 compatible_brands: isom
 creation_time : 2020-04-22T16:18:04.000000Z
 Duration: 00:40:39.12, start: 0.000000, bitrate: 8848 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], Closed C
aptions, 5068 kb/s, 25 fps, 25 tbr, 120k tbn, 50 tbc (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Video
 Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], Closed C
aptions, 1857 kb/s, 25 fps, 25 tbr, 120k tbn, 50 tbc (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Video
 Stream #0:2(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], Closed Ca
ptions, 902 kb/s, 25 fps, 25 tbr, 120k tbn, 50 tbc (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Video
 Stream #0:3(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x480 [SAR 4:3 DAR 16:9], Closed Cap
tions, 628 kb/s, 25 fps, 25 tbr, 120k tbn, 50 tbc (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Video
 Stream #0:4(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Sound
 Stream #0:5(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 253 kb/s (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Sound
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
 Stream #0:5 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000012bef91f80] using SAR=1/1
[libx264 @ 00000012bef91f80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000012bef91f80] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 00000012bef91f80] 264 - core 157 r2932 303c484 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.vid
eolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=34 looka
head_threads=5 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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookah
ead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'F:\Path\testtest.mp4'
:
 Metadata:
 major_brand : isom
 minor_version : 1
 compatible_brands: isom
 encoder : Lavf58.18.100
 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps,
 12800 tbn, 25 tbc (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Video
 encoder : Lavc58.30.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 341 kb/s (default)
 Metadata:
 creation_time : 2020-04-22T16:18:04.000000Z
 handler_name : Sound
 encoder : Lavc58.30.100 aac
frame=60981 fps= 84 q=-1.0 Lsize= 816313kB time=00:40:39.12 bitrate=2741.7kbits/s dup=3 drop=0 speed=3.36x
video:713292kB audio:101322kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.208512%
[libx264 @ 00000012bef91f80] frame I:769 Avg QP:16.36 size: 46713
[libx264 @ 00000012bef91f80] frame P:37125 Avg QP:19.81 size: 15059
[libx264 @ 00000012bef91f80] frame B:23087 Avg QP:21.11 size: 5866
[libx264 @ 00000012bef91f80] consecutive B-frames: 40.4% 24.0% 10.2% 25.5%
[libx264 @ 00000012bef91f80] mb I I16..4: 40.3% 58.0% 1.7%
[libx264 @ 00000012bef91f80] mb P I16..4: 6.2% 12.5% 0.1% P16..4: 29.8% 3.7% 2.7% 0.0% 0.0% skip:45.0%
[libx264 @ 00000012bef91f80] mb B I16..4: 1.0% 1.7% 0.0% B16..8: 27.9% 1.1% 0.1% direct: 2.0% skip:66.2% L0:49
.4% L1:49.3% BI: 1.3%
[libx264 @ 00000012bef91f80] 8x8 transform intra:65.3% inter:95.1%
[libx264 @ 00000012bef91f80] coded y,uvDC,uvAC intra: 24.7% 39.7% 3.2% inter: 7.0% 14.6% 0.0%
[libx264 @ 00000012bef91f80] i16 v,h,dc,p: 34% 26% 13% 28%
[libx264 @ 00000012bef91f80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 15% 41% 3% 3% 4% 3% 3% 2%
[libx264 @ 00000012bef91f80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 25% 20% 3% 6% 5% 4% 3% 2%
[libx264 @ 00000012bef91f80] i8c dc,h,v,p: 58% 19% 20% 3%
[libx264 @ 00000012bef91f80] Weighted P-Frames: Y:0.1% UV:0.0%
[libx264 @ 00000012bef91f80] ref P L0: 72.2% 6.3% 15.8% 5.7% 0.0%
[libx264 @ 00000012bef91f80] ref B L0: 86.6% 11.5% 1.9%
[libx264 @ 00000012bef91f80] ref B L1: 97.6% 2.4%
[libx264 @ 00000012bef91f80] kb/s:2395.53
[aac @ 00000012bef93b00] Qavg: 471.415



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


-
FFmpeg loglevel with level prefix
13 mai 2020, par Matan MarcianoI want to add level prefix to ffmpeg logs.
Im using
ffmpeg -loglevel level+info -i input

And it is working as well in my Mac (ios) but is not working in my Ubuntu 18 with ffmpeg version 3.4.6-0ubuntu0.18.04.1


When I am running it in my Ubuntu I got :



Invalid loglevel "level+info". Possible levels are numbers or:
"quite"
"panic"
...
...
...
"trace"




Please advise