Recherche avancée

Médias (1)

Mot : - Tags -/publier

Sur d’autres sites (346)

  • ffmpeg with libopenh264 to get profile high422

    24 juillet 2023, par Андрей Тернити

    I have raw MJPEG video file. 3840x2160, 25fps, YUYV 4:2:2. I want use ffmpeg with encoder libopenh264. Why I can't use profile high422 ?

    


    ffmpeg -framerate 25 -i inFile.yuvj422p -profile:v high422 -c:v libopenh264 -q 2 -b 2500000 -allow_skip_frames 1 -maxrate 3500000 outFile.mkv


    


    Log

    


    ...
[libopenh264enc @ 0x56077580ed80] [Eval @ 0x7ffe78457230] Undefined constant or missing '(' in 'high422'


    


    Let's know encoder's capability

    


    # ffmpeg -h encoder=libopenh264&#xA;Encoder libopenh264 [OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:&#xA;    General capabilities: threads &#xA;    Threading capabilities: other&#xA;    Supported pixel formats: yuv420p&#xA;libopenh264enc AVOptions:&#xA;  -slice_mode        <int>        E..V......P set slice mode, use slices/max_nal_size (from 0 to 4) (default fixed)&#xA;     fixed           1            E..V....... a fixed number of slices&#xA;     dyn             3            E..V....... Size limited (compatibility name)&#xA;     sizelimited     3            E..V....... Size limited&#xA;  -loopfilter        <int>        E..V....... enable loop filter (from 0 to 1) (default 1)&#xA;  -profile           <int>        E..V....... set profile restrictions (from -99 to 65535) (default -99)&#xA;     constrained_baseline 578          E..V.......&#xA;     main            77           E..V.......&#xA;     high            100          E..V.......&#xA;  -max_nal_size      <int>        E..V....... set maximum NAL size in bytes (from 0 to INT_MAX) (default 0)&#xA;  -allow_skip_frames <boolean>    E..V....... allow skipping frames to hit the target bitrate (default false)&#xA;  -cabac             <int>        E..V......P Enable cabac(deprecated, use coder) (from 0 to 1) (default 0)&#xA;  -coder             <int>        E..V....... Coder type (from -1 to 1) (default default)&#xA;     default         -1           E..V.......&#xA;     cavlc           0            E..V.......&#xA;     cabac           1            E..V.......&#xA;     vlc             0            E..V.......&#xA;     ac              1            E..V.......&#xA;  -rc_mode           <int>        E..V....... Select rate control mode (from -1 to 3) (default quality)&#xA;     off             -1           E..V....... bit rate control off&#xA;     quality         0            E..V....... quality mode&#xA;     bitrate         1            E..V....... bitrate mode&#xA;     buffer          2            E..V....... using buffer status to adjust the video quality (no bitrate control)&#xA;     timestamp       3            E..V....... bit rate control based on timestamp&#xA;</int></int></int></boolean></int></int></int></int>

    &#xA;

    Looks like there is no high422 profile in libopenh264. But I can find&#xA;PRO_HIGH422 in several places of source code...

    &#xA;

    ffmpeg version

    &#xA;

    # ffmpeg -v&#xA;ffmpeg version N-111611-g5b11ee9429 Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)&#xA;  configuration: --prefix=/home/a/Downloads/myGitHub/FFmpeg_fixing/ffmpeg_openh264/ffmpeg_build/ --pkg-config-flags=--static --extra-cflags=-I/home/a/Downloads/myGitHub/FFmpeg_fixing/ffmpeg_openh264/ffmpeg_build/include --extra-ldflags=-L/home/a/Downloads/myGitHub/FFmpeg_fixing/ffmpeg_openh264/ffmpeg_build/lib --extra-libs=&#x27;-lpthread -lm&#x27; --ld=g&#x2B;&#x2B; --bindir=/home/a/bin --enable-gpl --enable-libopenh264&#xA;

    &#xA;

    Why I can't use profile high422 ?

    &#xA;

  • How to use ffmpeg on a stream input to extract frames

    21 juillet 2023, par Deepak Sharma

    I have tried piping the stream to a ffmpeg process for extracting the frames. It does process the small files and able to extract the frames successfully but for most of the files it throws error. The reference of the code I have used from this link- https://mathewsachin.github.io/blog/2017/07/28/ffmpeg-pipe-csharp.html&#xA;When I am running the below code

    &#xA;

    `

    &#xA;

        public static void RunFfmpeg()&#xA;    {&#xA;        &#xA;        //-framerate 20 -f rawvideo -pix_fmt rgb32 -video_size 1920x1080&#xA;        var inputArgs = "-i -";&#xA;        var outputArgs = "-ss 00:00 -t 20 -vf fps=5  $filename%03d.bmp";&#xA;&#xA;        var process = new Process&#xA;        {&#xA;            StartInfo =&#xA;            {&#xA;                FileName = "ffmpeg",&#xA;                Arguments = $"{inputArgs} {outputArgs}",&#xA;                UseShellExecute = false,&#xA;                //CreateNoWindow = true,&#xA;                RedirectStandardInput = true,&#xA;                RedirectStandardOutput = true,&#xA;                WorkingDirectory = @"d:\ffmpegout"&#xA;            }&#xA;        };&#xA;&#xA;        process.Start();&#xA;&#xA;        var ffmpegIn = process.StandardInput.BaseStream;&#xA;&#xA;        using (Stream contents = File.OpenRead("C:\\Desktop\\Videos\\B.mp4"))&#xA;        {&#xA;            contents.CopyTo(ffmpegIn);&#xA;        }&#xA;&#xA;        // After you are done&#xA;        ffmpegIn.Flush();&#xA;        ffmpegIn.Close();&#xA;&#xA;        // Make sure ffmpeg has finished the work&#xA;        process.WaitForExit();&#xA;    }`&#xA;

    &#xA;

    I am getting the below error

    &#xA;

    ffmpeg version 2023-07-16-git-c541ecf0dc-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers&#xA;built with gcc 12.2.0 (Rev10, Built by MSYS2 project)&#xA;configuration : —enable-gpl —enable-version3 —enable-static —disable-w32threads —disable-autodetect —enable-fontconfig —enable-iconv —enable-gnutls —enable-libxml2 —enable-gmp —enable-bzlib —enable-lzma —enable-libsnappy —enable-zlib —enable-librist —enable-libsrt —enable-libssh —enable-libzmq —enable-avisynth —enable-libbluray —enable-libcaca —enable-sdl2 —enable-libaribb24 —enable-libaribcaption —enable-libdav1d —enable-libdavs2 —enable-libuavs3d —enable-libzvbi —enable-librav1e —enable-libsvtav1 —enable-libwebp —enable-libx264 —enable-libx265 —enable-libxavs2 —enable-libxvid —enable-libaom —enable-libjxl —enable-libopenjpeg —enable-libvpx —enable-mediafoundation —enable-libass —enable-frei0r —enable-libfreetype —enable-libfribidi —enable-libharfbuzz —enable-liblensfun —enable-libvidstab —enable-libvmaf —enable-libzimg —enable-amf —enable-cuda-llvm —enable-cuvid —enable-ffnvcodec —enable-nvdec —enable-nvenc —enable-d3d11va —enable-dxva2 —enable-libvpl —enable-libshaderc —enable-vulkan —enable-libplacebo —enable-opencl —enable-libcdio —enable-libgme —enable-libmodplug —enable-libopenmpt —enable-libopencore-amrwb —enable-libmp3lame —enable-libshine —enable-libtheora —enable-libtwolame —enable-libvo-amrwbenc —enable-libcodec2 —enable-libilbc —enable-libgsm —enable-libopencore-amrnb —enable-libopus —enable-libspeex —enable-libvorbis —enable-ladspa —enable-libbs2b —enable-libflite —enable-libmysofa —enable-librubberband —enable-libsoxr —enable-chromaprint&#xA;libavutil 58. 14.100 / 58. 14.100&#xA;libavcodec 60. 22.100 / 60. 22.100&#xA;libavformat 60. 10.100 / 60. 10.100&#xA;libavdevice 60. 2.101 / 60. 2.101&#xA;libavfilter 9. 8.102 / 9. 8.102&#xA;libswscale 7. 3.100 / 7. 3.100&#xA;libswresample 4. 11.100 / 4. 11.100&#xA;libpostproc 57. 2.100 / 57. 2.100&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 00000266a80179c0] Could not find codec parameters for stream 0 (Video : h264 (avc1 / 0x31637661), none(tv, bt709), 1280x720, 4023 kb/s) : unspecified pixel format&#xA;Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fd :' :&#xA;Metadata :&#xA;major_brand : isom&#xA;minor_version : 512&#xA;compatible_brands : isomiso2avc1mp41&#xA;encoder : Lavf58.76.100&#xA;Duration : 00:00:21.22, start : 0.000000, bitrate : N/A&#xA;Stream #0:00x1 : Video : h264 (avc1 / 0x31637661), none(tv, bt709), 1280x720, 4023 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k tbn (default)&#xA;Metadata :&#xA;handler_name : VideoHandler&#xA;vendor_id : [0][0][0][0]&#xA;Stream mapping :&#xA;Stream #0:0 -> #0:0 (h264 (native) -> bmp (native))&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 00000266a80179c0] stream 0, offset 0xbb3a : partial file&#xA;Cannot determine format of input stream 0:0 after EOF&#xA;Error marking filters as finished&#xA;Conversion failed !

    &#xA;

    I did check the metadata of the video is present in the start of the file before the mdat box.

    &#xA;

    Looking to get some help to resolve this issue.

    &#xA;

  • Flutter ffmpeg kit : Invalid size error when trying to scale video

    27 juillet 2023, par veryepicdude

    I'm trying to resize a video to match instagram's video format requirements. I'm using the ffmpeg_kit_flutter_full_gpl: ^5.1.0 package to do so and this is the function I'm calling :

    &#xA;

    Future<void> resizeVideo(String input, String output) async {&#xA;&#xA;  final command = &#x27;-i $input -c:v libx264 -aspect 16:9 -crf 18 -vf "scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2" -fpsmax 60 -preset ultrafast -c:a aac -b:a 128k -ac 1 -use_editlist false -ar 48000 -pix_fmt yuv420p -movflags &#x2B;faststart -t 59 -y $output&#x27;;&#xA;  final session = await FFmpegKit.execute(command);&#xA;  print("resize done with ${await session.getReturnCode()}");&#xA;}&#xA;</void>

    &#xA;

    However I get this error every time :

    &#xA;

     Stream #0:0[0x1](und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 60 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-07-27T15:30:28.000000Z&#xA;      handler_name    : Core Media Audio&#xA;      vendor_id       : [0][0][0][0]&#xA;  Stream #0:1[0x2](und): Video: hevc (hvc1 / 0x31637668), yuv420p(tv, smpte170m/bt709/bt709), 720x1280, 2085 kb/s, 30 fps, 30 tbr, 600 tbn (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-07-27T15:30:28.000000Z&#xA;      handler_name    : Core Media Video&#xA;      vendor_id       : [0][0][0][0]&#xA;Stream mapping:&#xA;  Stream #0:1 -> #0:0 (hevc (native) -> h264 (libx264))&#xA;  Stream #0:0 -> #0:1 (aac (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;[Parsed_scale_0 @ 0x2834a53f0] Invalid size &#x27;iw*min(1280/iw&#x27;&#xA;[AVFilterGraph @ 0x28278e3a0] Error initializing filter &#x27;scale&#x27;[AVFilterGraph @ 0x28278e3a0]  with args &#x27;iw*min(1280/iw&#x27;[AVFilterGraph @ 0x28278e3a0] &#xA;Error reinitializing filters!&#xA;Failed to inject frame into filter network: Invalid argument&#xA;Error while processing the decoded data for stream #0:1&#xA;[aac @ 0x105334290] Qavg: 461.613&#xA;[aac @ 0x105334290] 2 frames left in the queue on closing&#xA;

    &#xA;

    Removing the scale filter makes the function work fine, but it fails the instagram video requirements listed here.&#xA;Any help will be greatly appreciated.

    &#xA;