草庐IT

FFmpeg报错:Specified pixel format yuvj420p is invalid or not supported(用ffmpeg程序查看编码器支持像素格式命令)

Dontla 2023-10-06 原文

文章目录

原因

这是因为我们把海康rtsp视频流packet解封装后,它frame的像素格式是yuvj420p(AV_PIX_FMT_YUVJ420P)的,然后我们又指定编码器上下文的像素格式pix_fmt = AV_PIX_FMT_YUVJ420P,指定编码器为AV_CODEC_ID_MPEG4,但是AV_CODEC_ID_MPEG4不支持AV_PIX_FMT_YUVJ420P像素格式,所以报了上述错误

解决办法

ffmpeg -h encoder=mpeg4指令查看编码器支持哪些像素格式

发现:
x264编码器支持yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p nv12 nv16 nv21 yuv420p10le yuv422p10le yuv444p10le nv20le gray gray10le
x265编码器支持yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p gbrp yuv420p10le yuv422p10le yuv444p10le gbrp10le yuv420p12le yuv422p12le yuv444p12le gbrp12le gray gray10le gray12le
mpeg4编码器支持yuv420p

那么解决方法只能是
①将yuvj420p的frame转换成yuv420p的frame,再输入给mpeg4编码器(我不知道ffmpeg有没这个功能。。。)
②换个编码器,比如x264或x265,它们都支持解析yuvj420p,同时能将输出packet的像素格式转换成其他的类型,比如yuv420p

C:\Users\Arnold\source\repos\20221114_ffmpeg_compile_test2\video>ffmpeg -h encoder=libx264
ffmpeg version n4.3.2-162-g4bbcaf7559 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Encoder libx264 [libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    General capabilities: delay threads
    Threading capabilities: auto
    Supported pixel formats: yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p nv12 nv16 nv21 yuv420p10le yuv422p10le yuv444p10le nv20le gray gray10le
libx264 AVOptions:
  -preset            <string>     E..V...... Set the encoding preset (cf. x264 --fullhelp) (default "medium")
  -tune              <string>     E..V...... Tune the encoding params (cf. x264 --fullhelp)
  -profile           <string>     E..V...... Set profile restrictions (cf. x264 --fullhelp)
  -fastfirstpass     <boolean>    E..V...... Use fast settings when encoding first pass (default true)
  -level             <string>     E..V...... Specify level (as defined by Annex A)
  -passlogfile       <string>     E..V...... Filename for 2 pass stats
  -wpredp            <string>     E..V...... Weighted prediction for P-frames
  -a53cc             <boolean>    E..V...... Use A53 Closed Captions (if available) (default true)
  -x264opts          <string>     E..V...... x264 options
  -crf               <float>      E..V...... Select the quality for constant quality mode (from -1 to FLT_MAX) (default -1)
  -crf_max           <float>      E..V...... In CRF mode, prevents VBV from lowering quality beyond this point. (from -1 to FLT_MAX) (default -1)
  -qp                <int>        E..V...... Constant quantization parameter rate control method (from -1 to INT_MAX) (default -1)
  -aq-mode           <int>        E..V...... AQ method (from -1 to INT_MAX) (default -1)
     none            0            E..V......
     variance        1            E..V...... Variance AQ (complexity mask)
     autovariance    2            E..V...... Auto-variance AQ
     autovariance-biased 3            E..V...... Auto-variance AQ with bias to dark scenes
  -aq-strength       <float>      E..V...... AQ strength. Reduces blocking and blurring in flat and textured areas. (from -1 to FLT_MAX) (default -1)
  -psy               <boolean>    E..V...... Use psychovisual optimizations. (default auto)
  -psy-rd            <string>     E..V...... Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.
  -rc-lookahead      <int>        E..V...... Number of frames to look ahead for frametype and ratecontrol (from -1 to INT_MAX) (default -1)
  -weightb           <boolean>    E..V...... Weighted prediction for B-frames. (default auto)
  -weightp           <int>        E..V...... Weighted prediction analysis method. (from -1 to INT_MAX) (default -1)
     none            0            E..V......
     simple          1            E..V......
     smart           2            E..V......
  -ssim              <boolean>    E..V...... Calculate and print SSIM stats. (default auto)
  -intra-refresh     <boolean>    E..V...... Use Periodic Intra Refresh instead of IDR frames. (default auto)
  -bluray-compat     <boolean>    E..V...... Bluray compatibility workarounds. (default auto)
  -b-bias            <int>        E..V...... Influences how often B-frames are used (from INT_MIN to INT_MAX) (default INT_MIN)
  -b-pyramid         <int>        E..V...... Keep some B-frames as references. (from -1 to INT_MAX) (default -1)
     none            0            E..V......
     strict          1            E..V...... Strictly hierarchical pyramid
     normal          2            E..V...... Non-strict (not Blu-ray compatible)
  -mixed-refs        <boolean>    E..V...... One reference per partition, as opposed to one reference per macroblock (default auto)
  -8x8dct            <boolean>    E..V...... High profile 8x8 transform. (default auto)
  -fast-pskip        <boolean>    E..V...... (default auto)
  -aud               <boolean>    E..V...... Use access unit delimiters. (default auto)
  -mbtree            <boolean>    E..V...... Use macroblock tree ratecontrol. (default auto)
  -deblock           <string>     E..V...... Loop filter parameters, in <alpha:beta> form.
  -cplxblur          <float>      E..V...... Reduce fluctuations in QP (before curve compression) (from -1 to FLT_MAX) (default -1)
  -partitions        <string>     E..V...... A comma-separated list of partitions to consider. Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all
  -direct-pred       <int>        E..V...... Direct MV prediction mode (from -1 to INT_MAX) (default -1)
     none            0            E..V......
     spatial         1            E..V......
     temporal        2            E..V......
     auto            3            E..V......
  -slice-max-size    <int>        E..V...... Limit the size of each slice in bytes (from -1 to INT_MAX) (default -1)
  -stats             <string>     E..V...... Filename for 2 pass stats
  -nal-hrd           <int>        E..V...... Signal HRD information (requires vbv-bufsize; cbr not allowed in .mp4) (from -1 to INT_MAX) (default -1)
     none            0            E..V......
     vbr             1            E..V......
     cbr             2            E..V......
  -avcintra-class    <int>        E..V...... AVC-Intra class 50/100/200 (from -1 to 200) (default -1)
  -me_method         <int>        E..V...... Set motion estimation method (from -1 to 4) (default -1)
     dia             0            E..V......
     hex             1            E..V......
     umh             2            E..V......
     esa             3            E..V......
     tesa            4            E..V......
  -motion-est        <int>        E..V...... Set motion estimation method (from -1 to 4) (default -1)
     dia             0            E..V......
     hex             1            E..V......
     umh             2            E..V......
     esa             3            E..V......
     tesa            4            E..V......
  -forced-idr        <boolean>    E..V...... If forcing keyframes, force them as IDR frames. (default false)
  -coder             <int>        E..V...... Coder type (from -1 to 1) (default default)
     default         -1           E..V......
     cavlc           0            E..V......
     cabac           1            E..V......
     vlc             0            E..V......
     ac              1            E..V......
  -b_strategy        <int>        E..V...... Strategy to choose between I/P/B-frames (from -1 to 2) (default -1)
  -chromaoffset      <int>        E..V...... QP difference between chroma and luma (from INT_MIN to INT_MAX) (default -1)
  -sc_threshold      <int>        E..V...... Scene change threshold (from INT_MIN to INT_MAX) (default -1)
  -noise_reduction   <int>        E..V...... Noise reduction (from INT_MIN to INT_MAX) (default -1)
  -x264-params       <dictionary> E..V...... Override the x264 configuration using a :-separated list of key=value parameters


C:\Users\Arnold\source\repos\20221114_ffmpeg_compile_test2\video>ffmpeg -h encoder=libx265
ffmpeg version n4.3.2-162-g4bbcaf7559 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Encoder libx265 [libx265 H.265 / HEVC]:
    General capabilities: delay threads
    Threading capabilities: auto
    Supported pixel formats: yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p gbrp yuv420p10le yuv422p10le yuv444p10le gbrp10le yuv420p12le yuv422p12le yuv444p12le gbrp12le gray gray10le gray12le
libx265 AVOptions:
  -crf               <float>      E..V...... set the x265 crf (from -1 to FLT_MAX) (default -1)
  -qp                <int>        E..V...... set the x265 qp (from -1 to INT_MAX) (default -1)
  -forced-idr        <boolean>    E..V...... if forcing keyframes, force them as IDR frames (default false)
  -preset            <string>     E..V...... set the x265 preset
  -tune              <string>     E..V...... set the x265 tune parameter
  -profile           <string>     E..V...... set the x265 profile
  -x265-params       <dictionary> E..V...... set the x265 configuration using a :-separated list of key=value parameters


C:\Users\Arnold\source\repos\20221114_ffmpeg_compile_test2\video>
C:\Users\Arnold\source\repos\20221114_ffmpeg_compile_test2\video>ffmpeg -h encoder=mpeg4
ffmpeg version n4.3.2-162-g4bbcaf7559 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Encoder mpeg4 [MPEG-4 part 2]:
    General capabilities: delay threads
    Threading capabilities: slice
    Supported pixel formats: yuv420p
MPEG4 encoder AVOptions:
  -data_partitioning <boolean>    E..V...... Use data partitioning. (default false)
  -alternate_scan    <boolean>    E..V...... Enable alternate scantable. (default false)
  -mpv_flags         <flags>      E..V...... Flags common for all mpegvideo-based encoders. (default 0)
     skip_rd                      E..V...... RD optimal MB level residual skipping
     strict_gop                   E..V...... Strictly enforce gop size
     qp_rd                        E..V...... Use rate distortion optimization for qp selection
     cbp_rd                       E..V...... use rate distortion optimization for CBP
     naq                          E..V...... normalize adaptive quantization
     mv0                          E..V...... always try a mb with mv=<0,0>
  -luma_elim_threshold <int>        E..V...... single coefficient elimination threshold for luminance (negative values also consider dc coefficient) (from INT_MIN to INT_MAX) (default 0)
  -chroma_elim_threshold <int>        E..V...... single coefficient elimination threshold for chrominance (negative values also consider dc coefficient) (from INT_MIN to INT_MAX) (default 0)
  -quantizer_noise_shaping <int>        E..V...... (from 0 to INT_MAX) (default 0)
  -error_rate        <int>        E..V...... Simulate errors in the bitstream to test error concealment. (from 0 to INT_MAX) (default 0)
  -qsquish           <float>      E..V...... how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function) (from 0 to 99) (default 0)
  -rc_qmod_amp       <float>      E..V...... experimental quantizer modulation (from -FLT_MAX to FLT_MAX) (default 0)
  -rc_qmod_freq      <int>        E..V...... experimental quantizer modulation (from INT_MIN to INT_MAX) (default 0)
  -rc_eq             <string>     E..V...... Set rate control equation. When computing the expression, besides the standard functions defined in the section 'Expression Evaluation', the following functions are available: bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.
  -rc_init_cplx      <float>      E..V...... initial complexity for 1-pass encoding (from -FLT_MAX to FLT_MAX) (default 0)
  -rc_buf_aggressivity <float>      E..V...... currently useless (from -FLT_MAX to FLT_MAX) (default 1)
  -border_mask       <float>      E..V...... increase the quantizer for macroblocks close to borders (from -FLT_MAX to FLT_MAX) (default 0)
  -lmin              <int>        E..V...... minimum Lagrange factor (VBR) (from 0 to INT_MAX) (default 236)
  -lmax              <int>        E..V...... maximum Lagrange factor (VBR) (from 0 to INT_MAX) (default 3658)
  -ibias             <int>        E..V...... intra quant bias (from INT_MIN to INT_MAX) (default 999999)
  -pbias             <int>        E..V...... inter quant bias (from INT_MIN to INT_MAX) (default 999999)
  -rc_strategy       <int>        E..V...... ratecontrol method (from 0 to 1) (default ffmpeg)
     ffmpeg          0            E..V...... deprecated, does nothing
     xvid            0            E..V...... deprecated, does nothing
  -motion_est        <int>        E..V...... motion estimation algorithm (from 0 to 2) (default epzs)
     zero            0            E..V......
     epzs            1            E..V......
     xone            2            E..V......
  -force_duplicated_matrix <boolean>    E..V...... Always write luma and chroma matrix for mjpeg, useful for rtp streaming. (default false)
  -b_strategy        <int>        E..V...... Strategy to choose between I/P/B-frames (from 0 to 2) (default 0)
  -b_sensitivity     <int>        E..V...... Adjust sensitivity of b_frame_strategy 1 (from 1 to INT_MAX) (default 40)
  -brd_scale         <int>        E..V...... Downscale frames for dynamic B-frame decision (from 0 to 3) (default 0)
  -skip_threshold    <int>        E..V...... Frame skip threshold (from INT_MIN to INT_MAX) (default 0)
  -skip_factor       <int>        E..V...... Frame skip factor (from INT_MIN to INT_MAX) (default 0)
  -skip_exp          <int>        E..V...... Frame skip exponent (from INT_MIN to INT_MAX) (default 0)
  -skip_cmp          <int>        E..V...... Frame skip compare function (from INT_MIN to INT_MAX) (default dctmax)
     sad             0            E..V...... Sum of absolute differences, fast
     sse             1            E..V...... Sum of squared errors
     satd            2            E..V...... Sum of absolute Hadamard transformed differences
     dct             3            E..V...... Sum of absolute DCT transformed differences
     psnr            4            E..V...... Sum of squared quantization errors, low quality
     bit             5            E..V...... Number of bits needed for the block
     rd              6            E..V...... Rate distortion optimal, slow
     zero            7            E..V...... Zero
     vsad            8            E..V...... Sum of absolute vertical differences
     vsse            9            E..V...... Sum of squared vertical differences
     nsse            10           E..V...... Noise preserving sum of squared differences
     dct264          14           E..V......
     dctmax          13           E..V......
     chroma          256          E..V......
     msad            15           E..V...... Sum of absolute differences, median predicted
  -sc_threshold      <int>        E..V...... Scene change threshold (from INT_MIN to INT_MAX) (default 0)
  -noise_reduction   <int>        E..V...... Noise reduction (from INT_MIN to INT_MAX) (default 0)
  -mpeg_quant        <int>        E..V...... Use MPEG quantizers instead of H.263 (from 0 to 1) (default 0)
  -ps                <int>        E..V...... RTP payload size in bytes (from INT_MIN to INT_MAX) (default 0)
  -mepc              <int>        E..V...... Motion estimation bitrate penalty compensation (1.0 = 256) (from INT_MIN to INT_MAX) (default 256)
  -mepre             <int>        E..V...... pre motion estimation (from INT_MIN to INT_MAX) (default 0)
  -intra_penalty     <int>        E..V...... Penalty for intra blocks in block decision (from 0 to 1.07374e+09) (default 0)
  -a53cc             <boolean>    E..V...... Use A53 Closed Captions (if available) (default true)


C:\Users\Arnold\source\repos\20221114_ffmpeg_compile_test2\video>

参考文章:关于ffmpeg必须知道的

20221125:注意,支持的像素格式要具体查看你的ffmpeg!

我在我们英伟达8核盒子上查看

x264编码:

ffmpeg -h encoder=h264

有关FFmpeg报错:Specified pixel format yuvj420p is invalid or not supported(用ffmpeg程序查看编码器支持像素格式命令)的更多相关文章

  1. ruby - 在 Ruby 中编写命令行实用程序 - 2

    我想用ruby​​编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序

  2. ruby-on-rails - 如何在 Rails Controller Action 上触发 Facebook 像素 - 2

    我有一个ruby​​onrails应用程序。我按照facebook的说明添加了一个像素。但是,要跟踪转化,Facebook要求您将页面置于达到预期结果时出现的转化中。即,如果我想显示客户已注册,我会将您注册后转到的页面作为成功对象进行跟踪。我的问题是,当客户注册时,在我的应用程序中没有登陆页面。该应用程序将用户带回主页。它在主页上显示了一条消息,所以我想看看是否有一种方法可以跟踪来自Controller操作而不是实际页面的转化。我需要计数的Action没有页面,它们是ControllerAction。是否有任何人都知道的关于如何执行此操作的gem、文档或最佳实践?这是进入布局文件的像素

  3. ruby-on-rails - rbenv:从 RVM 移动到 rbenv 后,在 Jenkins 执行 shell 中找不到命令 - 2

    我从Ubuntu服务器上的RVM转移到rbenv。当我使用RVM时,使用bundle没有问题。转移到rbenv后,我在Jenkins的执行shell中收到“找不到命令”错误。我内爆并删除了RVM,并从~/.bashrc'中删除了所有与RVM相关的行。使用后我仍然收到此错误:rvmimploderm~/.rvm-rfrm~/.rvmrcgeminstallbundlerecho'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrcecho'eval"$(rbenvinit-)"'>>~/.bashrc.~/.bashrcrbenvversions

  4. 深度学习部署:Windows安装pycocotools报错解决方法 - 2

    深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal

  5. python ffmpeg 使用 pyav 转换 一组图像 到 视频 - 2

    2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p

  6. ruby - 无法在 Ruby 中将 ffmpeg 作为子进程运行 - 2

    我正在尝试使用以下代码通过将ffmpeg实用程序作为子进程运行并获取其输出并解析它来确定视频分辨率:IO.popen'ffmpeg-i'+path_to_filedo|ffmpegIO|#myparsegoeshereend...但是ffmpeg输出仍然连接到标准输出并且ffmepgIO.readlines是空的。ffmpeg实用程序是否需要一些特殊处理?或者还有其他方法可以获得ffmpeg输出吗?我在WinXP和FedoraLinux下测试了这段代码-结果是一样的。 最佳答案 要跟进mouviciel的评论,您需要使用类似pope

  7. ruby - 从 Ruby : capturing the output while displaying the output? 运行 shell 命令 - 2

    我有一个问题。我想从另一个ruby​​脚本运行一个ruby​​脚本并捕获它的输出信息,同时让它也输出到屏幕。亚军#!/usr/bin/envrubyprint"Enteryourpassword:"password=gets.chompputs"Hereisyourpassword:#{password}"我运行的脚本文件:开始.rboutput=`runner`putsoutput.match(/Hereisyour(password:.*)/).captures[0].to_s正如您在此处看到的那样,存在问题。在start.rb的第一行,屏幕是空的。我在运行程序中看不到“输入您的密

  8. ruby - 是否有将图像文件转换为 ASCII 艺术的命令行程序或库? - 2

    有这样的事吗?我想在Ruby程序中使用它。 最佳答案 试试这个http://csl.sublevel3.org/jp2a/此外,Imagemagick可能还有一些东西 关于ruby-是否有将图像文件转换为ASCII艺术的命令行程序或库?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6510445/

  9. ruby - 在 Ruby 的 if 语句中检查 bash 命令 - 2

    如何在Ruby的if语句中检查bash命令的返回值(true/false)。我想要这样的东西,if("/usr/bin/fswscell>/dev/null2>&1")has_afs="true"elsehas_afs="false"end它会提示以下错误含义,它总是返回true。(irb):5:warning:stringliteralincondition正确的语法是什么?更新:/usr/bin/fswscell寻找afs安装和运行状态。它会抛出这样的字符串,Thisworkstationbelongstocell如果afs没有运行,命令以状态1退出 最

  10. ruby - 可以正常中断的来自 Rake 的长时间运行的 shell 命令? - 2

    在几个项目中,我希望有一个类似rakeserver的rake任务,它将通过任何需要的方式开始为该应用程序提供服务。这是一个示例:task:serverdo%x{bundleexecrackup-p1234}end这行得通,但是当我准备停止它时,按Ctrl+c并没有正常关闭;它中断了Rake任务本身,它说rakeaborted!并给出堆栈跟踪。在某些情况下,我必须执行Ctrl+c两次。我可能可以用Signal.trap写一些东西来更优雅地中断它。有没有更简单的方法? 最佳答案 trap('SIGINT'){puts"Yourmessa

随机推荐