
Recherche avancée
Médias (91)
-
999,999
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Slip - Artworks
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Demon seed (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
The four of us are dying (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Corona radiata (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Lights in the sky (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (31)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
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
Sur d’autres sites (8551)
-
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 frame extraction with Nvidia GPU acceleration throws "Output file #0 does not contain any stream"
16 mai 2020, par nickthefreakI am trying to use nvidia gpu accelerated decoder api with ffmpeg, to extract all frames from a video file (
.MTS
) to a folder, but it looks like it's failing for some reason ; I could not find an answer or similar issues.


Command used :



ffmpeg -vsync 0 -hwaccel cuvid -c:v mpeg2_cuvid -i raw_video.MTS -q:v 2 -f image2 output_folder/image_%05d.jpg



Traceback :



ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 9.3.0 (Arch Linux 9.3.0-1)
 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
[mpegts @ 0x563fcc5616c0] start time for stream 0 is not set in estimate_timings_from_pts
[mpegts @ 0x563fcc5616c0] PES packet size mismatch
[mpegts @ 0x563fcc5616c0] Could not find codec parameters for stream 0 (Video: mpeg2video (HDMV / 0x564D4448), none(tv)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'raw_video.MTS':
 Duration: 00:07:15.68, start: 1010.210356, bitrate: 41186 kb/s
 Program 1 
 Stream #0:0[0x1011]: Video: mpeg2video (HDMV / 0x564D4448), none(tv), 90k tbr, 90k tbn, 90k tbc
 Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
 Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Output #0, image2, to 'output_folder/image_%05d.jpg':
Output file #0 does not contain any stream




I am pretty sure
-hwaccel cuvid -c:v mpeg2_cuvid
is correct as the file type seems to be MPEG-2 in the file properties, but similar issues happen with the other cuvid decoders as well :





I have also tried to run without
-c:v
flag but then a cuda error is raised and it runs on the cpu :


[h264 @ 0x55949e6d7e00] decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[h264 @ 0x55949e6d7e00] Failed setup for format cuda: hwaccel initialisation returned error.



Any help will be much appreciated.



Edit :



- 

- OS : Arch Linux
- GPU : Nvidia 1050Ti
- CUDA Version : 10.2
- NVIDIA-SMI : 440.82











Edit 2 :



ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 9.3.0 (Arch Linux 9.3.0-1)
 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[mpegts @ 0x55714390c540] PES packet size mismatch
Input #0, mpegts, from 'raw_video.MTS':
 Duration: 00:18:30.97, start: 113.284733, bitrate: 16850 kb/s
 Program 1 
 Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
 Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
 Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
At least one output file must be specified



-
Convert mkv to mp4 on ubuntu 18.10 error ?
15 janvier 2019, par ScipioAfricanusI am trying to convert some mkvs to mp4s on Ubuntu 18.10 with ffmpeg, and I keep getting the error below. Aby thoughts ?
I am following https://linuxconfig.org/install-ffmpeg-on-ubuntu-18-04-bionic-beaver-linux#h2-operating-system-and-software-versions
I have installed ffmpeg and installed :
sudo apt install -y libopus-dev libmp3lame-dev libfdk-aac-dev libvpx-dev libx264-dev yasm libass-dev libtheora-dev libvorbis-dev mercurial cmake
Command I ran with output :
ffmpeg -i 'video.mkv' -codec copy 'video.mp4' -strict -2 -y
ffmpeg version 4.0.2-2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Trailing options were found on the commandline.
Input #0, matroska,webm, from 'ALL nyannyancosplay tik toks (Chronological order) (HD-720p)-WxewnMF4j6Y.mkv':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
ENCODER : Lavf58.12.100
Duration: 00:27:39.74, start: -0.007000, bitrate: 834 kb/s
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 790x720 [SAR 1:1 DAR 79:72], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Metadata:
HANDLER_NAME : ISO Media file produced by Google Inc. Created on: 01/13/2019.
DURATION : 00:27:39.724000000
Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
DURATION : 00:27:39.741000000
[mp4 @ 0x560e85326100] track 1: codec frame size is not set
[mp4 @ 0x560e85326100] opus in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 timesI also tried adding -strict -2 to no avail.