ffmpeg como alterar a taxa de quadros de vídeo sem alterar a duração do vídeo?

0

Estou tentando codificar um vídeo com uma taxa de quadros constante diferente usando o ffmpeg. A duração do arquivo de saída é diferente do original por 0,02 segundos, que é sobre um quadro.

Como altero a taxa de quadros sem alterar a duração.

Estou usando este comando: "ffmpeg.exe -y -i work.ts -an -c: v libx264 -pix_fmt yuv420p -s 1280x720 -framérica 29.97 out.ts"

O framerate original é: 59,94 fps

Qualquer ajuda será muito apreciada: -)

Log:

ffmpeg.exe -y -i work.ts -an -c:v libx264 -pix_fmt yuv420p -s 1280x720 -framerate 29.97 out.ts

ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mpegts, from 'work.ts':
  Duration: 00:00:04.02, start: 31.405178, bitrate: 6430 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 126 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0000024c3c135a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000024c3c135a00] profile High, level 3.2
Output #0, mpegts, to 'out.ts':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720, q=-1--1, 59.94 fps, 90k tbn, 59.94 tbc
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=  240 fps= 43 q=-1.0 Lsize=    2120kB time=00:00:03.95 bitrate=4391.5kbits/s speed=0.714x
video:1940kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.278002%
[libx264 @ 0000024c3c135a00] frame I:1     Avg QP:27.60  size: 71877
[libx264 @ 0000024c3c135a00] frame P:61    Avg QP:28.06  size: 22993
[libx264 @ 0000024c3c135a00] frame B:178   Avg QP:31.75  size:  2875
[libx264 @ 0000024c3c135a00] consecutive B-frames:  0.8%  0.8%  0.0% 98.3%
[libx264 @ 0000024c3c135a00] mb I  I16..4:  5.0% 11.6% 83.5%
[libx264 @ 0000024c3c135a00] mb P  I16..4:  2.5%  3.6%  4.7%  P16..4: 43.1% 20.1% 10.1%  0.0%  0.0%    skip:15.9%
[libx264 @ 0000024c3c135a00] mb B  I16..4:  0.2%  0.1%  0.2%  B16..8: 22.6%  2.9%  0.5%  direct: 0.6%  skip:73.1%  L0:33.7% L1:59.3% BI: 6.9%
[libx264 @ 0000024c3c135a00] 8x8 transform intra:29.6% inter:65.2%
[libx264 @ 0000024c3c135a00] coded y,uvDC,uvAC intra: 68.8% 68.1% 30.0% inter: 10.8% 9.5% 0.4%
[libx264 @ 0000024c3c135a00] i16 v,h,dc,p: 10% 80%  5%  6%
[libx264 @ 0000024c3c135a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 49% 14%  4%  3%  4%  4%  5%  7%
[libx264 @ 0000024c3c135a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 55% 10%  3%  3%  4%  4%  3%  5%
[libx264 @ 0000024c3c135a00] i8c dc,h,v,p: 42% 35% 15%  7%
[libx264 @ 0000024c3c135a00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000024c3c135a00] ref P L0: 69.3% 16.2% 11.6%  2.8%
[libx264 @ 0000024c3c135a00] ref B L0: 88.4%  8.8%  2.8%
[libx264 @ 0000024c3c135a00] ref B L1: 99.4%  0.6%
[libx264 @ 0000024c3c135a00] kb/s:3968.40
ffProbe\ffprobe.exe work.ts

ffprobe version N-82117-gc117343 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 33.100 / 55. 33.100
  libavcodec     57. 63.103 / 57. 63.103
  libavformat    57. 55.100 / 57. 55.100
  libavdevice    57.  0.103 / 57.  0.103
  libavfilter     6. 64.100 /  6. 64.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mpegts, from 'work.ts':
  Duration: 00:00:04.02, start: 31.405178, bitrate: 6430 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 126 kb/s
ffProbe\ffprobe.exe out.ts

ffprobe version N-82117-gc117343 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 33.100 / 55. 33.100
  libavcodec     57. 63.103 / 57. 63.103
  libavformat    57. 55.100 / 57. 55.100
  libavdevice    57.  0.103 / 57.  0.103
  libavfilter     6. 64.100 /  6. 64.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mpegts, from 'out.ts':
  Duration: 00:00:04.00, start: 1.433367, bitrate: 4336 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    
por Tal Lempert 02.01.2018 / 10:07

1 resposta

0

Se o vídeo original tiver um número ímpar de quadros e você voltar a metade da taxa de quadros, é impossível atingir exatamente o mesmo tamanho do original. Você pode escolher entre metade de um quadro (nova taxa de quadros) mais ou menos.

Por padrão, ffmpeg escolherá a versão mais longa, mas definindo "-t ss.sss" você pode forçar a menor duração.

    
por 02.01.2018 / 10:20