Использование mediafilesegmenter для видео со списками редактирования

Я пытаюсь использовать mediafilesegmenter для видео, которое я перекодировал с помощью ffmpeg, чтобы упаковать его для HLS. Однако он жалуется на «списки редактирования» и отказывается что-либо делать. Кто-нибудь знает, как удалить списки редактирования или заставить mediafilesegmenter работать с ними?

$ mediafilesegmenter -I -f 180 -t 9 -s bbb_180p_30fps_264k.mp4
Jun 29 2016 17:12:33.676: Using floating point is not backward compatible to iOS 4.1 or earlier devices
Jun 29 2016 17:12:33.677: Single file output is not backward compatible to earlier than iOS 5.0
Jun 29 2016 17:12:33.677: Processing file /Users/aspera/git/dash-demo/video-transcoding/bbb-transcoded-hls/bbb_180p_30fps_264k.mp4
Jun 29 2016 17:12:33.689: track 1 of /Users/aspera/git/dash-demo/video-transcoding/bbb-transcoded-hls/bbb_180p_30fps_264k.mp4 contains edit lists; these tracks cannot be used for segmentation
Jun 29 2016 17:12:33.689: no tracks found!
Jun 29 2016 17:12:33.689: average bit rate is  0.00 bits/sec - max file bit rate is  0.00 bits/sec

Входное видео:

$ ffprobe bbb_180p_30fps_264k.mp4 
ffprobe version 3.0.2 Copyright (c) 2007-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfdk-aac --enable-nonfree --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bbb_180p_30fps_264k.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.25.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:10:34.53, start: 0.021333, bitrate: 184 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x180 [SAR 1:1 DAR 16:9], 113 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

РЕДАКТИРОВАТЬ: я обнаружил, что ffmpeg, похоже, добавляет списки редактирования при транскодировании.

Исходный файл:

$ MP4Box -info originals/bbb_sunflower_2160p_60fps_normal.mp4 
* Movie Info *
    Timescale 600 - 3 tracks
    Computed Duration 00:10:34.533 - Indicated Duration 00:10:34.533
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand isom - version 1
    Created: GMT Tue Dec 17 16:40:26 2013
    Modified: GMT Tue Dec 17 16:40:26 2013

File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: ISO Reserved Profile (0x15)
Audio PL: Not part of MPEG-4 audio profiles (0xfe)
No streams included in root OD

iTunes Info:
    Name: Big Buck Bunny, Sunflower version
    Artist: Blender Foundation 2008, Janus Bager Kristensen 2013
    Comment: Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    Composer: Jan Morgenstern
    Writer: Sacha Goedegebure
    Genre: Animation
1 UDTA types: meta (1) 

Track # 1 Info - TrackID 1 - TimeScale 60000
Media Duration 00:10:34.533 - Indicated Duration 00:10:34.533
Media Info: Language "und (und)" - Type "vide:avc1" - 38072 samples
Visual Track layout: x=0 y=0 width=3840 height=2160
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 3840 x 2160
    AVC Info: 1 SPS - 1 PPS - Profile High @ Level 5.1
    NAL Unit length bits: 32
    Pixel Aspect Ratio 1:1 - Indicated track size 3840 x 2160
    SPS#1 hash: 73C3B5E51841EEDF280132A1F7C72DD97D9FDE86
    PPS#1 hash: EB72205FBA0E2A677BE65E145507E2E05750EB4F
Self-synchronized
    RFC6381 Codec Parameters: avc1.640033
    Average GOP length: 184 samples

Track # 2 Info - TrackID 2 - TimeScale 48000
Media Duration 00:10:34.200 - Indicated Duration 00:10:34.200
Media Info: Language "und (und)" - Type "soun:mp4a" - 26425 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x6b
MPEG-1 Audio - 2 Channel(s) - SampleRate 48000 - Layer 3
Synchronized on stream 1
    RFC6381 Codec Parameters: mp4a.6b
    All samples are sync

Track # 3 Info - TrackID 3 - TimeScale 48000
Media Duration 00:10:34.144 - Indicated Duration 00:10:34.144
Media Info: Language "und (und)" - Type "soun:ac-3" - 19817 samples
    AC-3 stream - Sample Rate 48000 - 5.1 channel(s) - bitrate 32000
    RFC6381 Codec Parameters: ac-3
    All samples are sync

После FFMPEG:

$ MP4Box -info bbb_180p_30fps_264k.mp4 
* Movie Info *
    Timescale 1000 - 2 tracks
    Computed Duration 00:10:34.600 - Indicated Duration 00:10:34.534
    Fragmented File: no
    File Brand isom - version 512
    Created: UNKNOWN DATE   Modified: UNKNOWN DATE
File has no MPEG4 IOD/OD

iTunes Info:
    Name: Big Buck Bunny, Sunflower version
    Artist: Blender Foundation 2008, Janus Bager Kristensen 2013
    Comment: Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    Writer: Sacha Goedegebure
    Genre: Animation
    Encoder Software: Lavf57.25.100
1 UDTA types: meta (1) 

Track # 1 Info - TrackID 1 - TimeScale 15360
Media Duration 00:10:34.533 - Indicated Duration 00:10:34.533
Track has 2 edit lists: track duration is 00:10:34.600
Media Info: Language "und (und)" - Type "vide:avc1" - 19036 samples
Visual Track layout: x=0 y=0 width=320 height=180
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 320 x 180
    AVC Info: 1 SPS - 1 PPS - Profile Baseline @ Level 3
    NAL Unit length bits: 32
    Pixel Aspect Ratio 1:1 - Indicated track size 320 x 180
    SPS#1 hash: 4FD0A6F8F73D905B5A9973F02BF9E2D401820F71
    PPS#1 hash: E79F98332B320CB0B190539E0D4A262181656B90
Self-synchronized
    RFC6381 Codec Parameters: avc1.42c01e
    Average GOP length: 90 samples

Track # 2 Info - TrackID 2 - TimeScale 48000
Media Duration 00:10:34.221 - Indicated Duration 00:10:34.221
Track has 1 edit lists: track duration is 00:10:34.200
Media Info: Language "und (und)" - Type "soun:mp4a" - 29730 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000
Synchronized on stream 1
    RFC6381 Codec Parameters: mp4a.40.2
Alternate Group ID 1
    All samples are sync

Ответы (2)

Похоже, MP4 не будет пропускать edtsполя при создании MP4. Вы должны перекодировать в MPEG-TS и передать это в mediafilesegmenter

ffmpeg -i in.mp4 -<transcoding options> -vbsf h264_mp4toannexb out.ts
Я пробовал без параметров (просто ffmpeg -i in.mp4 -bsf:v h264_mp4toannexb out.ts), но запуск mediafilesegmenter на out.ts производил только звук. Мне пришлось добавить «-c:v copy -c:a copy» в команду ffmpeg, чтобы она заработала.

Я предпочитаю подход Mulvya, но другой метод, который «решает» проблему, заключается в демультиплексировании и мультиплексировании потоков:

ffmpeg -i in.mp4 -c:v copy -an video.mkv
ffmpeg -i in.mp4 -vn -c:a copy audio.mkv
ffmpeg -i video.mkv -i audio.mkv -c:v copy -c:a copy in2.mp4
mediafilesegmenter -I -t 9 -s in2.mp4

Я не могу сказать вам, почему это работает, хотя.