Recherche avancée

Médias (2)

Mot : - Tags -/plugins

Autres articles (37)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains 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, par

    Pré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 ) (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-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

Sur d’autres sites (6362)

  • FFmpeg : "Invalid data found when processing input" when reading video from memory

    24 avril 2020, par Drawoceans

    I'm trying to read a mp4 video file from memory with C++ and FFmpeg library, but I got "Invalid data found when processing input" error. Here are my codes :

    



    #include <cstdio>&#xA;#include <fstream>&#xA;#include <filesystem>&#xA;&#xA;extern "C"&#xA;{&#xA;#include "libavformat/avformat.h"&#xA;#include "libavformat/avio.h"&#xA;}&#xA;&#xA;using namespace std;&#xA;namespace fs = std::filesystem;&#xA;&#xA;struct VideoBuffer&#xA;{&#xA;    uint8_t* ptr;&#xA;    size_t size;&#xA;};&#xA;&#xA;static int read_packet(void* opaque, uint8_t* buf, int buf_size)&#xA;{&#xA;    VideoBuffer* vb = (VideoBuffer*)opaque;&#xA;    buf_size = FFMIN(buf_size, vb->size);&#xA;&#xA;    if (!buf_size) {&#xA;        return AVERROR_EOF;&#xA;    }&#xA;&#xA;    printf("ptr:%p size:%zu\n", vb->ptr, vb->size);&#xA;&#xA;    memcpy(buf, vb->ptr, buf_size);&#xA;    vb->ptr &#x2B;= buf_size;&#xA;    vb->size -= buf_size;&#xA;&#xA;    return buf_size;&#xA;}&#xA;&#xA;void print_ffmpeg_error(int ret)&#xA;{&#xA;    char* err_str = new char[256];&#xA;    av_strerror(ret, err_str, 256);&#xA;    printf("%s\n", err_str);&#xA;    delete[] err_str;&#xA;}&#xA;&#xA;int main()&#xA;{&#xA;    fs::path video_path = "test.mp4";&#xA;    ifstream video_file;&#xA;    video_file.open(video_path);&#xA;    if (!video_file) {&#xA;        abort();&#xA;    }&#xA;    size_t video_size = fs::file_size(video_path);&#xA;    char* video_ptr = new char[video_size];&#xA;    video_file.read(video_ptr, video_size);&#xA;    video_file.close();&#xA;&#xA;    VideoBuffer vb;&#xA;    vb.ptr = (uint8_t*)video_ptr;&#xA;    vb.size = video_size;&#xA;&#xA;    AVIOContext* avio = nullptr;&#xA;    uint8_t* avio_buffer = nullptr;&#xA;    size_t avio_buffer_size = 4096;&#xA;    avio_buffer = (uint8_t*)av_malloc(avio_buffer_size);&#xA;    if (!avio_buffer) {&#xA;        abort();&#xA;    }&#xA;&#xA;    avio = avio_alloc_context(avio_buffer, avio_buffer_size, 0, &amp;vb, read_packet, nullptr, nullptr);&#xA;&#xA;    AVFormatContext* fmt_ctx = avformat_alloc_context();&#xA;    if (!fmt_ctx) {&#xA;        abort();&#xA;    }&#xA;    fmt_ctx->pb = avio;&#xA;&#xA;    int ret = 0;&#xA;    ret = avformat_open_input(&amp;fmt_ctx, nullptr, nullptr, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        print_ffmpeg_error(ret);&#xA;    }&#xA;&#xA;    avformat_close_input(&amp;fmt_ctx);&#xA;    av_freep(&amp;avio->buffer);&#xA;    av_freep(&amp;avio);&#xA;    delete[] video_ptr;&#xA;    return 0;&#xA;}&#xA;</filesystem></fstream></cstdio>

    &#xA;&#xA;

    And here is what I got :

    &#xA;&#xA;

    ptr:000001E10CEA0070 size:4773617&#xA;ptr:000001E10CEA1070 size:4769521&#xA;...&#xA;ptr:000001E10D32D070 size:1777&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 000001e10caaeac0] moov atom not found&#xA;Invalid data found when processing input&#xA;

    &#xA;&#xA;

    FFmpeg version is 4.2.2, with Windows 10 and Visual Studio 2019 in x64 Debug mode. FFmpeg library is the Windows compiled shared library from FFmpeg homepage. Some codes are from official example avio_reading.c. Target MP4 file can be played normally by VLC player so I think the file is OK. Is anywhere wrong in my codes ? Or is it an FFmpeg library problem ?

    &#xA;

  • FFMPEG:av_rescale_q - time_base difference

    2 décembre 2020, par Michael IV

    I want to know once and for all, how time base calucaltion and rescaling works in FFMPEG. &#xA;Before getting to this question I did some research and found many controversial answers, which make it even more confusing.&#xA;So based on official FFMPEG examples one has to

    &#xA;&#xA;

    &#xA;

    rescale output packet timestamp values from codec to stream timebase

    &#xA;

    &#xA;&#xA;

    with something like this :

    &#xA;&#xA;

    pkt->pts = av_rescale_q_rnd(pkt->pts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;pkt->dts = av_rescale_q_rnd(pkt->dts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;pkt->duration = av_rescale_q(pkt->duration, *time_base, st->time_base);&#xA;

    &#xA;&#xA;

    But in this question a guy was asking similar question to mine, and he gave more examples, each of them doing it differently. And contrary to the answer which says that all those ways are fine, for me only the following approach works :

    &#xA;&#xA;

    frame->pts &#x2B;= av_rescale_q(1, video_st->codec->time_base, video_st->time_base);&#xA;

    &#xA;&#xA;

    In my application I am generating video packets (h264) at 60 fps outside FFMPEG API then write them into mp4 container.

    &#xA;&#xA;

    I set explicitly :

    &#xA;&#xA;

    video_st->time_base = {1,60};&#xA;video_st->r_frame_rate = {60,1};&#xA;video_st->codec->time_base = {1 ,60};&#xA;

    &#xA;&#xA;

    The first weird thing I see happens right after I have written header for the output format context :

    &#xA;&#xA;

    AVDictionary *opts = nullptr;&#xA;int ret = avformat_write_header(mOutputFormatContext, &amp;opts);&#xA;av_dict_free(&amp;opts);&#xA;

    &#xA;&#xA;

    After that ,video_st->time_baseis populated with :

    &#xA;&#xA;

    num = 1;&#xA;den = 15360&#xA;

    &#xA;&#xA;

    And I fail to understand why.

    &#xA;&#xA;

    I want someone please to exaplain me that.Next, before writing frame I calculate&#xA;PTS for the packet. In my case PTS = DTS as I don't use B-frames at all.

    &#xA;&#xA;

    And I have to do this :

    &#xA;&#xA;

     const int64_t duration = av_rescale_q(1, video_st->codec->time_base, video_st->time_base);&#xA; totalPTS &#x2B;= duration; //totalPTS is global variable&#xA; packet->pts = totalPTS ;&#xA; packet->dts = totalPTS ;&#xA; av_write_frame(mOutputFormatContext, mpacket);&#xA;

    &#xA;&#xA;

    I don't get it,why codec and stream have different time_base values even though I explicitly set those to be the same. And because I see across all the examples that av_rescale_q is always used to calculate duration I really want someone to explain this point.

    &#xA;&#xA;

    Additionally, as a comparison, and for the sake of experiment, I decided to try writing stream for WEBM container. So I don't use libav output stream at all.&#xA;I just grab the same packet I use to encode MP4 and write it manually into EBML stream. In this case I calculate duration like this :

    &#xA;&#xA;

     const int64_t duration =&#xA; ( video_st->codec->time_base.num / video_st->codec->time_base.den) * 1000;&#xA;

    &#xA;&#xA;

    Multiplication by 1000 is required for WEBM as the time stamps are presented in milliseconds in that container.And this works. So why in case of MP4 stream encoding there is a difference in time_base which has to be rescaled ?

    &#xA;

  • FFmpeg starting manually but not with Systemd on boot

    23 juin 2021, par eKrajnak

    On Raspberry Pi 4 B 4GB with official Debian 10 image, I have /home/pi/run.sh script with following :

    &#xA;

    #!/bin/bash&#xA;ffmpeg -nostdin -framerate 15 -video_size 1280x720 -input_format yuyv422  -i /dev/video0 -f alsa -i hw:Device \&#xA;    -af acompressor=threshold=-14dB:ratio=9:attack=10:release=1000 -c:a aac -ac 2 -ar 48000 -ab 160k \&#xA;    -c:v libx264 -pix_fmt yuv420p -b:v 3M -bf 1 -g 20 -flags &#x2B;ilme&#x2B;ildct -preset ultrafast \&#xA;    -streamid 0:0x101 -streamid 1:0x100 -mpegts_pmt_start_pid 4096 -mpegts_start_pid 0x259 -metadata:s:a:0 language="" -mpegts_service_id 131 -mpegts_transport_stream_id 9217 -metadata provider_name="Doesnt matter" -metadata service_name="Doesnt matter" \&#xA;    -minrate 3500 -maxrate 3500k -bufsize 4500k -muxrate 4000k  -f mpegts "udp://@239.1.67.13:1234?pkt_size=1316&amp;bitrate=4000000&amp;dscp=34" -loglevel debug &lt; /dev/null > /tmp/ff3.log 2>&amp;1&#xA;

    &#xA;

    Script is starting from console without problems. It takes audio from USB sound card and video from USB camera and creates UDP stream to IPTV. Then I created Systemd service :

    &#xA;

    [Unit]&#xA;Description=Streamer&#xA;After=multi-user.target sound.target network.target&#xA;&#xA;[Service]&#xA;ExecStart=/home/pi/run.sh&#xA;KillMode=control-group&#xA;Restart=on-failure&#xA;TimeoutSec=1&#xA;&#xA;[Install]&#xA;WantedBy=multi-user.target&#xA;Alias=streaming.service&#xA;

    &#xA;

    After restarting Raspberry, script has started, but FFmpeg hangs on error failures in log :

    &#xA;

    cur_dts is invalid st:0 (257) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:1 (256) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:0 (257) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:1 (256) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:0 (257) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:1 (256) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:0 (257) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;cur_dts is invalid st:1 (256) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)&#xA;

    &#xA;

    and will not start streaming to UDP target. But, if I manually login to SSH and issue systemctl stop streaming and then systemctl start streaming Ffmpeg starts successfully. What's different with service auto-start on boot ?

    &#xA;

    Setting the "sleep timeout" at script begginging will not help. However, removing audio stream from FFmpeg config looks to solve auto-start on boot.

    &#xA;