Recherche avancée

Médias (3)

Mot : - Tags -/plugin

Autres articles (45)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

Sur d’autres sites (3791)

  • ffmpeg can't stream to remote client

    4 septembre 2014, par KFL

    I’m building a simple ffmpeg command line on my laptop to stream from its camera. The command line reads (verbose output at the botton) :

    host1> ffmpeg -v verbose \
                 -f dshow \
                 -i video="Camera":audio="Microphone" \
                 -r 30 -g 0 -vcodec h264 -acodec libmp3lame \
                 -tune zerolatency \
                 -preset ultrafast \
                 -f mpegts udp://12.34.56.78:12345

    Firstly, it works locally. I.e., I can view the output by using ffplay on the same host :

    host1> ffplay -hide_banner -v udp://12.34.56.78:12345

    Now what is NOT working is when I do this from another machine in the same network. It shows a nan progress :

    host2> ffplay -hide_banner -v udp://12.34.56.78:12345
       nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0  

    I used ncat to dump the raw content. But there’s no output :

    host2>\ncat\ncat -v -u 12.34.56.78 12345
    Ncat: Version 5.59BETA1 ( http://nmap.org/ncat )
    Ncat: Connected to 12.34.56.78:12345.
    (...and nothing happen...)

    Note that I can exclude firewall issues as I used ncat to communicate with each other across the wire using the same port and protocol (UDP). This works and they can chat to each other :

    host1> ncat -l -u -p 12345
    host2> ncat -u 12.34.56.78 12345

    Any hint ?

    I’m using Windows x64 with FFMPEG 64bit installed from here. Below is the Output of my ffmpeg command :

    C:\ffmpeg\bin>ffmpeg -v verbose -f dshow -i video="Integrated Camera":audio="Microphone (Realtek High Definition Audio)" -r 30 -g 0 -vcodec h264 -acodec libmp3lame -tune zerolatency -preset ultrafast -f mpegts udp://12.34.56.78:12345
    ffmpeg version N-66012-g97b8809 Copyright (c) 2000-2014 the FFmpeg developers
     built on Sep  1 2014 00:21:15 with gcc 4.8.3 (GCC)
     configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug -enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
     libavutil      54.  7.100 / 54.  7.100
     libavcodec     56.  1.100 / 56.  1.100
     libavformat    56.  3.100 / 56.  3.100
     libavdevice    56.  0.100 / 56.  0.100
     libavfilter     5.  0.103 /  5.  0.103
     libswscale      3.  0.100 /  3.  0.100
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  0.100 / 53.  0.100
    Guessed Channel Layout for  Input Stream #0.1 : stereo
    Input #0, dshow, from 'video=Integrated Camera:audio=Microphone (Realtek High Definition Audio)':
     Duration: N/A, start: 171840.657000, bitrate: N/A
       Stream #0:0: Video: rawvideo, bgr24, 640x480, 30 fps, 30 tbr, 10000k tbn, 30 tbc
       Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
    Matched encoder 'libx264' for codec 'h264'.
    [graph 0 input from stream 0:0 @ 0000000000470aa0] w:640 h:480 pixfmt:bgr24 tb:1/10000000 fr:10000000/333333 sar:0/1 sws_param:flags=2
    [auto-inserted scaler 0 @ 0000000004326d00] w:iw h:ih flags:'0x4' interl:0
    [format @ 0000000004325a00] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
    [auto-inserted scaler 0 @ 0000000004326d00] w:640 h:480 fmt:bgr24 sar:0/1 -> w:640 h:480 fmt:yuv444p sar:0/1 flags:0x4
    No pixel format specified, yuv444p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
    [graph 1 input from stream 0:1 @ 0000000000460c20] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
    [audio format for output stream 0:1 @ 00000000004601a0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
    [auto-inserted resampler 0 @ 00000000004604a0] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2 chl:stereo fmt:s16p r:44100Hz
    [libx264 @ 000000000081bb20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 000000000081bb20] profile High 4:4:4 Intra, level 3.0, 4:4:4 8-bit
    [mpegts @ 000000000081abe0] muxrate VBR, pcr every 3 pkts, sdt every 200, pat/pmt every 40 pkts
    Output #0, mpegts, to 'udp://12.34.56.78:12345':
     Metadata:
       encoder         : Lavf56.3.100
       Stream #0:0: Video: h264 (libx264), yuv444p, 640x480, q=-1--1, 30 fps, 90k tbn, 30 tbc
       Metadata:
         encoder         : Lavc56.1.100 libx264
       Stream #0:1: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
       Metadata:
         encoder         : Lavc56.1.100 libmp3lame
    Stream mapping:
     Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
    Press [q] to stop, [?] for help
    *** 1 dup!
    frame=  241 fps= 31 q=28.0 Lsize=    3439kB time=00:00:08.03 bitrate=3506.4kbits/s dup=1 drop=0
    video:3035kB audio:125kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.791966%
    Input file #0 (video=Integrated Camera:audio=Microphone (Realtek High Definition Audio)):
     Input stream #0:0 (video): 240 packets read (221184000 bytes); 240 frames decoded;
     Input stream #0:1 (audio): 16 packets read (1411200 bytes); 16 frames decoded (352800 samples);
     Total: 256 packets (222595200 bytes) demuxed
    Output file #0 (udp://12.34.56.78:12345):
     Output stream #0:0 (video): 241 frames encoded; 241 packets muxed (3108187 bytes);
     Output stream #0:1 (audio): 306 frames encoded (352512 samples); 307 packets muxed (128313 bytes);
     Total: 548 packets (3236500 bytes) muxed
    [libx264 @ 000000000081bb20] frame I:241   Avg QP:27.97  size: 12897
    [libx264 @ 000000000081bb20] mb I  I16..4: 100.0%  0.0%  0.0%
    [libx264 @ 000000000081bb20] coded y,u,v intra: 26.3% 0.5% 0.0%
    [libx264 @ 000000000081bb20] i16 v,h,dc,p: 19% 28% 21% 31%
    [libx264 @ 000000000081bb20] kb/s:3095.29
    [dshow @ 0000000000467720] real-time buffer[Integrated Camera] too full (90% of size: 3041280)! frame dropped!
    Received signal 2: terminating. (I pressed CTRL-C)
  • Ffmpeg and Xing header - iTunes issue and Duration issue

    17 mars 2023, par Abs

    I extract the audio from a bunch of flv files as an MP3. This works great :

    


    ffmpeg -i video.flv -vn -acodec copy audio.mp3


    


    However, some audio that I extract have durations that are longer than they should be and some MP3 files keep looping the audio ! Also in some audio players like WMP, the seekbar gets stuck at one point.

    


    I have found out this is due to Xing headers not being correct or set (?). I was hoping someone could help me edit the above command so this is fixed and maybe some explanation of why this happens so I can learn.

    


  • ffmpeg decoding through C-API leads to artefacts when input resolution is 1200x1600. Am I doing something wrong ?

    26 février 2023, par Antonio

    Using the C-API and FFmpeg 5.1 I have been able to encode h264 videos with libx264 on Android.
Now I wanted to replay them on Linux inside my C++ application. These videos can be played correctly on a browser, or on other players that I tried like mplayer or ffplay from ffmpeg. Also, I can unroll the frames with ffmpeg -i recording.mp4 -start_number 0 -qscale:v 5 %06d.jpg and the images look alright.

    


    However in my C++ application every now and then, but in a very repeatable way, I get artifacts (like the bright pixels showing up above the monitor). They do not accumulate, even though they are not related to keyframes. So whatever error is going on, it doesn't seem to have an impact on subsequent frames. I use OpenCV to visualize the output, and I am pretty sure the problem is not the conversion to BGR because the artifact is already there if I simply show the y channel (luminance, grayscale).

    


    These artifacts show up in videos that I have recorded with a 1200x1600 resolution. It is to be noted that 1200 is not divisible by 32 so ffmpeg does add some padding, but I am dealing with it and it's not an issue. Videos recorded at 1920x1440 are replayed with no artifacts. Two sample videos can be found here for download.

    


    Here follows the code I am using, on the bottom you can see a picture of my decoded image with the artifact and the same as unrolled by ffmpeg command line. It should be noted that I am working with a custom built version of ffmpeg, out of conan packages, while the unrolling is done with ffmpeg from command line that comes with Ubuntu.

    


    extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;}&#xA;&#xA;#include &#xA;#include &#xA;#include &#xA;&#xA;#include <iostream>&#xA;int main(int argc, char** argv) {&#xA;&#xA;    int ret;&#xA;&#xA;    auto pkt = av_packet_alloc();&#xA;    if (!pkt) {&#xA;        std::cerr &lt;&lt; "Failed av_packet_alloc()" &lt;&lt; std::endl;&#xA;        exit(1);&#xA;    }&#xA;&#xA;    AVFormatContext* av_format = avformat_alloc_context();&#xA;    ret = avformat_open_input(&amp;av_format, FILE_NAME, nullptr, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed avformat_open_input, Error: " &lt;&lt; ret &lt;&lt; std::endl;&#xA;        ///Error codes https://stackoverflow.com/questions/12780931/ffmpeg-exit-status-1094995529&#xA;        exit(1);&#xA;    }&#xA;    av_dump_format(av_format, 0, FILE_NAME, 0);&#xA;    auto video_st_number = av_find_best_stream(av_format, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);&#xA;    if (video_st_number &lt; 0) {&#xA;        std::cerr &lt;&lt; "av_find_best_stream couldn&#x27;t find video stream" &lt;&lt; std::endl;&#xA;        exit(1);&#xA;    }&#xA;    auto video_st = av_format->streams[video_st_number];&#xA;    auto codec_id = video_st->codecpar->codec_id;&#xA;    std::cout &lt;&lt; "Duration " &lt;&lt; video_st->duration &lt;&lt; std::endl;&#xA;    std::cout &lt;&lt; "n_frames " &lt;&lt; video_st->nb_frames &lt;&lt; std::endl;&#xA;&#xA;    auto frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    auto codec = avcodec_find_decoder(codec_id);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    auto c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not allocate video codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;&#xA;    if ((ret = avcodec_parameters_to_context(c, video_st->codecpar))) {&#xA;        fprintf(stderr, "Failed avcodec_parameters_to_context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    c->pix_fmt = AV_PIX_FMT_YUV420P;///Not really necessary&#xA;    c->thread_count = 1;///No impact&#xA;&#xA;    /* open it */&#xA;    if (avcodec_open2(c, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n ");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    std::size_t counter = 0;&#xA;    std::size_t n_keyframes = 0;&#xA;&#xA;    while (ret >= 0) {&#xA;        ret = av_read_frame(av_format, pkt);&#xA;        if (pkt->size == 0) {&#xA;            std::cout &lt;&lt; "Skipping packet of size zero" &lt;&lt; std::endl;&#xA;            av_packet_unref(pkt);&#xA;            continue;&#xA;        }&#xA;        while (avcodec_send_packet(c, pkt) != 0) {&#xA;            if (avcodec_receive_frame(c, frame) != 0) {&#xA;                std::cerr &lt;&lt; "Error receiving frame" &lt;&lt; std::endl;&#xA;                exit(1);&#xA;            } else {&#xA;                n_keyframes &#x2B;= frame->key_frame;&#xA;                std::cout &lt;&lt; "Decoded " &lt;&lt; &#x2B;&#x2B;counter &lt;&lt; " frames. Frame No. " &lt;&lt; frame->pts / pkt->duration &lt;&lt; " "&#xA;                          &lt;&lt; frame->decode_error_flags &lt;&lt; " " &lt;&lt; frame->key_frame &lt;&lt; " " &lt;&lt; n_keyframes &lt;&lt; " "&#xA;                          &lt;&lt; frame->pkt_dts &lt;&lt; std::endl;&#xA;            }&#xA;            display(frame);&#xA;        }&#xA;        av_packet_unref(pkt);&#xA;    }&#xA;&#xA;    avcodec_send_packet(c, nullptr);&#xA;    std::cout &lt;&lt; "Flushing decoder" &lt;&lt; std::endl;&#xA;&#xA;    while (avcodec_receive_frame(c, frame) == 0) {&#xA;        n_keyframes &#x2B;= frame->key_frame;&#xA;        std::cout &lt;&lt; "Decoded " &lt;&lt; &#x2B;&#x2B;counter &lt;&lt; " frames. Frame No. " &lt;&lt; frame->pts &lt;&lt; " " &lt;&lt; frame->decode_error_flags&#xA;                  &lt;&lt; " " &lt;&lt; frame->key_frame &lt;&lt; " " &lt;&lt; n_keyframes &lt;&lt; " " &lt;&lt; frame->pkt_dts &lt;&lt; std::endl;&#xA;&#xA;        display(frame);&#xA;    }&#xA;&#xA;    avcodec_free_context(&amp;c);&#xA;    avformat_free_context(av_format);&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;&#xA;    return 0;&#xA;}&#xA;</iostream>

    &#xA;

    Picture as from my encoder&#xA;Picture from ffmpeg command line unrolling

    &#xA;

    For completeness, this is the display function, using openCV

    &#xA;

    void display(const AVFrame* frame) {&#xA;    static std::vector yuv_buffer;&#xA;    yuv_buffer.resize(frame->linesize[0] * 3 / 2 * frame->width);&#xA;    cv::Mat mYUV(frame->height * 3 / 2, frame->width, CV_8UC1, yuv_buffer.data(), frame->linesize[0]);&#xA;    memcpy(mYUV.ptr(), frame->data[0], frame->linesize[0] * frame->height);&#xA;    //cv::imshow("grayscale", mYUV.rowRange(0, frame->height));&#xA;    //cv::imshow("u", cv::Mat(frame->height / 2, frame->width / 2, CV_8UC1, frame->data[1], frame->linesize[1]));&#xA;    //cv::imshow("v", cv::Mat(frame->height / 2, frame->width / 2, CV_8UC1, frame->data[2], frame->linesize[2]));&#xA;&#xA;    int dest_row = frame->height;&#xA;    for (int j = 0; j &lt; frame->height / 2; j&#x2B;&#x2B;) {&#xA;        memcpy(mYUV.ptr(dest_row), frame->data[1] &#x2B; frame->linesize[1] * j, frame->width);&#xA;        j&#x2B;&#x2B;;&#xA;        memcpy(mYUV.ptr(dest_row) &#x2B; frame->width / 2, frame->data[1] &#x2B; frame->linesize[1] * j, frame->width);&#xA;        dest_row&#x2B;&#x2B;;&#xA;    }&#xA;    for (int j = 0; j &lt; frame->height / 2; j&#x2B;&#x2B;) {&#xA;        memcpy(mYUV.ptr(dest_row), frame->data[2] &#x2B; frame->linesize[2] * j, frame->width);&#xA;        j&#x2B;&#x2B;;&#xA;        memcpy(mYUV.ptr(dest_row) &#x2B; frame->width / 2, frame->data[2] &#x2B; frame->linesize[2] * j, frame->width);&#xA;        dest_row&#x2B;&#x2B;;&#xA;    }&#xA;    cv::Mat mRGB(frame->height, frame->width, CV_8UC3);&#xA;    cvtColor(mYUV, mRGB, cv::COLOR_YUV2BGR_I420, 3);&#xA;    cv::imshow("Video", mRGB);&#xA;    cv::waitKey(0);&#xA;}&#xA;

    &#xA;


    &#xA;

    Note : The AVFrame -> cv::Mat converter is now available in corrected version as answer here.

    &#xA;