
Recherche avancée
Autres articles (1)
-
Monitoring de fermes de MediaSPIP (et de SPIP tant qu’à faire)
31 mai 2013, parLorsque l’on gère plusieurs (voir plusieurs dizaines) de MediaSPIP sur la même installation, il peut être très pratique d’obtenir d’un coup d’oeil certaines informations.
Cet article a pour but de documenter les scripts de monitoring Munin développés avec l’aide d’Infini.
Ces scripts sont installés automatiquement par le script d’installation automatique si une installation de munin est détectée.
Description des scripts
Trois scripts Munin ont été développés :
1. mediaspip_medias
Un script de (...)
Sur d’autres sites (2260)
-
Cross compiling Rust app depending on ffmpeg fails
28 juin 2024, par user253530Trying to cross compile an application depending on ffmpeg-next from Linux to Windows. It works well on Linux but when using cross to compile for Windows I get this error


error: failed to run custom build command for `ffmpeg-sys-next v7.0.0`

Caused by:
process didn't exit successfully: `/target/debug/build/ffmpeg-sys-next-a15fd7744c0ae4bc/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-pc-windows-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_pc_windows_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at /cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-sys-next-7.0.0/build.rs:740:14:
called `Result::unwrap()` on an `Err` value:
pkg-config exited with status code 1
> PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags libavutil

The system library `libavutil` required by crate `ffmpeg-sys-next` was not found.
The file `libavutil.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
The PKG_CONFIG_PATH environment variable is not set.```

Appreciate the help.



-
FFMPEG subtitles in c
13 juillet 2023, par SerhiiI want to record video from camera with subtitles using FFMPEG and C. I was used examples on main FFMPEG repository and had successfully recorded video from camera. But with subtitles I'm stuck and do not know how to make it works. I was also tried example where shows how to re-mux video with existing one - it works but I can't understand how to create my own.


I have as example one video from my DJI drone. There is 2 streams : one for video and second for subtitles. I can see that codec for video is
h264
and codec for subtitles ismov_text
. But once I try to open this codec in my code (codec id =AV_CODEC_ID_MOV_TEXT
) every time it fails.
I had installed FFMPEG from default ubuntu repository.
In debug I was noticed(but may be wrong) that stream for subtitles present and have field codec_type = AVMEDIA_TYPE_SUBTITLE, codec_id = AV_CODEC_ID_MOV_TEXT but codec itself is NULL. Is it right for subtitles ?
Any FFMPEG manuals doesn't contain hints how to manage subtitles, so I will be happy if someone help my with that.
Thanks in advance !

void open_instance_codec(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) {
 int ret;
 AVCodecContext *c = ost->encoder;
 AVDictionary *opt = NULL;

 av_dict_copy(&opt, opt_arg, 0);
 av_dict_set(&opt, "loglevel", "debug", 0);
 av_dict_set(&opt, "stats", "1", 0);


 ret = avcodec_open2(c, codec, &opt); // failed to open subtitle codec
 av_dict_free(&opt);
 if (ret < 0) {

 fprintf(stderr, "Could not open %s codec \n", codec->name);
 char str[AV_ERROR_MAX_STRING_SIZE];
 av_make_error_string(reinterpret_cast<char>(str), AV_ERROR_MAX_STRING_SIZE, ret);
 fprintf(stderr, "This error means: '%s'\n", str); /// This error means: 'Invalid data found when processing input'

 exit(1);
 }


 ret = avcodec_parameters_from_context(ost->strm->codecpar, c);
 if (ret < 0) {
 fprintf(stderr, "Could not copy the stream parameters\n");
 exit(1);
 }
}
</char>


-
How to compensate frame rate underrun while muxing video to mp4 container with libav
17 septembre 2021, par Nuno SantosI have a process that generates video frames in real time. I’m muxing the generated video frames stream in a video file (x264 codec on a mp4 container).


I'm using ffmpeg-libav and I'm basing myself on the muxing.c example. The problem with the example is that isn't a real world scenario as frames are being generated on a while loop for a given stream duration, never missing a frame.


On my program, frames are supposed to be generated at FPS, however, depending on the hardware capacity it might produce less than FPS. When I initialize the video stream context I declare that frame rate is FPS :


AVRational r = { 1, FPS };
ost->st->time_base = r;



This specifies that the video is going to have FPS frame rate but if less frames are produced, the playback will be faster because it will still reproduce the video as it if had all the declared frames per second.


After googling a lot about this topic I understand that the key to fix this is to manipulate pts and dts but I still haven't found a solution that works.


There are two key functions when writing video frames in the muxing.c example, routines that I'm using in my program :


AVFrame* get_video_frame(int timestamp, OutputStream *ost, const QImage &image)
{
 /* when we pass a frame to the encoder, it may keep a reference to it
 * internally; make sure we do not overwrite it here */
 if (av_frame_make_writable(ost->frame) < 0)
 exit(1);

 av_image_fill_arrays(ost->tmp_frame->data, ost->tmp_frame->linesize, image.bits(), AV_PIX_FMT_RGBA, ost->frame->width, ost->frame->height, 8);
 libyuv::ABGRToI420(ost->tmp_frame->data[0], ost->tmp_frame->linesize[0], ost->frame->data[0], ost->frame->linesize[0], ost->frame->data[1], ost->frame->linesize[1], ost->frame->data[2], ost->frame->linesize[2], ost->tmp_frame->width, -ost->tmp_frame->height);

 #if 1 // this is my attempt to rescale pts, but crashes with ptsframe->pts = av_rescale_q(timestamp, AVRational{1, 1000}, ost->st->time_base);
 #else
 ost->frame->pts = ost->next_pts++;
 #endif

 return ost->frame;
}



On the original code, the pts is simply an incremeting integer for each frame. What I'm trying to do is to pass a timestamp in ms since the beggining of the recording so that I can rescale the pts. When I rescale pts the program crashes complaining that pts is lower then dts.


From what I've been reading, the pts/dts manipulation is supposed to be done at the packet level so I have also tried to manipulate things on write_frame routine without success.


int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c, AVStream *st, AVFrame *frame)
{
 int ret;

 // send the frame to the encoder
 ret = avcodec_send_frame(c, frame);

 if (ret<0)
 {
 fprintf(stderr, "Error sending a frame to the encoder\n");
 exit(1);
 }

 while (ret >= 0)
 {
 AVPacket pkt = { 0 };

 ret = avcodec_receive_packet(c, &pkt);

 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 {
 break;
 }
 else if (ret<0)
 {
 //fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));
 exit(1);
 }

 /* rescale output packet timestamp values from codec to stream timebase */
 av_packet_rescale_ts(&pkt, c->time_base, st->time_base);
 pkt.stream_index = st->index;

 /* Write the compressed frame to the media file. */
 //log_packet(fmt_ctx, &pkt);
 ret = av_interleaved_write_frame(fmt_ctx, &pkt);
 av_packet_unref(&pkt);

 if (ret < 0)
 {
 //fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));
 exit(1);
 }
 }

 return ret == AVERROR_EOF ? 1 : 0;
}



How should I manipulate dts and pts so that I can achieve a video at certain frame that does not have all the frames as specified in the stream initialization ? Where should I do that manipulation ? On get_video_frame ? On write_frame ? On both ?


Am I heading in the right direction ? What am I missing ?