合并 audio.m3u8 和 video.m3u8 时音频不同步

合并 audio.m3u8 和 video.m3u8 时音频不同步

我有.ts 文件和清单文件。

360p/index.m3u8
480p/index.m3u8
720p/index.m3u8
audio/english/index.m3u8
playlist.m3u8

我用命令合并视频

    ffmpeg -i "720p/index.m3u8" -i "audio/english/index.m3u8" -c copy -movflags +faststart 720p.mp4

问题:当我打开 720p.mp4 时,声音与视频的时间/图片不匹配,有时匹配。使用 jwplayer/浏览器打开它们时没有问题。

有人知道这个问题吗?

这是日志:

ffmpeg -i "1080p/index.m3u8" -i "audio/english/index.m3u8"  -c copy -movflags +faststart test.mp4
ffmpeg version N-102003-g718e03e5f2 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-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-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-libsvtav1 --enable-libtwolame --enable-libuavs3d --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. 73.100 / 56. 73.100
  libavcodec     58.136.101 / 58.136.101
  libavformat    58. 78.100 / 58. 78.100
  libavdevice    58. 14.100 / 58. 14.100
  libavfilter     7.111.100 /  7.111.100
  libswscale      5. 10.100 /  5. 10.100
  libswresample   3. 10.100 /  3. 10.100
  libpostproc    55. 10.100 / 55. 10.100
[hls @ 000001c4e00e7000] Skip ('#EXT-X-VERSION:4')
[hls @ 000001c4e00e7000] Opening '1080p/media-0.ts' for reading
Input #0, hls, from '1080p/index.m3u8':
  Duration: 01:39:06.34, start: 0.066733, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
  Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Metadata:
      variant_bitrate : 0
[hls @ 000001c4e1c74ec0] Skip ('#EXT-X-VERSION:4')
[hls @ 000001c4e1c74ec0] Opening 'audio/english/media-0.ts' for reading
Input #1, hls, from 'audio/english/index.m3u8':
  Duration: 01:39:06.37, start: 0.000000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
  Stream #1:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Output #0, mp4, to 'test.mp4':
  Metadata:
    encoder         : Lavf58.78.100
  Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
    Metadata:
      variant_bitrate : 0
  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls @ 000001c4e00e7000] Opening '1080p/media-1.ts' for readingrate=N/A speed=   0x
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 177177).
[hls @ 000001c4e00e7000] Opening '1080p/media-2.ts' for reading
[hls @ 000001c4e00e7000] Opening '1080p/media-3.ts' for reading
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 717717).
[hls @ 000001c4e1c74ec0] Opening 'audio/english/media-1.ts' for reading
[hls @ 000001c4e00e7000] Opening '1080p/media-4.ts' for reading
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 1078077).
[hls @ 000001c4e00e7000] Opening '1080p/media-5.ts' for reading
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 1798797).
[hls @ 000001c4e1c74ec0] Opening 'audio/english/media-2.ts' for reading
[hls @ 000001c4e00e7000] Opening '1080p/media-6.ts' for reading
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 2699697).
[mp4 @ 000001c4e23ccd00] Non-monotonous DTS in output stream 0:0; previous: 2693691, current: 2689937; changing to 2693692. This may result in incorrect timestamps in the output file.
[mp4 @ 000001c4e23ccd00] Non-monotonous DTS in output stream 0:0; previous: 2693692, current: 2692940; changing to 2693693. This may result in incorrect timestamps in the output file.
[hls @ 000001c4e1c74ec0] Opening 'audio/english/media-3.ts' for reading
[hls @ 000001c4e00e7000] Opening '1080p/media-7.ts' for reading
[mpegts @ 000001c4e1c38240] Packet corrupt (stream = 0, dts = 3593840).

答案1

音频和视频的持续时间和开始时间不同。

视频:

Input #0, hls, from '1080p/index.m3u8':
Duration: 01:39:06.34, start: 0.066733

音频:

Input #1, hls, from 'audio/english/index.m3u8':
Duration: 01:39:06.37, start: 0.000000

相关内容