将视频转换为HLS时ffmpeg不正确的持续时间

时间:2016-10-11 19:45:58

标签: ios iphone ffmpeg avplayer hls

我正面临使用ffmpeg转换视频的问题,正好是mp4 video => Http Live Streaming(HLS)

转换为HLS后,.m3u8文件的持续时间错误(例如:20,1s而不是20.00s),在iOS上使用AVPlayer播放时会导致错误。 使用Safari播放视频会导致同样的问题。

示例:
1)打开野生动物园 2)Play this video that i've converted
3)查看下载进度,停止在98%的错误持续时间的原因 enter image description here
4)当您在98%和100%之间滑动时,视频播放器可能会崩溃。

编辑1:

我已经编辑了命令行

return

日志:

 ffmpeg -i  video.mp4 \
 -codec copy \
 -acodec copy \
 -map 0 -f ssegment -g 60 -sc_threshold 0 \
 -segment_list playlist.m3u8 \
 -segment_list_flags +live \
 -segment_time 2 media%05d.ts \
  >./log_ffmpeg 2>./log_ffmpeg

m3u8文件:

ffmpeg version 3.1.4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-2) 20160904
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libzimg --cc=gcc-5 --disable-ffplay
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Comptes/1/Photos/306/original_video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2016-10-12 14:29:51
  Duration: 00:00:20.00, start: 0.000000, bitrate: 1673 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1563 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 101 kb/s (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Audio
[stream_segment,ssegment @ 0x652ed80] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times

Output #0, stream_segment,ssegment, to './Comptes/1/Photos/306/media%05d.ts':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    encoder         : Lavf57.41.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, q=2-31, 1563 kb/s, 30 fps, 30 tbr, 90k tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, 101 kb/s (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  601 fps=0.0 q=-1.0 Lsize=N/A time=00:00:20.10 bitrate=N/A speed= 917x    
video:3823kB audio:249kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

正如您所见,输入持续时间= / =输出持续时间
输入时间:20s
输出持续时间20.1s

0 个答案:

没有答案