
Recherche avancée
Autres articles (39)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
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 ) (...)
Sur d’autres sites (5067)
-
Reasons for "Segmentation fault (core dumped)" when using Python extension and FFmpeg
24 août 2021, par Christian VorhemusI want to write a Python C extension that includes a function
convertVideo()
that converts a video from one format to another making use of FFmpeg 3.4.8 (the libav* libaries). The code of the extension is at the end of the question. The extension compiles successfully but whenever I open Python and want to call it (using a simple Python wrapper code that I don't include here), I get

Python 3.7.10 (default, May 2 2021, 18:28:10)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import myModule
>>> myModule.convert_video("/home/admin/video.h264", "/home/admin/video.mp4")
convert 0
convert 1
Format raw H.264 video, duration -9223372036854775808 us
convert 2
Segmentation fault (core dumped)



The interesting thing is, I wrote a simple helper program
test_convert.cc
that callsconvertVideo()
like so

#include 
#include 

int convertVideo(const char *in_filename, const char *out_filename);

int main() {
 int res = convertVideo("/home/admin/video.h264", "/home/admin/video.mp4");
 return 0;
}



and I compiled this program making use of the shared library that Python generates when building the C extension like so


gcc test_convert.cc /usr/lib/python3.7/site-packages/_myModule.cpython-37m-aarch64-linux-gnu.so -o test_convert



And it works ! The output is


root# ./test_convert
convert 0
convert 1
Format raw H.264 video, duration -9223372036854775808 us
convert 2
convert 3
convert 4
convert 5
convert 6
Output #0, mp4, to '/home/admin/video.mp4':
 Stream #0:0: Video: h264 (High), yuv420p(tv, bt470bg, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31
convert 7



The extension code looks like this


#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

extern "C"
{
#include "libavformat/avformat.h"
#include "libavutil/imgutils.h"
}

int convertVideo(const char *in_filename, const char *out_filename)
{
 // Input AVFormatContext and Output AVFormatContext
 AVFormatContext *input_format_context = avformat_alloc_context();
 AVPacket pkt;

 int ret, i;
 int frame_index = 0;
 printf("convert 0\n");
 av_register_all();
 printf("convert 1\n");
 // Input
 if ((ret = avformat_open_input(&input_format_context, in_filename, NULL,
 NULL)) < 0)
 {
 printf("Could not open input file.");
 return 1;
 }
 else
 {
 printf("Format %s, duration %lld us\n",
 input_format_context->iformat->long_name,
 input_format_context->duration);
 }
 printf("convert 2\n");
 if ((ret = avformat_find_stream_info(input_format_context, 0)) < 0)
 {
 printf("Failed to retrieve input stream information");
 return 1;
 }
 printf("convert 3\n");
 AVFormatContext *output_format_context = avformat_alloc_context();
 AVPacket packet;
 int stream_index = 0;
 int *streams_list = NULL;
 int number_of_streams = 0;
 int fragmented_mp4_options = 0;
 printf("convert 4\n");
 avformat_alloc_output_context2(&output_format_context, NULL, NULL,
 out_filename);
 if (!output_format_context)
 {
 fprintf(stderr, "Could not create output context\n");
 ret = AVERROR_UNKNOWN;
 return 1;
 }
 printf("convert 5\n");
 AVOutputFormat *fmt = av_guess_format(0, out_filename, 0);
 output_format_context->oformat = fmt;

 number_of_streams = input_format_context->nb_streams;
 streams_list =
 (int *)av_mallocz_array(number_of_streams, sizeof(*streams_list));

 if (!streams_list)
 {
 ret = AVERROR(ENOMEM);
 return 1;
 }
 for (i = 0; i < input_format_context->nb_streams; i++)
 {
 AVStream *out_stream;
 AVStream *in_stream = input_format_context->streams[i];
 AVCodecParameters *in_codecpar = in_stream->codecpar;
 if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
 in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &&
 in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
 {
 streams_list[i] = -1;
 continue;
 }
 streams_list[i] = stream_index++;

 out_stream = avformat_new_stream(output_format_context, NULL);
 if (!out_stream)
 {
 fprintf(stderr, "Failed allocating output stream\n");
 ret = AVERROR_UNKNOWN;
 return 1;
 }
 ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
 if (ret < 0)
 {
 fprintf(stderr, "Failed to copy codec parameters\n");
 return 1;
 }
 }
 printf("convert 6\n");
 av_dump_format(output_format_context, 0, out_filename, 1);
 if (!(output_format_context->oformat->flags & AVFMT_NOFILE))
 {
 ret = avio_open(&output_format_context->pb, out_filename, AVIO_FLAG_WRITE);
 if (ret < 0)
 {
 fprintf(stderr, "Could not open output file '%s'", out_filename);
 return 1;
 }
 }
 AVDictionary *opts = NULL;
 printf("convert 7\n");
 ret = avformat_write_header(output_format_context, &opts);
 if (ret < 0)
 {
 fprintf(stderr, "Error occurred when opening output file\n");
 return 1;
 }
 int n = 0;

 while (1)
 {
 AVStream *in_stream, *out_stream;
 ret = av_read_frame(input_format_context, &packet);
 if (ret < 0)
 break;
 in_stream = input_format_context->streams[packet.stream_index];
 if (packet.stream_index >= number_of_streams ||
 streams_list[packet.stream_index] < 0)
 {
 av_packet_unref(&packet);
 continue;
 }
 packet.stream_index = streams_list[packet.stream_index];

 out_stream = output_format_context->streams[packet.stream_index];

 out_stream->codec->time_base.num = 1;
 out_stream->codec->time_base.den = 30;

 packet.pts = n * 3000;
 packet.dts = n * 3000;
 packet.duration = 3000;

 packet.pos = -1;

 ret = av_interleaved_write_frame(output_format_context, &packet);
 if (ret < 0)
 {
 fprintf(stderr, "Error muxing packet\n");
 break;
 }
 av_packet_unref(&packet);
 n++;
 }

 av_write_trailer(output_format_context);
 avformat_close_input(&input_format_context);
 if (output_format_context &&
 !(output_format_context->oformat->flags & AVFMT_NOFILE))
 avio_closep(&output_format_context->pb);
 avformat_free_context(output_format_context);
 av_freep(&streams_list);
 if (ret < 0 && ret != AVERROR_EOF)
 {
 fprintf(stderr, "Error occurred\n");
 return 1;
 }
 return 0;
}
// PyMethodDef and other orchestration code is skipped



What is the reason that the code works as expected in my test_convert but not within Python ?


-
ffmpeg says "No JPEG data found in image" when reading image paths from Linux pipe
18 septembre 2021, par user16945608I'm trying to convert a set of pictures into a video, and I want to read the file paths of the pictures from the pipe. The command I would like to run looks like this :


find dir/*.JPG | sort | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -s 6000x4000 -pix_fmt yuvj422p -i - -vcodec libx264 -s 1080x720 -r 20 -pix_fmt yuv420p out.mkv


But I keep obtaining the
No JPEG data found in image
error. Here is the full log :

Input #0, image2pipe, from 'pipe:':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: mjpeg, yuvj422p(bt470bg/unknown/unknown), 6000x4000, 1 fps, 1 tbr, 1 tbn, 1 tbc
Stream mapping:
 Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
[mjpeg @ 0x558e98cd7300] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input
[swscaler @ 0x558e98ce9440] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x558e98cdaac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x558e98cdaac0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x558e98cdaac0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft
2003-2021 - http://www.videolan.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=6 lookahead_threads=1 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=20 scenecut=40 intra_refresh=0 rc_lookahead=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, matroska, to 'out.mkv':
 Metadata:
 encoder : Lavf58.76.100
 Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1080x720, q=2-31, 20 fps, 1k tbn
 Metadata:
 encoder : Lavc58.134.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 0 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!



The pictures are in the following format (with
mediainfo
) and the filenames are in the formDSC_1234.JPG
:

Format : JPEG
Video
Format : JPEG
Width : 6 000 pixels
Height : 4 000 pixels
Display aspect ratio : 3:2
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Compression mode : Lossy



Also, I would like to avoid using a solution without piping the paths (with
-f image2 -i DSC_%04d.JPG
for example). Do you have any idea what's happening ?

-
FFmpeg's common filter "v360" missing
26 septembre 2021, par Niklas E.I'm trying to convert a 180° fisheye video to a normal/regular video using the
v360
filter of FFmpeg.

This is the command I tried :

ffmpeg -i in.mp4 -vf "v360=input=fisheye:output=flat:iv_fov=180:v_fov=90" out.mp4


But the output says clearly
No such filter: 'v360'
, although v360 is a common filter listed in docs and other filters I used before worked just fine. I tried updating/reinstalling and looking for solutions, not fixing it.

Why is the filter missing ? How can I debug this ? Should I doe the task using another program entirely ?


Command output :


ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
 configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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-libvidstab --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-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
 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
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
 Metadata:
 major_brand : mp42
 minor_version : 0
 compatible_brands: mp42mp41
 creation_time : 2021-09-11T14:18:33.000000Z
 Duration: 00:02:48.02, start: 0.000000, bitrate: 26056 kb/s
 Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 2160x1080 [SAR 1:1 DAR 2:1], 25924 kb/s, 50 fps, 50 tbr, 50k tbn, 100 tbc (default)
 Metadata:
 creation_time : 2021-09-11T14:18:33.000000Z
 handler_name : Mainconcept MP4 Video Media Handler
 encoder : AVC Coding
 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
 Metadata:
 creation_time : 2021-09-11T14:18:33.000000Z
 handler_name : Mainconcept MP4 Sound Media Handler
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
 Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[AVFilterGraph @ 0x55ee57567340] No such filter: 'v360'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!