
Recherche avancée
Autres articles (93)
-
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 -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
MediaSPIP Player : problèmes potentiels
22 février 2011, parLe lecteur ne fonctionne pas sur Internet Explorer
Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)
Sur d’autres sites (11159)
-
CVAT error during installation of development version
28 novembre 2022, par RamanI'm trying to install development version of CVAT according to official instruction but struggling at the step of requirements.txt applying :


pip install -r cvat/requirements/development.txt



... with following error :


Skipping wheel build for av, due to binaries being disabled for it.
Skipping wheel build for datumaro, due to binaries being disabled for it.
Installing collected packages: wrapt, tf-estimator-nightly, termcolor, tensorboard-plugin-wit, Shapely, rules, rope, rjsmin, rcssmin, pytz, pyasn1, patool, mistune, mccabe, libclang, keras, itypes, flatbuffers, entrypoint2, EasyProcess, dj-pagination, diskcache, av, addict, Werkzeug, urllib3, uritemplate, typing-extensions, tqdm, tornado, toml, threadpoolctl, tensorflow-io-gcs-filesystem, tensorboard-data-server, sqlparse, smmap, six, ruamel.yaml.clib, rsa, redis, PyYAML, pyunpack, pyrsistent, pyparsing, pylogbeat, pyjwt, Pygments, pycparser, pyasn1-modules, protobuf, Pillow, oauthlib, numpy, networkx, natsort, MarkupSafe, Markdown, lxml, lazy-object-proxy, kiwisolver, joblib, jmespath, isort, inflection, idna, google-crc32c, gast, fonttools, dnspython, django-extensions, deprecated, defusedxml, cycler, click, charset-normalizer, certifi, cachetools, attrs, asgiref, absl-py, tensorboardX, snakeviz, scipy, ruamel.yaml, rq, requests, python3-openid, python-ldap, python-dateutil, pdf2image, packaging, orderedmultidict, opt-einsum, opencv-python-headless, opencv-python, keras-preprocessing, jsonschema, jinja2, isodate, h5py, grpcio, googleapis-common-protos, google-resumable-media, google-pasta, google-auth, gitdb, Django, cffi, astunparse, astroid, scikit-learn, requests-oauthlib, pylint, pandas, matplotlib, limits, google-api-core, GitPython, furl, djangorestframework, django-sendfile2, django-rq, django-filter, django-cors-headers, django-auth-ldap, django-appconf, cryptography, croniter, coreschema, botocore, azure-core, s3transfer, rq-scheduler, python-logstash-async, pylint-plugin-utils, pycocotools, open3d, msrest, google-cloud-core, google-auth-oauthlib, drf-spectacular, django-rest-auth, django-compressor, coreapi, tensorboard, pylint-django, google-cloud-storage, django-allauth, datumaro, boto3, azure-storage-blob, tensorflow
 Running setup.py install for av ... error
 error: subprocess-exited-with-error
 
 × Running setup.py install for av did not run successfully.
 │ exit code: 1
 ╰─> [50 lines of output]
 running install
 /Users/dd/cvat/.env/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
 warnings.warn(
 running build
 running build_py
 creating build
 creating build/lib.macosx-12.4-x86_64-cpython-39
 creating build/lib.macosx-12.4-x86_64-cpython-39/av
 copying av/deprecation.py -> build/lib.macosx-12.4-x86_64-cpython-39/av
 copying av/datasets.py -> build/lib.macosx-12.4-x86_64-cpython-39/av
 copying av/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av
 copying av/__main__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/video
 copying av/video/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/video
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/codec
 copying av/codec/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/codec
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/container
 copying av/container/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/container
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/audio
 copying av/audio/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/audio
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/subtitles
 copying av/subtitles/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/subtitles
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/filter
 copying av/filter/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/filter
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/sidedata
 copying av/sidedata/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/sidedata
 creating build/lib.macosx-12.4-x86_64-cpython-39/av/data
 copying av/data/__init__.py -> build/lib.macosx-12.4-x86_64-cpython-39/av/data
 running build_ext
 running config
 PyAV: 8.0.2 (unknown commit)
 Python: 3.9.10 (main, Jun 28 2022, 17:49:16) \n[Clang 13.1.6 (clang-1316.0.21.2.5)]
 platform: macOS-12.4-x86_64-i386-64bit
 extension_extra:
 include_dirs: [b'include']
 libraries: []
 library_dirs: []
 define_macros: []
 runtime_library_dirs: []
 config_macros:
 PYAV_COMMIT_STR="unknown-commit"
 PYAV_VERSION=8.0.2
 PYAV_VERSION_STR="8.0.2"
 Could not find libavformat with pkg-config.
 Could not find libavcodec with pkg-config.
 Could not find libavdevice with pkg-config.
 Could not find libavutil with pkg-config.
 Could not find libavfilter with pkg-config.
 Could not find libswscale with pkg-config.
 Could not find libswresample with pkg-config.
 [end of output]
 
 note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> av



I have already tried suggested fixes, but no luck :
https://github.com/openvinotoolkit/cvat/issues/4406


Environment :


- 

- MacBook Pro (Intel x64)
- macOS Monterey (Version 12.4)
- (pyenv) Python 3.9.10








What other options could be applied to fix it ?


-
Duplicate a signal with FFmpeg library [on hold]
22 septembre 2016, par MeugiwaraI’m using the FFmpeg library to develop a program in C/C++. At this time, my aim is to duplicate the signal when I open an audio file. My scheme is the next : read an audio file, transform the stereo signal in mono signal and duplicate this mono signal to get two mono signal exactly the same.
I watched in the Doxygen documentation on the official website, but I don’t find something interesting. Do someone know a good way to do this ?
Here’s what I have so far :
#include
#include
#include
#define __STDC_CONSTANT_MACROS
#ifdef _WIN32
extern "C" /* Windows */
{
#include "libswresample/swresample.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "SDL2/SDL.h"
};
#else
#ifdef __cplusplus
extern "C" /* Linux */
{
#endif /* __cplusplus */
#include <libswresample></libswresample>swresample.h>
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <sdl2></sdl2>SDL.H>
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* _WIN32 */
#define MAX_AUDIO_FRAME_SIZE 192000 /* 1 second of 48 kHz 32 bits audio*/
#define OUTPUT_PCM 1 /* Output PCM */
#define USE_SDL 1 /* Use SDL */
/* Les incrémentations */
static Uint32 audio_len;
static Uint8 *audio_chunk;
static Uint8 *audio_pos;
void fill_audio(void *udata, Uint8 *stream, int len)
{
SDL_memset(stream, 0, len); /* SDL 2.0 */
if (audio_len == 0)
return;
len = (len > audio_len ? audio_len : len);
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
audio_pos = audio_pos + len;
audio_len = audio_len - len;
}
int reading_sound(char *str)
{
SDL_AudioSpec wanted_spec;
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVSampleFormat out_sample_fmt;
AVPacket *packet;
AVFrame *pFrame;
AVCodec *pCodec;
uint64_t out_channel_layout;
uint8_t *out_buffer;
int64_t in_channel_layout;
struct SwrContext *au_convert_ctx;
int out_sample_rate;
int out_buffer_size;
int out_nb_samples;
int out_channels;
int audioStream;
int got_picture;
int index = 0;
int ret;
int i;
FILE *pFile = NULL;
/*
//char *sound = "WavinFlag.aac";
*/
av_register_all();
avformat_network_init();
pFormatCtx = avformat_alloc_context();
if (avformat_open_input(&pFormatCtx, str, NULL, NULL) != 0) /* Ouverture du fichier */
{
fprintf(stderr, "%s\n", "Couldn't open input stream");
return (-1);
}
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) /* Récupérer les informations */
{
fprintf(stderr, "Couldn't find stream information\n");
return (-1);
}
av_dump_format(pFormatCtx, 0, str, false); /* Envoyer les informations utiles sur la sortie d'erreur */
audioStream = -1;
for (i = 0; i < pFormatCtx->nb_streams; i++) /* Trouver le début du son */
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
audioStream = i;
break;
}
if (audioStream == -1)
{
fprintf(stderr, "%s\n", "Didn't find an audio stream");
return (-1);
}
pCodecCtx = pFormatCtx->streams[audioStream]->codec;
pCodec = avcodec_find_decoder(pCodecCtx->codec_id); /* Trouver le décodeur du fichier (.aac, .mp3, ...) */
if (pCodec == NULL)
{
fprintf(stderr, "%s\n", "Codec not found");
return (-1);
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) /* Ouvrir le décodeur du fichier */
{
fprintf(stderr, "%s\n", "Couldn't open codec");
return (-1);
}
#if OUTPUT_PCM
pFile = fopen("output.pcm", "wb"); /* Créer et écrire tout ce qui se passe dans ce fichier */
#endif /* OUTPUT_PCM */
packet = (AVPacket *)av_malloc(sizeof(AVPacket)); /* Allouer taille */
av_init_packet(packet);
out_channel_layout = AV_CH_LAYOUT_MONO; /* Canaux de sortie */
out_nb_samples = pCodecCtx->frame_size; /* L'échantillonnage - Le nombre de samples*/
out_sample_fmt = AV_SAMPLE_FMT_S16; /* Format */
out_sample_rate = 44100; /* Fréquence */
out_channels = av_get_channel_layout_nb_channels(out_channel_layout); /* Récupérer le nombre de canaux */
/*
// printf("%d\n", out_channels);
// system("PAUSE");
*/
out_buffer_size = av_samples_get_buffer_size(NULL, out_channels, out_nb_samples, out_sample_fmt, 1); /* Taille du buffer */
out_buffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE * 2); /* Allouer taille */
pFrame = av_frame_alloc(); /* Allouer taille */
#if USE_SDL
if (SDL_Init(SDL_INIT_VIDEO |SDL_INIT_AUDIO | SDL_INIT_TIMER)) /* Initialiser SDL */
{
fprintf(stderr, "%s - %s\n", "Couldn't initialize SDL", SDL_GetError());
return (-1);
}
/*
// Attribution des valeurs avec les variables au-dessus
*/
wanted_spec.freq = out_sample_rate;
wanted_spec.format = AUDIO_S16SYS;
wanted_spec.channels = out_channels;
wanted_spec.silence = 0;
wanted_spec.samples = out_nb_samples;
wanted_spec.callback = fill_audio;
wanted_spec.userdata = pCodecCtx;
if (SDL_OpenAudio(&wanted_spec, NULL) < 0)
{
fprintf(stderr, "%s\n", "Can't open audio");
return (-1);
}
#endif /* USE_SDL */
in_channel_layout = av_get_default_channel_layout(pCodecCtx->channels);
au_convert_ctx = swr_alloc();
au_convert_ctx = swr_alloc_set_opts(au_convert_ctx, out_channel_layout, out_sample_fmt, out_sample_rate,
in_channel_layout, pCodecCtx->sample_fmt, pCodecCtx->sample_rate, 0, NULL);
swr_init(au_convert_ctx);
while (av_read_frame(pFormatCtx, packet) >= 0) /* Lecture du fichier */
{
if (packet->stream_index == audioStream)
{
ret = avcodec_decode_audio4(pCodecCtx, pFrame, &got_picture, packet); /* Décoder les packets */
if (ret < 0)
{
fprintf(stderr, "%s\n", "Error in decoding audio frame");
return (-1);
}
if (got_picture > 0)
{
swr_convert(au_convert_ctx, &out_buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **)pFrame->data, pFrame->nb_samples);
#if 1
printf("Index : %5d\t Points : %lld\t Packet size : %d\n", index, packet->pts, packet->size); /* Affichage des informations sur la console */
#endif /* 1 */
#if OUTPUT_PCM
fwrite(out_buffer, 1, out_buffer_size, pFile); /* Faire l'écriture dans le fichier */
#endif /* OUTPUT_PCM */
index = index + 1;
}
#if USE_SDL
while (audio_len > 0)
SDL_Delay(1);
audio_chunk = (Uint8 *)out_buffer;
audio_len = out_buffer_size;
audio_pos = audio_chunk;
SDL_PauseAudio(0);
#endif /* USE_SDL */
}
av_free_packet(packet); /* Libérer les packets */
}
swr_free(&au_convert_ctx); /* Libérer la taille de conversion */
#if USE_SDL
SDL_CloseAudio(); /* Arrêter le son dans SDL */
SDL_Quit(); /* Quitter SDL */
#endif /* USE_SDL */
#if OUTPUT_PCM
fclose(pFile); /* Fermer le fichier d'écriture */
#endif /* OUTPUT_PCM */
av_free(out_buffer);
avcodec_close(pCodecCtx); /* Fermer le décodeur */
avformat_close_input(&pFormatCtx); /* Fermer le fichier lu */
return (0);
}
int main(int argc, char **argv)
{
if (argc != 2)
{
fprintf(stderr, "%s\n", "Usage : ./BASELFI [File]");
system("PAUSE");
return (-1);
}
else
{
reading_sound(argv[1]);
return (0);
}
return (0);
} -
Ffmpeg set output format C++
7 septembre 2022, par TurgutI made a program that encodes a video and I want to specify the format as
h264
but I can't figure out how to do it. It automatically sets the format tompeg4
and I can't change it. I got my code from ffmpegs official examples muxing.c and slightly edited it to fit my code (I haven't changed much especially did not touch the parts where it sets the format)

Here is my code so for (I have trimmed down the code slightly, removing redundant parts)


video_encoder.cpp :



video_encoder::video_encoder(int w, int h, float fps, unsigned int duration) 
 :width(w), height(h), STREAM_FRAME_RATE(fps), STREAM_DURATION(duration)
{
 std::string as_str = "./output/video.mp4";

 char* filename = const_cast(as_str.c_str());
 enc_inf.video_st, enc_inf.audio_st = (struct OutputStream) { 0 };
 enc_inf.video_st.next_pts = 1; 
 enc_inf.audio_st.next_pts = 1;
 enc_inf.encode_audio, enc_inf.encode_video = 0;
 int ret;
 int i;

 /* allocate the output media context */
 avformat_alloc_output_context2(&enc_inf.oc, NULL, NULL, filename);

 if (!enc_inf.oc) {
 std::cout << "FAILED" << std::endl;
 avformat_alloc_output_context2(&enc_inf.oc, NULL, "mpeg", filename);
 }

 enc_inf.fmt = enc_inf.oc->oformat;

 /* Add the audio and video streams using the default format codecs
 * and initialize the codecs. */
 if (enc_inf.fmt->video_codec != AV_CODEC_ID_NONE) {
 add_stream(&enc_inf.video_st, enc_inf.oc, &video_codec, enc_inf.fmt->video_codec);
 enc_inf.have_video = 1;
 enc_inf.encode_video = 1;
 }
 if (enc_inf.fmt->audio_codec != AV_CODEC_ID_NONE) {
 add_stream(&enc_inf.audio_st, enc_inf.oc, &audio_codec, enc_inf.fmt->audio_codec);
 enc_inf.have_audio = 1;
 enc_inf.encode_audio = 1;
 }

 /* Now that all the parameters are set, we can open the audio and
 * video codecs and allocate the necessary encode buffers. */
 if (enc_inf.have_video)
 open_video(enc_inf.oc, video_codec, &enc_inf.video_st, opt);

 if (enc_inf.have_audio)
 open_audio(enc_inf.oc, audio_codec, &enc_inf.audio_st, opt);
 av_dump_format(enc_inf.oc, 0, filename, 1);

 /* open the output file, if needed */
 if (!(enc_inf.fmt->flags & AVFMT_NOFILE)) {
 ret = avio_open(&enc_inf.oc->pb, filename, AVIO_FLAG_WRITE);
 if (ret < 0) {
 //VI_ERROR("Could not open '%s': %s\n", filename, ret);
 //return 1;
 }
 }

 /* Write the stream header, if any. */
 ret = avformat_write_header(enc_inf.oc, &opt);
 if (ret < 0) {
 VI_ERROR("Error occurred when opening output file:");
 //return 1;
 }
 
 //return 0;
}


/* Add an output stream. */
void video_encoder::add_stream(OutputStream *ost, AVFormatContext *oc,
 const AVCodec **codec,
 enum AVCodecID codec_id)
{
 AVCodecContext *c;
 int i;

 /* find the encoder */
 *codec = avcodec_find_encoder(codec_id);
 
 if (!(*codec)) {
 fprintf(stderr, "Could not find encoder for '%s'\n",
 avcodec_get_name(codec_id));
 exit(1);
 }

 ost->tmp_pkt = av_packet_alloc();

 if (!ost->tmp_pkt) {
 fprintf(stderr, "Could not allocate AVPacket\n");
 exit(1);
 }

 ost->st = avformat_new_stream(oc, NULL);
 if (!ost->st) {
 fprintf(stderr, "Could not allocate stream\n");
 exit(1);
 }
 ost->st->id = oc->nb_streams-1;
 c = avcodec_alloc_context3(*codec);
 if (!c) {
 fprintf(stderr, "Could not alloc an encoding context\n");
 exit(1);
 }
 ost->enc = c;


 switch ((*codec)->type) {
 case AVMEDIA_TYPE_AUDIO:
 ...
 break;
 case AVMEDIA_TYPE_VIDEO:
 c->codec_id = codec_id;

 c->bit_rate = 10000;
 /* Resolution must be a multiple of two. */
 c->width = width;
 c->height = height;
 /* timebase: This is the fundamental unit of time (in seconds) in terms
 * of which frame timestamps are represented. For fixed-fps content,
 * timebase should be 1/framerate and timestamp increments should be
 * identical to 1. */
 ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE }; // *frame_rate
 c->time_base = ost->st->time_base;

 c->gop_size = 7; /* emit one intra frame every twelve frames at most */
 //c->codec_id = AV_CODEC_ID_H264;
 c->pix_fmt = STREAM_PIX_FMT;
 //if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) 
 // c->max_b_frames = 2;
 if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
 /* Needed to avoid using macroblocks in which some coeffs overflow.
 * This does not happen with normal video, it just happens here as
 * the motion of the chroma plane does not match the luma plane. */
 c->mb_decision = 2;
 }

 if ((*codec)->pix_fmts){
 //c->pix_fmt = (*codec)->pix_fmts[0];
 std::cout << "NEW FORMAT : " << c->pix_fmt << std::endl;
 }

 break;
 }
 

 /* Some formats want stream headers to be separate. */
 if (oc->oformat->flags & AVFMT_GLOBALHEADER)
 c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}



video_encoder.h



typedef struct OutputStream {
 AVStream *st;
 AVCodecContext *enc;

 /* pts of the next frame that will be generated */
 int64_t next_pts;
 int samples_count;

 AVFrame *frame;
 AVFrame *tmp_frame;

 AVPacket *tmp_pkt;

 float t, tincr, tincr2;

 struct SwsContext *sws_ctx;
 struct SwrContext *swr_ctx;
} OutputStream;

class video_encoder{
 private:
 typedef struct {
 OutputStream video_st, audio_st;
 const AVOutputFormat *fmt;
 AVFormatContext *oc;
 int have_video, have_audio, encode_video, encode_audio;
 std::string name;
 } encode_info;
 public:
 encode_info enc_inf;
 video_encoder(int w, int h, float fps, unsigned int duration);
 ~video_encoder(); 
 ...
 private:
 ...
 void add_stream(OutputStream *ost, AVFormatContext *oc,
 const AVCodec **codec,
 enum AVCodecID codec_id);



I'm thinking that the example sets the codec at
avformat_alloc_output_context2(&enc_inf.oc, NULL, NULL, filename)
but I'm not quite sure how to set it to h264.

I've tried something like this
avformat_alloc_output_context2(&enc_inf.oc, enc_inf.fmt, "h264", filename)


But it just gives a seg fault. What am I supposed to do ?


Edit : I've tried adding these two lines to
video_encoder::video_encoder
by deletingavformat_alloc_output_context2(&enc_inf.oc, NULL, NULL, filename);
:


 video_codec = avcodec_find_encoder(AV_CODEC_ID_H264);
 enc_inf.video_st.enc = avcodec_alloc_context3(video_codec);




But it resulted in these errors :
It says this every frame (A bunch of times)


[mpeg @ 0x56057c465480] buffer underflow st=0 bufi=26822 size=31816



Says this once when the frame encoding loop is over :


[mpeg @ 0x5565ac4a04c0] start time for stream 0 is not set in estimate_timings_from_pts
[mpeg @ 0x5565ac4a04c0] stream 0 : no TS found at start of file, duration not set
[mpeg @ 0x5565ac4a04c0] Could not find codec parameters for stream 0 (Video: mpeg2video, none): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options