当前位置: 首页 > 知识库问答 >
问题:

用ffmpeg录制时错误的视频持续时间

卫弘义
2023-03-14

我正在尝试用FFMPEG录制一段H264视频。

以下是我在FFMPEG中使用的选项:

-thread_queue_size 512-framerate 30-f rawvideo-pix_fmt rgb32-video_size 1920x1080-i\.\pipe\pipe_name-vcodec libx264-crf 23-pix_fmt yuv420p-preset超快-r 30“output.mp4”

以下是FFmpeg日志

2018-10-04 15:56:11.9342 | INFO  | ffmpeg version N-91715-gd71dfc087b Copyright (c) 2000-2018 the FFmpeg developers 
2018-10-04 15:56:11.9402 | INFO  |   built with gcc 8.2.1 (GCC) 20180813 
2018-10-04 15:56:11.9402 | INFO  |   configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth 
2018-10-04 15:56:11.9402 | INFO  |   libavutil      56. 19.100 / 56. 19.100 
2018-10-04 15:56:11.9542 | INFO  |   libavcodec     58. 27.100 / 58. 27.100 
2018-10-04 15:56:11.9542 | INFO  |   libavformat    58. 17.103 / 58. 17.103 
2018-10-04 15:56:11.9728 | INFO  |   libavdevice    58.  4.101 / 58.  4.101 
2018-10-04 15:56:11.9728 | INFO  |   libavfilter     7. 26.100 /  7. 26.100 
2018-10-04 15:56:11.9999 | INFO  |   libswscale      5.  2.100 /  5.  2.100 
2018-10-04 15:56:12.0239 | INFO  |   libswresample   3.  2.100 /  3.  2.100 
2018-10-04 15:56:12.0239 | INFO  |   libpostproc    55.  2.100 / 55.  2.100 
2018-10-04 15:56:12.0350 | INFO  | Input #0, rawvideo, from '\\.\pipe\pipe_name': 
2018-10-04 15:56:12.0350 | INFO  |   Duration: N/A, start: 0.000000, bitrate: 1990656 kb/s 
2018-10-04 15:56:12.0350 | INFO  |     Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1920x1080, 1990656 kb/s, 30 tbr, 30 tbn, 30 tbc 
2018-10-04 15:56:12.0481 | INFO  | Stream mapping: 
2018-10-04 15:56:12.0481 | INFO  |   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) 
2018-10-04 15:56:12.0691 | INFO  | Press [q] to stop, [?] for help 
2018-10-04 15:56:12.0881 | INFO  | [libx264 @ 000001bceea618c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 
2018-10-04 15:56:12.0881 | INFO  | [libx264 @ 000001bceea618c0] profile Constrained Baseline, level 4.0, 4:2:0, 8-bit 
2018-10-04 15:56:12.0951 | INFO  | [libx264 @ 000001bceea618c0] 264 - core 157 r2932 303c484 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=30.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0 
2018-10-04 15:56:12.0951 | INFO  | Output #0, mp4, to 'output.mp4': 
2018-10-04 15:56:12.0951 | INFO  |   Metadata: 
2018-10-04 15:56:12.0951 | INFO  |     encoder         : Lavf58.17.103 
2018-10-04 15:56:12.0951 | INFO  |     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 30 fps, 15360 tbn, 30 tbc 
2018-10-04 15:56:12.1171 | INFO  |     Metadata: 
2018-10-04 15:56:12.1171 | INFO  |       encoder         : Lavc58.27.100 libx264 
2018-10-04 15:56:12.1531 | INFO  |     Side data: 
2018-10-04 15:56:12.1691 | INFO  |       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 
2018-10-04 15:56:12.8750 | INFO  | frame=    8 fps=0.0 q=31.0 size=       0kB time=00:00:00.00 bitrate=5907.7kbits/s speed=0.000121x     
2018-10-04 15:56:13.3238 | INFO  | frame=   11 fps=9.9 q=31.0 size=       0kB time=00:00:00.10 bitrate=   3.8kbits/s speed=0.0904x     
2018-10-04 15:56:13.7782 | INFO  | frame=   16 fps=9.5 q=31.0 size=       0kB time=00:00:00.26 bitrate=   1.4kbits/s speed=0.159x     
2018-10-04 15:56:14.2346 | INFO  | frame=   21 fps=9.5 q=31.0 size=       0kB time=00:00:00.43 bitrate=   0.9kbits/s speed=0.197x     
2018-10-04 15:56:14.8011 | INFO  | frame=   27 fps=9.7 q=31.0 size=       0kB time=00:00:00.63 bitrate=   0.6kbits/s speed=0.229x     
2018-10-04 15:56:15.4266 | INFO  | frame=   33 fps=9.7 q=32.0 size=       0kB time=00:00:00.83 bitrate=   0.5kbits/s speed=0.246x     
2018-10-04 15:56:16.0827 | INFO  | frame=   39 fps=9.6 q=31.0 size=     256kB time=00:00:01.03 bitrate=2029.7kbits/s speed=0.255x     
2018-10-04 15:56:16.7291 | INFO  | frame=   47 fps= 10 q=31.0 size=     256kB time=00:00:01.30 bitrate=1613.4kbits/s speed=0.277x     
2018-10-04 15:56:17.4279 | INFO  | frame=   54 fps= 10 q=31.0 size=     256kB time=00:00:01.53 bitrate=1367.9kbits/s speed=0.284x     
2018-10-04 15:56:18.0562 | INFO  | frame=   61 fps= 10 q=31.0 size=     512kB time=00:00:01.76 bitrate=2374.3kbits/s speed=0.298x     
2018-10-04 15:56:18.5401 | INFO  | frame=   64 fps=9.9 q=31.0 size=     512kB time=00:00:01.86 bitrate=2247.1kbits/s speed=0.287x     
2018-10-04 15:56:19.2106 | INFO  | frame=   70 fps=9.9 q=32.0 size=     512kB time=00:00:02.06 bitrate=2029.6kbits/s speed=0.293x     
2018-10-04 15:56:19.6653 | INFO  | frame=   75 fps=9.9 q=31.0 size=     512kB time=00:00:02.23 bitrate=1878.2kbits/s speed=0.294x     
2018-10-04 15:56:20.1512 | INFO  | frame=   78 fps=9.6 q=31.0 size=     512kB time=00:00:02.33 bitrate=1797.7kbits/s speed=0.287x     
2018-10-04 15:56:21.0577 | INFO  | frame=   84 fps=9.3 q=31.0 size=     768kB time=00:00:02.53 bitrate=2483.6kbits/s speed=0.281x     
2018-10-04 15:56:21.6416 | INFO  | frame=   91 fps=9.5 q=31.0 size=     768kB time=00:00:02.76 bitrate=2274.1kbits/s speed=0.29x     
2018-10-04 15:56:22.1779 | INFO  | frame=   97 fps=9.6 q=31.0 size=     768kB time=00:00:02.96 bitrate=2120.8kbits/s speed=0.295x     
2018-10-04 15:56:22.6571 | INFO  | frame=  101 fps=9.5 q=-1.0 Lsize=    1015kB time=00:00:03.33 bitrate=2495.6kbits/s speed=0.313x     
2018-10-04 15:56:22.6571 | INFO  | video:1014kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.117556% 
2018-10-04 15:56:22.6571 | INFO  | [libx264 @ 000001bceea618c0] frame I:1     Avg QP:27.00  size: 60682 
2018-10-04 15:56:22.6571 | INFO  | [libx264 @ 000001bceea618c0] frame P:100   Avg QP:31.09  size:  9774 
2018-10-04 15:56:22.6571 | INFO  | [libx264 @ 000001bceea618c0] mb I  I16..4: 100.0%  0.0%  0.0% 
2018-10-04 15:56:22.6736 | INFO  | [libx264 @ 000001bceea618c0] mb P  I16..4: 10.6%  0.0%  0.0%  P16..4: 15.2%  0.0%  0.0%  0.0%  0.0%    skip:74.3% 
2018-10-04 15:56:22.6736 | INFO  | [libx264 @ 000001bceea618c0] coded y,uvDC,uvAC intra: 15.8% 24.4% 1.4% inter: 4.8% 6.8% 0.0% 
2018-10-04 15:56:22.6736 | INFO  | [libx264 @ 000001bceea618c0] i16 v,h,dc,p: 39% 20% 15% 26% 
2018-10-04 15:56:22.6736 | INFO  | [libx264 @ 000001bceea618c0] i8c dc,h,v,p: 54% 19% 20%  7% 
2018-10-04 15:56:22.6896 | INFO  | [libx264 @ 000001bceea618c0] kb/s:2466.66 

我能做什么来写10秒内展开的100帧?

我研究了一个名为-vsync的FFmpeg选项,但没有任何成功。

共有1个答案

澹台聪
2023-03-14

添加-use_wallclock_as_timestamps true作为输入选项,即在-i之前。

rawvideo输入没有固有的时间戳,因此demuxer根据framerate值生成一个平滑的序列

 类似资料:
  • 使用FFmpeg C API,我试图将输入视频转换成类似动画gif的视频,这意味着没有音频流,视频流为4/fps。 我有解码/编码部分工作。我可以从输出文件中删除音频流,但在降低fps时遇到了问题。我可以将输出视频流的time_base更改为4/fps,但它会增加视频的持续时间-基本上是以慢速模式播放。 我想我需要先删除额外的帧,然后再将它们写入输出容器。 下面是我读取输入帧,然后将它们写入输出容

  • 我有一个原始视频文件“inputvideofile.mp4” 我使用ffmpeg解码输入视频文件,处理每一帧,然后将那些帧编码为“OutputVideofile.mp4”。 $FFProbe InputVideofile.mp4 持续时间:00:00:04.08,开始时间:0.000000,生成时间:7835 KB/s $FFProbe OutputVideofile.mp4

  • 问题:是否有一个单独的FFMPEG裁剪过滤器可以用于所有视频,包括(但不限于):856x480、640x480和1280x720? 我们有一个视频处理系统(使用DirectShow),所有输入到这个系统的视频必须是16:9使用MJPEG编解码器。我们使用下面的ffmpeg命令将源视频转换为MJPEG,缩放像素使其为正方形,然后裁剪到16:9的纵横比。这对大多数输入视频都很管用,输出正是我们想要的。

  • 我有两个使用FFmpeg concat解复用器连接的输入视频: 档案。txt包含以下两个文件路径: 不幸的是,串联的视频有两个问题: 第一个输入视频的持续时间为4秒。在输出视频中,在第二个输入视频开始之前,最后一帧冻结几秒钟 我已尝试指定视频中每个视频的持续时间。由FFmpeg文档指定的txt文件,但这似乎对输出没有影响。 我对FFmpeg有点新手,所以非常感谢任何帮助! 编辑-每个输入视频的属性