
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (63)
-
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users. -
Formulaire personnalisable
21 juin 2013, parCette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire. (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (10113)
-
AWS Lambda Docker image with librosa and ffmpeg
4 août 2022, par loretoparisiI'm using this
Dockerfile
to build an image for AWS Lambda havinglibrosa
andffmpeg
withpython3.7
:

ARG FUNCTION_DIR="/function"
FROM python:3.7.4-slim-buster as build-image

# librosa and ffmpeg dependencies
RUN apt-get update && apt-get install -y \
 software-properties-common \
 libsndfile1-dev \
 ffmpeg

# Install aws-lambda-cpp build dependencies
RUN apt-get update && \
 apt-get install -y \
 g++ \
 make \
 cmake \
 unzip \
 libcurl4-openssl-dev

# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}

# Copy function code
COPY app.py ${FUNCTION_DIR}

# Install the runtime interface client
RUN pip install \
 --target ${FUNCTION_DIR} \
 awslambdaric

# Multi-stage build: grab a fresh copy of the base image
FROM python:3.7.4-slim-buster

# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}

# Copy in the build image dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}

EXPOSE 8080
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "app.handler" ]



The build works ok, but I cannot run the image :


docker run -e AWS_LAMBDA_RUNTIME_API=localhost:9000 --rm -it -p 9000:8080 lambda:latest
Executing 'app.handler' in function directory '/function'
[ERROR] [1628271126733] LAMBDA_RUNTIME Failed to get next invocation. No Response from endpoint
Traceback (most recent call last):
 File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
 "__main__", mod_spec)
 File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
 exec(code, run_globals)
 File "/function/awslambdaric/__main__.py", line 21, in <module>
 main(sys.argv)
 File "/function/awslambdaric/__main__.py", line 17, in main
 bootstrap.run(app_root, handler, lambda_runtime_api_addr)
 File "/function/awslambdaric/bootstrap.py", line 399, in run
 event_request = lambda_runtime_client.wait_next_invocation()
 File "/function/awslambdaric/lambda_runtime_client.py", line 76, in wait_next_invocation
 response_body, headers = runtime_client.next()
RuntimeError: Failed to get next
</module>


I therefore tried this simplified
Dockerfile
that is based on the AWS EC2 CentOS with package manageryum
:

FROM public.ecr.aws/lambda/python:3.8

# libsndfile
RUN curl -o libsndfile-1.0.28-alt1.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile-1.0.28-alt1.x86_64.rpm 
RUN curl -o libsndfile-devel-1.0.28-alt1.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile-devel-1.0.28-alt1.x86_64.rpm
#ffmpeg
RUN curl -o ffmpeg-4.4-alt5.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//ffmpeg-4.4-alt5.x86_64.rpm 

RUN yum localinstall \
 libsndfile-devel-1.0.28-alt1.x86_64.rpm \
 fmpeg-4.4-alt5.x86_64.rpm

# Create function directory
WORKDIR /app

# Copy function code
COPY app.py .

COPY requirements.txt .
RUN pip install -r requirements.txt

EXPOSE 8080
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD ["/app/app.handler"]



In this case, the image builds and run and I can invoke the handler :


docker run --rm -it -p 9000:8080 lambda:latest
INFO[0000] exec '/var/runtime/bootstrap' (cwd=/app, handler=) 
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'



but I
librosa
complains about thelibsndfile1
installation :

Traceback (most recent call last):
 File "/var/runtime/bootstrap.py", line 452, in main
 request_handler = _get_handler(handler)
 File "/var/runtime/bootstrap.py", line 46, in _get_handler
 m = imp.load_module(modname, file_handle, pathname, desc)
 File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
 return load_source(name, filename, file)
 File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
 module = _load(spec)
 File "<frozen>", line 702, in _load
 File "<frozen>", line 671, in _load_unlocked
 File "<frozen>", line 848, in exec_module
 File "<frozen>", line 219, in _call_with_frames_removed
 File "/app/app.py", line 7, in <module>
 import librosa
 File "/var/lang/lib/python3.8/site-packages/librosa/__init__.py", line 211, in <module>
 from . import core
 File "/var/lang/lib/python3.8/site-packages/librosa/core/__init__.py", line 6, in <module>
 from .audio import * # pylint: disable=wildcard-import
 File "/var/lang/lib/python3.8/site-packages/librosa/core/audio.py", line 8, in <module>
 import soundfile as sf
 File "/var/lang/lib/python3.8/site-packages/soundfile.py", line 142, in <module>
 raise OSError('sndfile library not found')
OSError: sndfile library not found

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
 File "/var/runtime/bootstrap.py", line 480, in <module>
 main()
 File "/var/runtime/bootstrap.py", line 457, in main
 lambda_runtime_client.post_init_error(to_json(error_result))
 File "/var/runtime/lambda_runtime_client.py", line 42, in post_init_error
 response = runtime_connection.getresponse()
 File "/var/lang/lib/python3.8/http/client.py", line 1344, in getresponse
 response.begin()
 File "/var/lang/lib/python3.8/http/client.py", line 307, in begin
 version, status, reason = self._read_status()
 File "/var/lang/lib/python3.8/http/client.py", line 276, in _read_status
 raise RemoteDisconnected("Remote end closed connection without"
 http.client.RemoteDisconnected: Remote end closed connection without response
 WARN[0023] First fatal error stored in appctx: Runtime.ExitError 
 WARN[0023] Process 16(bootstrap) exited: Runtime exited with error: exit status 1 
 ERRO[0023] Init failed InvokeID= error="Runtime exited with error: exit status 1"
 WARN[0023] Failed to send default error response: ErrInvalidInvokeID 
 ERRO[0023] INIT DONE failed: Runtime.ExitError 
 WARN[0023] Reset initiated: ReserveFail 
</module></module></module></module></module></module></frozen></frozen></frozen></frozen>


The strange thing in this case (
yum
andrmp
) is that the installation seems to work fine :

=> CACHED [2/9] RUN curl -o libsndfile-1.0.28-alt1.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile-1.0.2 0.0s
 => CACHED [3/9] RUN curl -o libsndfile-devel-1.0.28-alt1.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile 0.0s
 => CACHED [4/9] RUN curl -o ffmpeg-4.4-alt5.x86_64.rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//ffmpeg-4.4-alt5.x86_64 0.0s
 => CACHED [5/9] RUN yum localinstall libsndfile-devel-1.0.28-alt1.x86_64.rpm fmpeg-4.4-alt5.x86_64.rpm 



-
GRAY16 stream with over network ffmpeg
9 novembre 2023, par Norbert P.Im working in a school project where we need to use depth cameras. The camera produces color and depth (in other words 16bit grayscale image). We decided to use ffmpeg, as later on compression could be very useful. For now we got some basic stream running form one PC to other. These settings include :


- 

- rtmp
- flv as container
- pixel format AV_PIX_FMT_YUV420P
- codec AV_CODEC_ID_H264










The problem we are having is with grayscale image. Not every codec is able to cope with this format, so as not every protocol able to work with given codec. I got some settings "working" but receiver side is just stuck on avformat_open_input() method.
I have also tested it with commandline where ffmpeg is listening for connection and same happens.


I include a minimum "working" example of client code. Server can be tested with "ffmpeg.exe -f apng -listen 1 -i rtmp ://localhost:9999/stream/stream1 -c copy -f apng -listen 1 rtmp ://localhost:2222/live/l" or code below. I get no warnings, ffmpeg is newest version installed with "vcpkg install —triplet x64-windows ffmpeg[ffmpeg,ffprobe,zlib]" on windows or packet manager on linux.


The question : Did I miss something ? How do I get it to work ? If you have any better ideas I would very gladly consider them. In the end I need 16 bits of lossless transmission, could be split between channels etc. which I also tried with same effect.


Client code that would have camera and connect to server :


extern "C" {
#include <libavutil></libavutil>opt.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>channel_layout.h>
#include <libavutil></libavutil>common.h>
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>imgutils.h>
}

int main() {

 std::string container = "apng";
 AVCodecID codec_id = AV_CODEC_ID_APNG;
 AVPixelFormat pixFormat = AV_PIX_FMT_GRAY16BE;

 AVFormatContext* format_ctx;
 AVCodec* out_codec;
 AVStream* out_stream;
 AVCodecContext* out_codec_ctx;
 AVFrame* frame;
 uint8_t* data;

 std::string server = "rtmp://localhost:9999/stream/stream1";

 int width = 1280, height = 720, fps = 30, bitrate = 1000000;

 //initialize format context for output with flv and no filename
 avformat_alloc_output_context2(&format_ctx, nullptr, container.c_str(), server.c_str());
 if (!format_ctx) {
 return 1;
 }

 //AVIOContext for accessing the resource indicated by url
 if (!(format_ctx->oformat->flags & AVFMT_NOFILE)) {
 int avopen_ret = avio_open(&format_ctx->pb, server.c_str(),
 AVIO_FLAG_WRITE);// , nullptr, nullptr);
 if (avopen_ret < 0) {
 fprintf(stderr, "failed to open stream output context, stream will not work\n");
 return 1;
 }
 }


 const AVCodec* tmp_out_codec = avcodec_find_encoder(codec_id);
 //const AVCodec* tmp_out_codec = avcodec_find_encoder_by_name("hevc");
 out_codec = const_cast(tmp_out_codec);
 if (!(out_codec)) {
 fprintf(stderr, "Could not find encoder for '%s'\n",
 avcodec_get_name(codec_id));

 return 1;
 }

 out_stream = avformat_new_stream(format_ctx, out_codec);
 if (!out_stream) {
 fprintf(stderr, "Could not allocate stream\n");
 return 1;
 }

 out_codec_ctx = avcodec_alloc_context3(out_codec);

 const AVRational timebase = { 60000, fps };
 const AVRational dst_fps = { fps, 1 };
 av_log_set_level(AV_LOG_VERBOSE);
 //codec_ctx->codec_tag = 0;
 //codec_ctx->codec_id = codec_id;
 out_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
 out_codec_ctx->width = width;
 out_codec_ctx->height = height;
 out_codec_ctx->gop_size = 1;
 out_codec_ctx->time_base = timebase;
 out_codec_ctx->pix_fmt = pixFormat;
 out_codec_ctx->framerate = dst_fps;
 out_codec_ctx->time_base = av_inv_q(dst_fps);
 out_codec_ctx->bit_rate = bitrate;
 //if (fctx->oformat->flags & AVFMT_GLOBALHEADER)
 //{
 // codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 //}

 out_stream->time_base = out_codec_ctx->time_base; //will be set afterwards by avformat_write_header to 1/1000

 int ret = avcodec_parameters_from_context(out_stream->codecpar, out_codec_ctx);
 if (ret < 0)
 {
 fprintf(stderr, "Could not initialize stream codec parameters!\n");
 return 1;
 }

 AVDictionary* codec_options = nullptr;
 av_dict_set(&codec_options, "tune", "zerolatency", 0);

 // open video encoder
 ret = avcodec_open2(out_codec_ctx, out_codec, &codec_options);
 if (ret < 0)
 {
 fprintf(stderr, "Could not open video encoder!\n");
 return 1;
 }
 av_dict_free(&codec_options);

 out_stream->codecpar->extradata_size = out_codec_ctx->extradata_size;
 out_stream->codecpar->extradata = static_cast(av_mallocz(out_codec_ctx->extradata_size));
 memcpy(out_stream->codecpar->extradata, out_codec_ctx->extradata, out_codec_ctx->extradata_size);

 av_dump_format(format_ctx, 0, server.c_str(), 1);

 frame = av_frame_alloc();

 int sz = av_image_get_buffer_size(pixFormat, width, height, 32);
#ifdef _WIN32
 data = (uint8_t*)_aligned_malloc(sz, 32);
 if (data == NULL)
 return ENOMEM;
#else
 ret = posix_memalign(reinterpret_cast(&data), 32, sz);
#endif
 av_image_fill_arrays(frame->data, frame->linesize, data, pixFormat, width, height, 32);
 frame->format = pixFormat;
 frame->width = width;
 frame->height = height;
 frame->pts = 1;
 if (avformat_write_header(format_ctx, nullptr) < 0) //Header making problems!!!
 {
 fprintf(stderr, "Could not write header!\n");
 return 1;
 }

 printf("stream time base = %d / %d \n", out_stream->time_base.num, out_stream->time_base.den);

 double inv_stream_timebase = (double)out_stream->time_base.den / (double)out_stream->time_base.num;
 printf("Init OK\n");
 /* Init phase end*/
 int dts = 0;
 int frameNo = 0;

 while (true) {
 //Fill dummy frame with something
 for (int y = 0; y < height; y++) {
 uint16_t color = ((y + frameNo) * 256) % (256 * 256);
 for (int x = 0; x < width; x++) {
 data[x+y*width] = color;
 }
 }

 memcpy(frame->data[0], data, 1280 * 720 * sizeof(uint16_t));
 AVPacket* pkt = av_packet_alloc();

 int ret = avcodec_send_frame(out_codec_ctx, frame);
 if (ret < 0)
 {
 fprintf(stderr, "Error sending frame to codec context!\n");
 return ret;
 }
 while (ret >= 0) {
 ret = avcodec_receive_packet(out_codec_ctx, pkt);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 break;
 else if (ret < 0) {
 fprintf(stderr, "Error during encoding\n");
 break;
 }
 pkt->dts = dts;
 pkt->pts = dts;
 dts += 33;
 av_write_frame(format_ctx, pkt);
 frameNo++;
 av_packet_unref(pkt);
 }
 printf("Streamed %d frames\n", frameNo);
 }
 return 0;
}



And part of server that should receive. code where is stops and waits


extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavformat></libavformat>avio.h>
}

int main() {
 AVFormatContext* fmt_ctx = NULL;
 av_log_set_level(AV_LOG_VERBOSE);
 AVDictionary* options = nullptr;
 av_dict_set(&options, "protocol_whitelist", "file,udp,rtp,tcp,rtmp,rtsp,hls", 0);
 av_dict_set(&options, "timeout", "500000", 0); // Timeout in microseconds 

//Next Line hangs 
 int ret = avformat_open_input(&fmt_ctx, "rtmp://localhost:9999/stream/stream1", NULL, &options);
 if (ret != 0) {
 fprintf(stderr, "Could not open RTMP stream\n");
 return -1;
 }

 // Find the first video stream
 ret = avformat_find_stream_info(fmt_ctx, nullptr);
 if (ret < 0) {
 return ret;
 }
 //...
} 




-
GDPR Compliance Checklist : A Detailed Walkthrough
14 septembre 2023, par Erin — GDPR