Opened 8 years ago

Last modified 7 years ago

#5748 new defect

M3U8 playback broken after seek in Safari OSX/iOS

Reported by: Bryan Murphy Owned by:
Priority: important Component: undetermined
Version: unspecified Keywords: codecpar regression
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I recently tried upgrading to ffmpeg 3.1 and a number of videos that previously worked without issue in Safari on OSX and iOS are now broken when remuxed into M3U8 format.

The specific behavior is that the video starts playing without any issues and if you watch from beginning to end there won't be any problem. However, if at any point you try to seek (sometimes it might take two or three attempts) the video stream will crash. Playback will either stop entirely, or the video stream will crash but audio stream will continue playing.

I ran a git bisect on ffmpeg and this is what I came up with:

# git bisect log
git bisect start
# good: [c66f4d1ae64dffaf456d05cbdade02054446f499] Changelog: Fix minor formating inconsistency
git bisect good c66f4d1ae64dffaf456d05cbdade02054446f499
# bad: [18ce5a4d1b3f87b3b45651401cdf3352de34cfa1] configure: use c++98 for c++ files
git bisect bad 18ce5a4d1b3f87b3b45651401cdf3352de34cfa1
# good: [bb9f7bf1a21d6e00dcb2afaf94d8f84e410cf89c] Changelog/APIChanges Put 3.0 release marker
git bisect good bb9f7bf1a21d6e00dcb2afaf94d8f84e410cf89c
# good: [bb9f7bf1a21d6e00dcb2afaf94d8f84e410cf89c] Changelog/APIChanges Put 3.0 release marker
git bisect good bb9f7bf1a21d6e00dcb2afaf94d8f84e410cf89c
# bad: [36dad146935a500ef6fd7246b5c216f7af26f9db] Merge commit 'eaeba6f241e0de0e797be10f8fda967ef8489e64'
git bisect bad 36dad146935a500ef6fd7246b5c216f7af26f9db
# good: [9f6e63f6f2f289e429c9354c80c21a9dbcd21d1a] avfilter/vf_waveform: add >8 bit support for other filters
git bisect good 9f6e63f6f2f289e429c9354c80c21a9dbcd21d1a
# bad: [0dfbca73bbb3319af49554f7f844e1d7b8d2192c] Merge commit 'dc4983d78af2a666461654067d2e5d45b835358a'
git bisect bad 0dfbca73bbb3319af49554f7f844e1d7b8d2192c
# skip: [e6053b3b19c070e994a501fe0cc20255d15c4aa8] Merge commit 'a8068346e48e123f8d3bdf4d64464d81e53e5fc7'
git bisect skip e6053b3b19c070e994a501fe0cc20255d15c4aa8
# skip: [3fafde6cbe345d2f84cfe61b94d4a823990969b3] lavc: Add seek_preroll to AVCodecParameters
git bisect skip 3fafde6cbe345d2f84cfe61b94d4a823990969b3
# good: [4d251723c0a157b77fa9d3c84c74507d399f7254] lavfi: Add coreimage filter for GPU based image filtering on OSX.
git bisect good 4d251723c0a157b77fa9d3c84c74507d399f7254
# good: [cf4d050b7231d7d96ed4d9a1bfaad87b8981e19d] avformat/wavdec: Remove direct s->pb->buffer access
git bisect good cf4d050b7231d7d96ed4d9a1bfaad87b8981e19d
# good: [38a6242b271fad4917a1c6201ff61e10160c965b] avformat/mpegts: Remove unused argument from analyze()
git bisect good 38a6242b271fad4917a1c6201ff61e10160c965b
# bad: [030e69b4dcb92f3b0372c9af1cefba60e9135010] Merge commit 'a9e1f2cc61cbd5606a087a60565e87923c39de5a'
git bisect bad 030e69b4dcb92f3b0372c9af1cefba60e9135010
# bad: [bc91bc1d8b2baa29267b5181d805f5286466cade] Merge commit '0705f5960c9d272cef1309c090000865b991c9c7'
git bisect bad bc91bc1d8b2baa29267b5181d805f5286466cade
# bad: [6f69f7a8bf6a0d013985578df2ef42ee6b1c7994] Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
git bisect bad 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994
# good: [571aa7d25edc414c3da9253af8b80508c5275b4b] avcodec/shorten: mark as AV_CODEC_CAP_SUBFRAMES
git bisect good 571aa7d25edc414c3da9253af8b80508c5275b4b
# good: [60b75186b2c878b6257b43c8fcc0b1356ada218e] avcodec/wmalosslessdec: do not discard last frame
git bisect good 60b75186b2c878b6257b43c8fcc0b1356ada218e
# skip: [9200514ad8717c63f82101dc394f4378854325bf] lavf: replace AVStream.codec with AVStream.codecpar
git bisect skip 9200514ad8717c63f82101dc394f4378854325bf
# only skipped commits left to test
# possible first bad commit: [6f69f7a8bf6a0d013985578df2ef42ee6b1c7994] Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
# possible first bad commit: [9200514ad8717c63f82101dc394f4378854325bf] lavf: replace AVStream.codec with AVStream.codecpar

It looks like this is the suspect commit:

http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9200514ad8717c63f82101dc394f4378854325bf

I also took a look at the API change log:

2016-04-14 - afccfaf / b1f01e8 - lavu 55.21.100 / 55.7.0 - hwcontext.h
  Add AVHWFramesConstraints and associated API.

2016-04-11 - 6f69f7a / 9200514 - lavf 57.33.100 / 57.5.0 - avformat.h
  Add AVStream.codecpar, deprecate AVStream.codec.

2016-04-02 - e8a9b64 - lavu 55.20.100 - base64.h
  Add AV_BASE64_DECODE_SIZE(x) macro.

and can confirm that revision e8a9b64 does not exhibit any problems. The issue is easily replicated with changeset 6f69f7a/9200514.

I have a sample input video here (Big Buck Bunny):

https://s3.amazonaws.com/1d4326f61a9a4ed596de9e1a41d48413/safariissue/input.mp4

I've already remuxed this video with the two referenced revisions. This was remuxed with 6f69f7a and exhibits the behavior:

https://s3.amazonaws.com/1d4326f61a9a4ed596de9e1a41d48413/safariissue/6f69f7a/6f69f7a.m3u8

This was remuxed with e8a9b64 and plays back without issue:

https://s3.amazonaws.com/1d4326f61a9a4ed596de9e1a41d48413/safariissue/e8a9b64/e8a9b64.m3u8

The command I used to remux the videos is as follows:

ffmpeg -y -i input.mp4 -c "copy" -map "0" -f "segment" -segment_time "10" -vbsf "h264_mp4toannexb" -segment_list_type m3u8 -segment_list "e8a9b64/e8a9b64.m3u8" "e8a9b64/e8a9b64.m3u8.%05d.ts"

I can currently reproduce this with Safari Version 9.1.1 (11601.6.17).

Attachments (1)

build.fd2cde0.log (200.2 KB ) - added by Bryan Murphy 8 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Carl Eugen Hoyos, 8 years ago

Component: ffmpegundetermined
Keywords: codecpar regression added; m3u8 removed
Priority: normalimportant

Is the issue reproducible with current FFmpeg git head? If yes, please provide the command line that allows to reproduce the issue together with the complete, uncut console output to make this a valid ticket.

comment:2 by Bryan Murphy, 8 years ago

Yes, I can reproduce this with current origin/master fd2cde0. Here is the complete output of the ffmpeg command:

bash-4.3# ffmpeg -y -i input.mp4 -c "copy" -map "0" -f "segment" -segment_time "10" -vbsf "h264_mp4toannexb" -segment_list_type m3u8 -segment_list "output/fd2cde0/fd2cde0.m3u8" "output/fd2cde0/fd2cde0.m3u8.%05d.ts"
ffmpeg version N-81193-gfd2cde0 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (Alpine 5.3.0)
  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libmp3lame --enable-librtmp --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-x11grab --disable-stripping --disable-static --enable-vaapi --enable-libopus --enable-nonfree --enable-libfdk-aac
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 49.100 /  6. 49.100
  libavresample   3.  0.  0 /  3.  0.  0
  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 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isomiso2mp42
  Duration: 00:10:34.63, start: 0.000000, bitrate: 2757 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720, 2560 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : Bento4 Video Handler
      encoder         : x264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      handler_name    : Bento4 Sound Handler
[segment @ 0x56475bb479a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, segment, to 'output/fd2cde0/fd2cde0.m3u8.%05d.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isomiso2mp42
    encoder         : Lavf57.44.100
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720, q=2-31, 2560 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : Bento4 Video Handler
      encoder         : x264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, 192 kb/s (default)
    Metadata:
      handler_name    : Bento4 Sound Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=19020 fps=1811 q=-1.0 Lsize=N/A time=00:10:34.62 bitrate=N/A speed=60.4x
video:198393kB audio:14874kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bash-4.3#

Here is the newly muxed file:

https://s3.amazonaws.com/1d4326f61a9a4ed596de9e1a41d48413/safariissue/fd2cde0/fd2cde0.m3u8

I've also attached the build.log for this version of ffmpeg.

by Bryan Murphy, 8 years ago

Attachment: build.fd2cde0.log added

comment:3 by Bryan Murphy, 7 years ago

For anybody else who may be running into this issue, we've had better success using Shaka Packager instead of FFmpeg to mux the video.

Note: See TracTickets for help on using tickets.