Me acabo de enterar de FFmpeg y lo necesito para cortar un montón de archivos MP4 en los últimos 20 segundos de cada uno. Cada archivo MP4 tiene una pista de video y dos pistas de audio .

He estado usando esta línea de código:

for %F in (*.mp4) do ffmpeg -sseof -20 -i "%F" -map 0:v -map 0:a -c:v copy -c:a copy "%~nF_trimmed.mp4"

El recorte va bien pero hay un problema con el audio. Este error aparece sin cancelar el proceso de recorte:

[mp4 @ 0000025740443740] track 1: codec frame size is not set
[mp4 @ 0000025740443740] track 2: codec frame size is not set

Y cuando suelto los archivos recortados en un software de edición de video, esto se puede ver: https://i.imgur.com/OrhK2gV.png

La segunda pista de audio es más larga que la pista de video.

 

Tenga en cuenta que no estoy familiarizado con la codificación y solo necesito esto solo para fines de edición de video. He estado tratando de encontrar un camino, pero no tuve suerte. ¿Algunas ideas?

Si es útil, aquí está el proceso completo de la consola:

D:\User Libraries\Desktop\Test>for %F in (*.mp4) do ffmpeg -sseof -20 -i "%F" -map 0:v -map 0:a -c:v copy -c:a copy "%~nF_trimmed.mp4"

D:\User Libraries\Desktop\Test>ffmpeg -sseof -20 -i "Test1.mp4" -map 0:v -map 0:a -c:v copy -c:a copy "Test1_trimmed.mp4"
ffmpeg version N-91024-g293a6e8332 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.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-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
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.101 / 58. 19.101
  libavformat    58. 13.102 / 58. 13.102
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Test1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2018-05-05T06:59:14.000000Z
    date            : 2018
  Duration: 00:02:57.53, start: 0.000000, bitrate: 48706 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], 48332 kb/s, 59.83 fps, 59.94 tbr, 90k tbn, 120 tbc (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 171 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : SoundHandle
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : SoundHandle
Output #0, mp4, to 'Test1_trimmed.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    date            : 2018
    encoder         : Lavf58.13.102
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 48332 kb/s, 59.83 fps, 59.94 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 171 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : SoundHandle
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T06:59:14.000000Z
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame= 1211 fps=833 q=-1.0 Lsize=  124193kB time=00:00:19.98 bitrate=50911.9kbits/s speed=13.8x
video:123268kB audio:887kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.030864%

D:\User Libraries\Desktop\Test>ffmpeg -sseof -20 -i "Test2.mp4" -map 0:v -map 0:a -c:v copy -c:a copy "Test2_trimmed.mp4"
ffmpeg version N-91024-g293a6e8332 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.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-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
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.101 / 58. 19.101
  libavformat    58. 13.102 / 58. 13.102
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Test2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2018-05-05T07:02:30.000000Z
    date            : 2018
  Duration: 00:02:36.73, start: 0.000000, bitrate: 49260 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], 48916 kb/s, 58.73 fps, 59.94 tbr, 90k tbn, 120 tbc (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 139 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : SoundHandle
    Stream #0:2(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : SoundHandle
[mp4 @ 000001cf28f53740] track 1: codec frame size is not set
[mp4 @ 000001cf28f53740] track 2: codec frame size is not set
Output #0, mp4, to 'Test2_trimmed.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    date            : 2018
    encoder         : Lavf58.13.102
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 48916 kb/s, 58.73 fps, 59.94 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 139 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : SoundHandle
    Stream #0:2(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
    Metadata:
      creation_time   : 2018-05-05T07:02:30.000000Z
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame= 1225 fps=834 q=-1.0 Lsize=  125448kB time=00:00:19.98 bitrate=51429.4kbits/s speed=13.6x
video:124591kB audio:815kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.034254%
Lord Porongus
fuente