Recherche avancée

Médias (1)

Mot : - Tags -/getid3

Autres articles (58)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

Sur d’autres sites (8964)

  • avcodec/vp8 : Fix wrong vpx_rac_is_end() check

    16 novembre 2022, par Hirokazu Honda
    avcodec/vp8 : Fix wrong vpx_rac_is_end() check
    

    The check of vpx_rac_is_end check(s) are added originally from
    1afd246960202917e244c844c534e9c1e3c323f5. It causes a regression
    of some vp8 stream. b6b9ac5698c8f911841b469af77199153278c55c fixes
    the regression by a sort of band-aid way. This fixes the wrongness
    of the original commit. vpx_rac_is_end() should be called against
    the bool decoder for the vp8 headr context, not one for each
    coefficient. Reference is vp8_dixie_tokens_process_row() in token.c
    in spec 20.16.

    Fixes : Ticket 8069
    Fixes : regression of 1afd246960202917e244c844c534e9c1e3c323f5.
    Fixes : b6b9ac5698c8f911841b469af77199153278c55c

    Co-authored-by : Ronald S. Bultje <rsbultje@gmail.com>
    Signed-off-by : Hirokazu Honda <hiroh@chromium.org>
    Signed-off-by : Ronald S. Bultje <rsbultje@gmail.com>

    • [DH] libavcodec/vp8.c
  • ffmpeg output gives file not found error in python

    20 octobre 2022, par Batuhan Yılmaz

    Trying to build an auto subtitled video generator in Python. But couldn't generate the subtitled video of the input video using ffmpeg. Getting an error saying there is no output.mp4. FileNotFoundError : [Errno 2] No such file or directory : 'C :\Users\batuh\Desktop\auto-multipage\output.mp4'

    &#xA;

    Can you help me out ? Full code is here : https://github.com/BatuhanYilmaz26/auto-sub-exp/blob/main/pages/02_up3.py

    &#xA;

    Here's the parts where I used ffmpeg :

    &#xA;

    def inferecence(loaded_model, uploaded_file, task):&#xA;    with open(f"{save_dir}/audio.mp3" , "wb") as f:&#xA;            f.write(uploaded_file.read())&#xA;        audio = ffmpeg.input(f"{save_dir}/audio.mp3")&#xA;        audio = ffmpeg.output(audio, f"{save_dir}/output.wav", acodec="pcm_s16le", ac=1, ar="16k")&#xA;        ffmpeg.run(audio, overwrite_output=True)&#xA;    if task == "Transcribe":&#xA;            options = dict(task="transcribe", best_of=5)&#xA;            results = loaded_model.transcribe(f"{save_dir}/output.wav", **options)&#xA;            vtt = getSubs(results["segments"], "vtt", 80)&#xA;            srt = getSubs(results["segments"], "srt", 80)&#xA;            lang = results["language"]&#xA;    return results["text"], vtt, srt, lang&#xA;    elif task == "Translate":&#xA;            options = dict(task="translate", best_of=5)&#xA;            results = loaded_model.transcribe(f"{save_dir}/output.wav", **options)&#xA;            vtt = getSubs(results["segments"], "vtt", 80)&#xA;            srt = getSubs(results["segments"], "srt", 80)&#xA;            lang = results["language"]&#xA;    return results["text"], vtt, srt, lang&#xA;    else:&#xA;    raise ValueError("Task not supported")&#xA;    &#xA;    results = inferecence(loaded_model, input_file, task)&#xA;    &#xA;    subprocess.run(shlex.split(f"ffmpeg -i {save_dir}/input.mp4 -i {save_dir}/output.wav -i transcript.srt -c:v copy -c:a copy -c:s copy -map 0:a -map 1:v -map 2:s -metadata:s:a:0 language={results[3]} -y {save_dir}/output.mp4"))&#xA;    #subprocess.run(shlex.split(f"ffmpeg -i {save_dir}/input.mp4 -vf {save_dir}/transcript.srt -y {save_dir}/output.mp4"))&#xA;    with open(os.path.join(os.getcwd(), "output.mp4"), "rb") as f:&#xA;                        data = f.read()&#xA;                    st.video(data)&#xA;                    st.download_button(label="Download Subtitled Video",&#xA;                                        data=data,&#xA;                                        file_name="output.mp4")&#xA;

    &#xA;

    sorry about the indentations

    &#xA;

    Logfile :

    &#xA;

    ffmpeg started on 2022-10-20 at 23:43:53&#xA;Report written to "ffmpeg-20221020-234353.log"&#xA;Command line:&#xA;ffmpeg -i C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4 -i C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.wav -i transcript.srt -c:v copy -c:a copy -c:s copy -map 0:a -map 1:v -map 2:s -metadata:s:a:0 "language=eng" -y C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.mp4 -report&#xA;ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with gcc 9.3.1 (GCC) 20200523&#xA;  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;Splitting the commandline.&#xA;Reading option &#x27;-i&#x27; ... matched as input url with argument &#x27;C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as input url with argument &#x27;C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.wav&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as input url with argument &#x27;transcript.srt&#x27;.&#xA;Reading option &#x27;-c:v&#x27; ... matched as option &#x27;c&#x27; (codec name) with argument &#x27;copy&#x27;.&#xA;Reading option &#x27;-c:a&#x27; ... matched as option &#x27;c&#x27; (codec name) with argument &#x27;copy&#x27;.&#xA;Reading option &#x27;-c:s&#x27; ... matched as option &#x27;c&#x27; (codec name) with argument &#x27;copy&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;0:a&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;1:v&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;2:s&#x27;.&#xA;Reading option &#x27;-metadata:s:a:0&#x27; ... matched as option &#x27;metadata&#x27; (add metadata) with argument &#x27;language=eng&#x27;.&#xA;Reading option &#x27;-y&#x27; ... matched as option &#x27;y&#x27; (overwrite output files) with argument &#x27;1&#x27;.&#xA;Reading option &#x27;C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.mp4&#x27; ... matched as output url.&#xA;Reading option &#x27;-report&#x27; ... matched as option &#x27;report&#x27; (generate a report) with argument &#x27;1&#x27;.&#xA;Finished splitting the commandline.&#xA;Parsing a group of options: global .&#xA;Applying option y (overwrite output files) with argument 1.&#xA;Applying option report (generate a report) with argument 1.&#xA;Successfully parsed a group of options.&#xA;Parsing a group of options: input url C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4.&#xA;Successfully parsed a group of options.&#xA;Opening an input file: C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4.&#xA;[NULL @ 000001fba186b9c0] Opening &#x27;C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4&#x27; for reading&#xA;[file @ 000001fba186c140] Setting default whitelist &#x27;file,crypto&#x27;&#xA;C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4: No such file or directory&#xA;

    &#xA;

  • ffmpeg video encoder skips first frames [duplicate]

    19 octobre 2022, par Eduard Barnoviciu

    I am new to ffmpeg. I am trying to run this simple video encoding example :

    &#xA;

    &#xA;#include <iostream>&#xA;#include <vector>&#xA;// FFmpeg&#xA;extern "C" {&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;}&#xA;// OpenCV&#xA;#include <opencv2></opencv2>opencv.hpp>&#xA;#include <opencv2></opencv2>highgui.hpp>&#xA;&#xA;&#xA;int main(int argc, char* argv[])&#xA;{&#xA;    if (argc &lt; 2) {&#xA;        std::cout &lt;&lt; "Usage: cv2ff <outfile>" &lt;&lt; std::endl;&#xA;        return 1;&#xA;    }&#xA;    const char* outfile = argv[1];&#xA;&#xA; // av_log_set_level(AV_LOG_DEBUG);&#xA;    int ret;&#xA;&#xA;    const int dst_width = 640;&#xA;    const int dst_height = 480;&#xA;    const AVRational dst_fps = {30, 1};&#xA;&#xA;    // initialize OpenCV capture as input frame generator&#xA;    cv::VideoCapture cvcap(0);&#xA;    if (!cvcap.isOpened()) {&#xA;        std::cerr &lt;&lt; "fail to open cv::VideoCapture";&#xA;        return 2;&#xA;    }&#xA;    cvcap.set(cv::CAP_PROP_FRAME_WIDTH, dst_width);&#xA;    cvcap.set(cv::CAP_PROP_FRAME_HEIGHT, dst_height);&#xA;    cvcap.set(cv::CAP_PROP_FPS, dst_fps.num);&#xA;    // some device ignore above parameters for capturing image,&#xA;    // so we query actual parameters for image rescaler.&#xA;    const int cv_width = cvcap.get(cv::CAP_PROP_FRAME_WIDTH);&#xA;    const int cv_height = cvcap.get(cv::CAP_PROP_FRAME_HEIGHT);&#xA;    const int cv_fps = cvcap.get(cv::CAP_PROP_FPS);&#xA;&#xA;    // open output format context&#xA;    AVFormatContext* outctx = nullptr;&#xA;    ret = avformat_alloc_output_context2(&amp;outctx, nullptr, nullptr, outfile);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avformat_alloc_output_context2(" &lt;&lt; outfile &lt;&lt; "): ret=" &lt;&lt; ret;&#xA;        return 2;&#xA;    }&#xA;&#xA;    // create new video stream&#xA;    AVCodec* vcodec = avcodec_find_encoder(outctx->oformat->video_codec);&#xA;    AVStream* vstrm = avformat_new_stream(outctx, vcodec);&#xA;    if (!vstrm) {&#xA;        std::cerr &lt;&lt; "fail to avformat_new_stream";&#xA;        return 2;&#xA;    }&#xA;&#xA;    // open video encoder&#xA;    AVCodecContext* cctx = avcodec_alloc_context3(vcodec);&#xA;    if (!vstrm) {&#xA;        std::cerr &lt;&lt; "fail to avcodec_alloc_context3";&#xA;        return 2;&#xA;    }&#xA;    cctx->width = dst_width;&#xA;    cctx->height = dst_height;&#xA;    cctx->pix_fmt = vcodec->pix_fmts[0];&#xA;    cctx->time_base = av_inv_q(dst_fps);&#xA;    cctx->framerate = dst_fps;&#xA;    if (outctx->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        cctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    ret = avcodec_open2(cctx, vcodec, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avcodec_open2: ret=" &lt;&lt; ret;&#xA;        return 2;&#xA;    }&#xA;    avcodec_parameters_from_context(vstrm->codecpar, cctx);&#xA;&#xA;    // initialize sample scaler&#xA;    SwsContext* swsctx = sws_getContext(&#xA;        cv_width, cv_height, AV_PIX_FMT_BGR24,&#xA;        dst_width, dst_height, cctx->pix_fmt,&#xA;        SWS_BILINEAR, nullptr, nullptr, nullptr);&#xA;    if (!swsctx) {&#xA;        std::cerr &lt;&lt; "fail to sws_getContext";&#xA;        return 2;&#xA;    }&#xA;&#xA;    // allocate frame buffer for encoding&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    frame->width = dst_width;&#xA;    frame->height = dst_height;&#xA;    frame->format = static_cast<int>(cctx->pix_fmt);&#xA;    ret = av_frame_get_buffer(frame, 32);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to av_frame_get_buffer: ret=" &lt;&lt; ret;&#xA;        return 2;&#xA;    }&#xA;&#xA;    // allocate packet to retrive encoded frame&#xA;    AVPacket* pkt = av_packet_alloc();&#xA;&#xA;    // open output IO context&#xA;    ret = avio_open2(&amp;outctx->pb, outfile, AVIO_FLAG_WRITE, nullptr, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avio_open2: ret=" &lt;&lt; ret;&#xA;        return 2;&#xA;    }&#xA;&#xA;    std::cout&#xA;        &lt;&lt; "camera:  " &lt;&lt; cv_width &lt;&lt; &#x27;x&#x27; &lt;&lt; cv_height &lt;&lt; &#x27;@&#x27; &lt;&lt; cv_fps &lt;&lt; "\n"&#xA;        &lt;&lt; "outfile: " &lt;&lt; outfile &lt;&lt; "\n"&#xA;        &lt;&lt; "format:  " &lt;&lt; outctx->oformat->name &lt;&lt; "\n"&#xA;        &lt;&lt; "vcodec:  " &lt;&lt; vcodec->name &lt;&lt; "\n"&#xA;        &lt;&lt; "size:    " &lt;&lt; dst_width &lt;&lt; &#x27;x&#x27; &lt;&lt; dst_height &lt;&lt; "\n"&#xA;        &lt;&lt; "fps:     " &lt;&lt; av_q2d(cctx->framerate) &lt;&lt; "\n"&#xA;        &lt;&lt; "pixfmt:  " &lt;&lt; av_get_pix_fmt_name(cctx->pix_fmt) &lt;&lt; "\n"&#xA;        &lt;&lt; std::flush;&#xA;&#xA;    // write media container header (if any)&#xA;    ret = avformat_write_header(outctx, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avformat_write_header: ret=" &lt;&lt; ret;&#xA;        return 2;&#xA;    }&#xA;&#xA;    cv::Mat image;&#xA;&#xA;    // encoding loop&#xA;    int64_t frame_pts = 0;&#xA;    unsigned nb_frames = 0;&#xA;    bool end_of_stream = false;&#xA;    for (;;) {&#xA;        if (!end_of_stream) {&#xA;            // retrieve source image&#xA;            cvcap >> image;&#xA;            cv::imshow("press ESC to exit", image);&#xA;            if (cv::waitKey(33) == 0x1b) {&#xA;                // flush encoder&#xA;                avcodec_send_frame(cctx, nullptr);&#xA;                end_of_stream = true;&#xA;            }&#xA;        }&#xA;        if (!end_of_stream) {&#xA;            // convert cv::Mat(OpenCV) to AVFrame(FFmpeg)&#xA;            const int stride[4] = { static_cast<int>(image.step[0]) };&#xA;            sws_scale(swsctx, &amp;image.data, stride, 0, image.rows, frame->data, frame->linesize);&#xA;            frame->pts = frame_pts&#x2B;&#x2B;;&#xA;            // encode video frame&#xA;            ret = avcodec_send_frame(cctx, frame);&#xA;            if (ret &lt; 0) {&#xA;                std::cerr &lt;&lt; "fail to avcodec_send_frame: ret=" &lt;&lt; ret &lt;&lt; "\n";&#xA;                break;&#xA;            }&#xA;        }&#xA;        while ((ret = avcodec_receive_packet(cctx, pkt)) >= 0) {&#xA;            // rescale packet timestamp&#xA;            pkt->duration = 1;&#xA;            av_packet_rescale_ts(pkt, cctx->time_base, vstrm->time_base);&#xA;            // write encoded packet&#xA;            av_write_frame(outctx, pkt);&#xA;            av_packet_unref(pkt);&#xA;            std::cout &lt;&lt; nb_frames &lt;&lt; &#x27;\r&#x27; &lt;&lt; std::flush;  // dump progress&#xA;            &#x2B;&#x2B;nb_frames;&#xA;        }&#xA;        if (ret == AVERROR_EOF)&#xA;            break;&#xA;    };&#xA;    std::cout &lt;&lt; nb_frames &lt;&lt; " frames encoded" &lt;&lt; std::endl;&#xA;&#xA;    // write trailer and close file&#xA;    av_write_trailer(outctx);&#xA;    avio_close(outctx->pb);&#xA;&#xA;    av_packet_free(&amp;pkt);&#xA;    av_frame_free(&amp;frame);&#xA;    sws_freeContext(swsctx);&#xA;    avcodec_free_context(&amp;cctx);&#xA;    avformat_free_context(outctx);&#xA;    return 0;&#xA;}&#xA;</int></int></outfile></vector></iostream>

    &#xA;

    The problem is, while using codecs such as HEVC, H265 or VP9, the encoder always drops first 27 frames.

    &#xA;

    More exactly, at line 163 :

    &#xA;

      while ((ret = avcodec_receive_packet(cctx, pkt)) >= 0) {&#xA;

    &#xA;

    ret is equal to -11 and it doesn't go inside the while loop. From that point onward it's always equal to 0 and no issues are found.

    &#xA;

    If I use MPEG4 for example, ret is 0 from the start and no frames are dropped.

    &#xA;