Recherche avancée

Médias (1)

Mot : - Tags -/biographie

Autres articles (53)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

Sur d’autres sites (4641)

  • ffmpeg Command in Docker with Rust Tokio Closes Warp Server Connection (curl 52 Error)

    3 juin 2024, par user762345

    I’m encountering an issue where executing an ffmpeg concatenation command through Rust’s Tokio process in a Docker container causes subsequent HTTP requests to fail. The error occurs exclusively after running the ffmpeg command and making immediate requests, resulting in a “curl 52 empty response from server” error with the connection being closed. Notably, this issue does not occur when running the same setup outside of Docker. Additionally, if no HTTP requests are made after the ffmpeg command, the curl 52 error does not occur.

    


    Here is the verbose curl output of my minimum reproducible example (see below).

    


    curl -v "http://localhost:3030"
*   Trying 127.0.0.1:3030...
* Connected to localhost (127.0.0.1) port 3030 (#0)
> GET / HTTP/1.1
> Host: localhost:3030
> User-Agent: curl/8.1.2
> Accept: */*
> 
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server


    


    Here are Docker logs from my minimum reproducible example (see below). The wav files are concatenated successfully, then the container appears to rebuild.

    


    [2024-06-03T05:26:58Z INFO  minimal_docker_webserver_post_error] Starting server on 0.0.0.0:3030
[2024-06-03T05:26:58Z INFO  warp::server] Server::run; addr=0.0.0.0:3030
[2024-06-03T05:26:58Z INFO  warp::server] listening on http://0.0.0.0:3030
[2024-06-03T05:27:07Z INFO  minimal_docker_webserver_post_error] WAV files concatenated successfully
[Running 'cargo run']
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/minimal_docker_webserver_post_error`
[2024-06-03T05:27:08Z INFO  minimal_docker_webserver_post_error] Starting server on 0.0.0.0:3030
[2024-06-03T05:27:08Z INFO  warp::server] Server::run; addr=0.0.0.0:3030
[2024-06-03T05:27:08Z INFO  warp::server] listening on http://0.0.0.0:3030


    


    What I have tried :
I tried using different web frameworks (Warp, Actix-web) and request crates (reqwest, ureq). I also tried running the setup outside of Docker, which worked as expected without any issues. Additionally, I tried running the setup in Docker without making any HTTP requests after the ffmpeg command, and the connection closed successfully without errors. I also tried posting to httpbin with a minimal request, but the issue persisted.

    


    Minimum reproducible example :

    


    main.rs

    


    use warp::Filter;&#xA;use reqwest::Client;&#xA;use std::convert::Infallible;&#xA;use log::{info, error};&#xA;use env_logger;&#xA;use tokio::process::Command;&#xA;&#xA;#[tokio::main]&#xA;async fn main() {&#xA;    std::env::set_var("RUST_LOG", "debug");&#xA;    env_logger::init();&#xA;&#xA;    let route = warp::path::end()&#xA;        .and_then(handle_request);&#xA;&#xA;    info!("Starting server on 0.0.0.0:3030");&#xA;    warp::serve(route)&#xA;        .run(([0, 0, 0, 0], 3030))&#xA;        .await;&#xA;}&#xA;&#xA;async fn handle_request() -> Result<impl infallible="infallible"> {&#xA;    let client = Client::new();&#xA;&#xA;    let output = Command::new("ffmpeg")&#xA;        .args(&amp;[&#xA;            "y",&#xA;            "-i", "concat:/usr/src/minimal_docker_webserver_post_error/file1.wav|/usr/src/minimal_docker_webserver_post_error/file2.wav",&#xA;            "-c", "copy",&#xA;            "/usr/src/minimal_docker_webserver_post_error/combined.wav"&#xA;        ])&#xA;        .output()&#xA;        .await;&#xA;&#xA;    match output {&#xA;        Ok(output) => {&#xA;            if output.status.success() {&#xA;                info!("WAV files concatenated successfully");&#xA;            } else {&#xA;                error!("Failed to concatenate WAV files: {:?}", output);&#xA;                return Ok(warp::reply::with_status("Failed to concatenate WAV files", warp::http::StatusCode::INTERNAL_SERVER_ERROR));&#xA;            }&#xA;        },&#xA;        Err(e) => {&#xA;            error!("Failed to execute ffmpeg: {:?}", e);&#xA;            return Ok(warp::reply::with_status("Failed to execute ffmpeg", warp::http::StatusCode::INTERNAL_SERVER_ERROR));&#xA;        }&#xA;    }&#xA;&#xA;    // ISSUE: Connection closes with curl: (52) Empty reply from server&#xA;    match client.get("https://httpbin.org/get").send().await {&#xA;        Ok(response) => info!("GET request successful: {:?}", response),&#xA;        Err(e) => error!("GET request failed: {:?}", e),&#xA;    }&#xA;&#xA;    match client.post("https://httpbin.org/post")&#xA;        .body("field1=value1&amp;field2=value2")&#xA;        .send().await {&#xA;        Ok(response) => info!("POST request successful: {:?}", response),&#xA;        Err(e) => error!("POST request failed: {:?}", e),&#xA;    }&#xA;&#xA;    Ok(warp::reply::with_status("Request handled", warp::http::StatusCode::OK))&#xA;}&#xA;</impl>

    &#xA;

    FFMPEG command to generate the two wav files for concatenation

    &#xA;

    ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" file1.wav &amp;&amp; ffmpeg -f lavfi -i "sine=frequency=500:duration=5" file2.wav&#xA;

    &#xA;

    Dockerfile

    &#xA;

    # Use the official Rust image as the base image&#xA;FROM rust:latest&#xA;&#xA;# Install cargo-watch&#xA;RUN cargo install cargo-watch&#xA;&#xA;# Install ffmpeg&#xA;RUN apt-get update &amp;&amp; apt-get install -y ffmpeg&#xA;&#xA;# Set the working directory inside the container&#xA;WORKDIR /usr/src/minimal_docker_webserver_post_error&#xA;&#xA;# Copy the Cargo.toml and Cargo.lock files&#xA;COPY Cargo.toml Cargo.lock ./&#xA;&#xA;# Copy the source code&#xA;COPY src ./src&#xA;&#xA;# Copy wav files&#xA;COPY file1.wav /usr/src/minimal_docker_webserver_post_error/file1.wav&#xA;COPY file2.wav /usr/src/minimal_docker_webserver_post_error/file2.wav&#xA;&#xA;# Install dependencies&#xA;RUN cargo build --release&#xA;&#xA;# Expose the port that the application will run on&#xA;EXPOSE 3030&#xA;&#xA;# Set the entry point to use cargo-watch&#xA;CMD ["cargo", "watch", "-x", "run"]&#xA;

    &#xA;

    Cargo.toml

    &#xA;

    [package]&#xA;name = "minimal_docker_webserver_post_error"&#xA;version = "0.1.0"&#xA;edition = "2021"&#xA;&#xA;# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html&#xA;&#xA;[dependencies]&#xA;warp = "0.3"&#xA;reqwest = { version = "0.12.4", features = ["json"] }&#xA;tokio = { version = "1", features = ["full"] }&#xA;log = "0.4"&#xA;env_logger = "0.11.3"&#xA;

    &#xA;

    Making the request to the warp server

    &#xA;

    curl -v "http://localhost:3030"&#xA;

    &#xA;

  • Why codecs x264/x265 ignores pts and dts of input frame ?

    1er mars 2018, par Iceman

    I’m trying to encode images from a webcam with libx265 (libx264 tried earlier) ...
    The webcam can not shoot with stable FPS because of the different amount of light entering the matrix and, as a result, different delays. Therefore, I count the fps and dts of the incoming frame and set these values for the corresponding parameters of the x265_image object, and init the encoder fpsNum with 1000 and fpsDenom with 1 (for millisecond timebase).
    The problem is that the encoder ignores pts and dts of input image and encodes at 1000 fps ! The same trick with timebase produces smooth record with libvpx. Why it does not work with x264/x265 codecs ?

    Here is parameters initialization :

    ...
       error = (x265_param_default_preset(param, "fast", "zerolatency") != 0);
       if(!error){
           param->sourceWidth = width;
           param->sourceHeight = height;
           param->frameNumThreads = 1;
           param->fpsNum = 1000;
           param->fpsDenom =  1;
           // Intra refres:
           param->keyframeMax = 15;
           param->intraRefine = 1;
           // Rate control:
           param->rc.rateControlMode = X265_RC_CQP;
           param->rc.rfConstant = 12;
           param->rc.rfConstantMax = 48;
           // For streaming:
           param->bRepeatHeaders = 1;
           param->bAnnexB = 1;
           encoder = x265_encoder_open(param);
           ...
       }
    ...

    Here is frame adding function :

    bool hevc::Push(unsigned char *data){
       if(!error){
           std::lock_guard lock(m_framestack);
           if( timer > 0){
               framestack.back()->dts = clock() - timer;
               timer+= framestack.back()->dts;
           }
           else{timer = clock();}
           x265_picture *picture = x265_picture_alloc();
           if( picture){
               x265_picture_init(param, picture);
               picture->height = param->sourceHeight;
               picture->stride[0] = param->sourceWidth;
               picture->stride[1] = picture->stride[2] = picture->stride[0] / 2;
               picture->planes[0] = new char[  luma_size];
               picture->planes[1] = new char[chroma_size];
               picture->planes[2] = new char[chroma_size];

               colorspaces::BGRtoI420(param->sourceWidth, param->sourceHeight, data, (byte*)picture->planes[0], (byte*)picture->planes[1], (byte*)picture->planes[2]);
               picture->pts = picture->dts = 0;
               framestack.emplace_back(picture);
           }
           else{error = true;}
       }
       return !error;
    }

    Global PTS is increasing right after x265_encoder_encode call :
    pts+= pic_in->dts; and sets as a pts of new image from framestack queue when it comes to encoder.

    Can the x265/x264 codecs encode at variable fps ? How to configure it if yes ?

  • How do I write audio and video to the same file using FFMPEG and C ?

    29 juin 2018, par benwiz

    I am consuming an audio file and a video file using ffmpeg in a C program. I am modifying both the audio and the video data. In working the code below I write both each of these streams to its own file. How can I write both streams to the same file ?

    #include
    #include
    #include

    // Video resolution
    #define W 1280
    #define H 720

    // Allocate a buffer to store one video frame
    unsigned char video_frame[H][W][3] = {0};

    int main()
    {
       // Audio pipes
       FILE *audio_pipein = popen("ffmpeg -i data/daft-punk.mp3 -f s16le -ac 1 -", "r");
       FILE *audio_pipeout = popen("ffmpeg -y -f s16le -ar 44100 -ac 1 -i - out/daft-punk.mp3", "w");

       // Video pipes
       FILE *video_pipein = popen("ffmpeg -i data/daft-punk.mp4 -f image2pipe -vcodec rawvideo -pix_fmt rgb24 -", "r");
       FILE *video_pipeout = popen("ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 1280x720 -r 25 -i - -f mp4 -q:v 5 -an -vcodec mpeg4 out/daft-punk.mp4", "w");

       // Audio vars
       int16_t audio_sample;
       int audio_count;
       int audio_n = 0;

       // Video vars
       int x = 0;
       int y = 0;
       int video_count = 0;

       // Read, modify, and write one audio_sample and video_frame at a time
       while (1)
       {
           // Audio
           audio_count = fread(&amp;audio_sample, 2, 1, audio_pipein); // read one 2-byte audio_sample
           if (audio_count == 1)
           {
               ++audio_n;
               audio_sample = audio_sample * sin(audio_n * 5.0 * 2 * M_PI / 44100.0);
               fwrite(&amp;audio_sample, 2, 1, audio_pipeout);
           }

           // Video
           video_count = fread(video_frame, 1, H * W * 3, video_pipein); // Read a frame from the input pipe into the buffer
           if (video_count == H * W * 3)                                 // Only modify and write if frame exists
           {
               for (y = 0; y &lt; H; ++y)     // Process this frame
                   for (x = 0; x &lt; W; ++x) // Invert each colour component in every pixel
                   {
                       video_frame[y][x][0] = 255 - video_frame[y][x][0]; // red
                       video_frame[y][x][1] = 255 - video_frame[y][x][1]; // green
                       video_frame[y][x][2] = 255 - video_frame[y][x][2]; // blue
                   }
               fwrite(video_frame, 1, H * W * 3, video_pipeout); // Write this frame to the output pipe
           }

           // Break if both complete
           if (audio_count != 1 &amp;&amp; video_count != H * W * 3)
               break;
       }

       // Close audio pipes
       pclose(audio_pipein);
       pclose(audio_pipeout);

       // Close video pipes
       fflush(video_pipein);
       fflush(video_pipeout);
       pclose(video_pipein);
       pclose(video_pipeout);

       return 0;
    }

    I took the base for this code from this article.

    Thanks !