Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • ffmpeg mp4 to hls transcode fails on Azure Windows Server Image [closed]

    13 février, par James Weatherhead

    I am having an issue with transcoding an mp4 (any mp4) to hls. If I run the command below on my Windows 11 machine it works fine. If I run it on a clean Windows 11 VM, it works fine. If I run it on a clean Windows 2022 Server VM it works fine. If I create a Windows 2022 server image in Azure and run it... it fails (see error below)

    I feel like something that FFMPEG needs is missing from the default server image in Azure. Has anyone experienced this issue and found a way to solve it?

    The command I am using:

    ffmpeg.exe -i LowPriVMs-1.mp4 -filter_complex "[0:v]split=1[v1]; [v1]scale=w=1920:h=1080[v1out]; " -map "[v1out]" -c:v:0 mpeg4 -b:v:0 5000k -maxrate:v:0 5350k -bufsize:v:0 7500k -map a:0 -c:a aac -b:a:0 192k -ac 2 -f hls -hls_time 10 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename stream_%v/data%03d.ts -master_pl_name master.m3u8 -var_stream_map "v:0,a:0" stream_%v/playlist.m3u8

    The error returned by FFMPEG is:

    [out#0/hls @ 00000204c6aded40] Could not write header (incorrect codec parameters ?): Invalid argument

    Has anyone else encountered this and found a solution? I wondered if it is required to add a Feature Pack or some such dependency to Windows?

    Thanks James

  • Error "Transparency encoding with auto_alt_ref does not work" when converting a .mov with Alpha to .webm with alpha with ffmpeg [closed]

    13 février, par ThomTTP

    I am trying to convert a .mov file with alpha transparency into a .webm file and have been following this thread for help: Convert mov with Alpha to VP9 Webm with Alpha Using ffmpeg

    The command line I have been using is

    ffmpeg -r 24/1 -i Desktop/Skel_Walk_1.mov -c:v libvpx -pix_fmt yuva420p Desktop/Skel_Walk_1.webm
    

    However when I go to run the command it comes up with 2 errors

    Transparency encoding with auto_alt_ref does not work
    

    and

    Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 
    - maybe incorrect parameters such as bit_rate, rate, width or height
    

    I am not too sure what the problem is here, any suggestions, I am very confused!

  • How to reinitialize AVCodec with updated AVCodecContext on fly

    13 février, par Alemao

    There is a question about an old (0.7) version of the FFMPEG(LibAV) library, including to my project as

    extern "C" {
        #include avcodec.h>
        #include avformat.h>
        #include avfilter.h>
        #include timestamp.h>
        #include pixdesc.h>
        #include opt.h>
    }
    

    I have an AVCodec object, which knows how to encode my frames(to H264 codec). I have an object of AVCodecContext type, initialized with the parameters that I need (bitrate, framerate etc.).

        AVCodec *encoderVideoCodec = nullptr;
        AVCodecContext *encoderVideoCodecContext = nullptr;
    

    Then I initialize AVCodec with its context, setting some important parameters from decoder (Before that I analyzed input RTSP stream from camera).

        encoderVideoCodecContext = avcodec_alloc_context3(encoderVideoCodec);
        if(!encoderVideoCodecContext) {
            std::cerr << "Error" << std::endl;
            return 1;
        }
    
        av_opt_set(encoderVideoCodecContext->priv_data, "preset", "fast", 0);
        if(outStreamParams.codec_priv_key && outStreamParams.codec_priv_value)
            av_opt_set(encoderVideoCodecContext->priv_data, outStreamParams.codec_priv_key, outStreamParams.codec_priv_value, 0);
    
        encoderVideoCodecContext->height = decoderVideoCodecContext->height;
        encoderVideoCodecContext->width = decoderVideoCodecContext->width;
        encoderVideoCodecContext->sample_aspect_ratio = decoderVideoCodecContext->sample_aspect_ratio;
    
        if(encoderVideoCodec->pix_fmts)
            encoderVideoCodecContext->pix_fmt = encoderVideoCodec->pix_fmts[0];
        else
            encoderVideoCodecContext->pix_fmt = decoderVideoCodecContext->pix_fmt;
    
        encoderVideoCodecContext->bit_rate = bitrate;
        encoderVideoCodecContext->rc_buffer_size = 4*1000*1000;
        encoderVideoCodecContext->rc_max_rate = 2*1000*1000;
        encoderVideoCodecContext->rc_min_rate = 2.5*1000*1000;
        encoderVideoCodecContext->time_base = av_inv_q(frameRate);
        encoderVideoStream->time_base = encoderVideoCodecContext->time_base;
    
        int ret = 0;
        ret = avcodec_open2(encoderVideoCodecContext, encoderVideoCodec, nullptr);
        if(ret < 0 ) {
            std::cerr << "Error" << std::endl;
            return 1;
        }
    
        ret = avcodec_parameters_from_context(encoderVideoStream->codecpar, encoderVideoCodecContext);
        if(ret < 0) {
            std::cerr << "Ошибка копирования параметров из контекста энкодера в энкодер " << std::endl;
            return 1;
        } else {
            std::cout << "Параметры энкодера заполнены из контекста" << std::endl;
        }
    

    Then I start the process of encoding, and everything goes well. But, for example, in the middle of this process I want to change the bitrate on the fly. I change AVCodecContext::bit_rate and then call the init() method of AVCodec to apply changes.

        encoderVideoCodecContext->bit_rate = bitrate;
        int res = -1;
        res = encoderVideoCodec->init(encoderVideoCodecContext);
    

    And the bitrate value changed. But Valgrind tells me that for this operation I have a memory leak of about 100 bytes. init() method allocates some memory that doesn't clean then. Can you, please,help me and advise the right way to do this operation. Or what memory should I clean and the allocate again to fix memory leak?

  • Converting audio/video tracks to AAC format in C# app

    13 février, par Alex1347

    I try convert audio/video tracks to AAC format using qaac lib. In CMD it works and output information about progress of convertation. In my C# app it works too, but I can't get information about progress, i try use these events: OutputDataReceived, ErrorDataReceived. In handler of ErrorDataReceived I don't get needed information, in handler of OutputDataReceived I get received.Data like null value. How can I get conversion progress information during conversion in C# code?

    (I use qaac lib because ffmpeg lib convert tracks to AAC incorrect - incorrect duration of result track, resolving not find for this problem, some analog apps have the same bug.)

    Creating process for converting:

    string arguments = $"\"{engineParameters.InputFile.Filename}\" -no-delay -o \"{engineParameters.OutputFile.Filename}\"";
    
    processStartInfo = new ProcessStartInfo
    {
        FileName = QaacFilePath,
        Arguments = arguments,
        RedirectStandardOutput = true,
        UseShellExecute = false,
        CreateNoWindow = true,
        WindowStyle = ProcessWindowStyle.Hidden
    };
    

    Also I call these methods for process:

    BeginOutputReadLine();
    BeginErrorReadLine();
    WaitForExit();
    

    Handlers:

    this.Process.OutputDataReceived += (sender, received) =>
    {
        if (received.Data == null) return;
        //Some code...
    }
    
    this.Process.ErrorDataReceived += (sender, received) =>
    {
        if (received.Data == null) return;
        //Some code...
    }
    
  • How to disable slf4j log in java

    12 février, par Model123123

    Sorry for my poor English.

    I'm using ffmpeg-cli-wrapper library in java

    [main] INFO net.bramp.ffmpeg.RunProcessFunction - .\ffprobe.exe -version

    [main] INFO net.bramp.ffmpeg.RunProcessFunction - .\ffprobe.exe -v quiet -print_format json -show_error -show_format -show_streams -show_chapters

    How to remove this log?

    try this:

    1. java.util.logging.Logger.getLogger("net.bramp.ffmpeg").setLevel(Level.OFF);

    2. /logger name="net.bramp.ffmpeg" level="OFF"/ in logback.xml

    but not work...

    RunProcessFunction src: https://github.com/bramp/ffmpeg-cli-wrapper/blob/master/src/main/java/net/bramp/ffmpeg/RunProcessFunction.java