Opened 10 months ago

Closed 5 weeks ago

#7073 closed defect (fixed)

Generating multiple HLS renditions and a master playlist results in unusable renditions and anomalies on the master playlist

Reported by: Brainiarc7 Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: hls
Cc: zaterio@grupoz.cl Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Generating multiple HLS renditions with a master playlist results in defects on variant streams and on the master playlist.
Variant streams, apart from the first entry defined by the -var_stream_map option to HLS have zeroed out duration (EXTINF duration tag is zero) as shown below.

How to reproduce:

I have ran into a problem with the HLS muxer, as shown below.

I want to generate three HLS renditions from a single input file, and
a master playlist pointing to the renditions.

Here's the command line used:

ffmpeg -loglevel debug -threads 4 -filter_complex_threads 4 -vsync 1
-i '/home/lin/Desktop/src/sowdtow.webm' -filter_complex \
"[v:0]split=3[s0][s1][s2]; \
 [s0]yadif[v0]; \
 [s1]yadif[v1]; \
 [s2]scale=w=1280:h=720:force_original_aspect_ratio=decrease:flags=lanczos,yadif[v2]"
\
-map "[v0]" -c:v libx264 -pix_fmt yuv420p -preset medium -profile:v
main -level 4.1 -b:v 5250k -maxrate:v 6375k -bufsize:v 12600k \
-map "[v1]" -c:v libx264 -pix_fmt yuv420p -preset medium -profile:v
main -level 4.1 -b:v 4200k -maxrate:v 4494k -bufsize:v 6300k \
-map "[v2]" -c:v libx264 -pix_fmt yuv420p -preset medium -profile:v
main -level 4.1 -b:v 2100k -maxrate:v 2247k -bufsize:v 3150k \
-map a:0 -map a:0 -map a:0 -c:a aac -ar 48000 -ab 256k -af
"aresample=async=1:min_hard_comp=0.100000:first_pts=0" \
-f hls \
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2" -hls_wrap 24 -hls_time 4
-master_pl_name master.m3u8 \
"/home/lin/Desktop/dest/vs%v/manifest.m3u8"

File information:

ffprobe -i sowdtow.webm

ffprobe version N-90268-g9fe61b6 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --prefix=/home/lin/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/lin/ffmpeg_build/include
--extra-ldflags=-L/home/lin/ffmpeg_build/lib --bindir=/home/lin/bin
--enable-cuda-sdk --enable-cuvid --enable-libnpp
--extra-cflags=-I../nv_sdk --extra-ldflags=-L../nv_sdk
--extra-cflags=-I/usr/local/cuda/include/
--extra-ldflags=-L/usr/local/cuda/lib64/ --nvccflags='-gencode
arch=compute_61,code=sm_61 -O2' --enable-gpl --enable-libass
--enable-libfdk-aac --enable-libx264 --extra-libs=-lpthread
--enable-libx265 --enable-nvenc --enable-nonfree
  libavutil      56.  8.100 / 56.  8.100
  libavcodec     58. 14.100 / 58. 14.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, matroska,webm, from 'sowdtow.webm':
  Metadata:
    ENCODER         : Lavf58.10.100
  Duration: 00:03:02.18, start: 0.000000, bitrate: 16906 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv,
bt709/unknown/unknown), 3840x2160, SAR 1:1 DAR 16:9, 29.97 fps, 29.97
tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:03:02.115000000
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      HANDLER_NAME    : SoundHandler
      DURATION        : 00:03:02.184000000



The command above is supposed to achieve the following goals:

  1. Split the primary video stream into three, such that separate

outputs governed by the selected encoder (libx264) and separate
filters can be applied, including a re-scale for the third stream.

  1. Encode the audio stream to three different renditions, and;
  1. Using the HLS muxer's -var_stream_map , generate appropriate

groupings for the renditions above and a master playlist pointing to
the renditions.

Here's where all goes to hell:

Only the first variable stream map pair (output under
~/Desktop/dest/vs1) has the correct HLS time set in the segments, as
shown below:

less vs0/manifest.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:41
#EXTINF:3.937267,
manifest17.ts
#EXTINF:4.004000,
manifest18.ts
#EXTINF:4.070733,
manifest19.ts
#EXTINF:3.903900,
manifest20.ts
#EXTINF:2.202200,
manifest21.ts
#EXT-X-ENDLIST

And now, on to the other broken manifests rendered unplayable:

less vs1/manifest.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:0
#EXT-X-MEDIA-SEQUENCE:41
#EXTINF:0.000000,
manifest17.ts
#EXTINF:0.000000,
manifest18.ts
#EXTINF:0.000000,
manifest19.ts
#EXTINF:0.000000,
manifest20.ts
#EXTINF:0.000000,
manifest21.ts
#EXT-X-ENDLIST

And
vs2/manifest.m3u8:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:0
#EXT-X-MEDIA-SEQUENCE:41
#EXTINF:0.000000,
manifest17.ts
#EXTINF:0.000000,
manifest18.ts
#EXTINF:0.000000,
manifest19.ts
#EXTINF:0.000000,
manifest20.ts
#EXTINF:0.000000,
manifest21.ts
#EXT-X-ENDLIST

Note the anomaly in the #EXTINF: period field on vs1 and 2's manifest,
zeroed out, and compare it to the functioning vs0's manifest.

The second anomaly arises in the main manifest:

less master.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=2591600,RESOLUTION=3840x2160,CODECS="avc1.4d4029,mp4a.40.2"
vs0/manifest.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2591600,RESOLUTION=3840x2160,CODECS="avc1.4d4029,mp4a.40.2"
vs1/manifest.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2591600,RESOLUTION=1280x720,CODECS="avc1.4d4029,mp4a.40.2"
vs2/manifest.m3u8

Note that according to the master manifest, all three renditions have
the same BANDWIDTH value, despite having separate encoder settings.

Testing with other muxers, such as fifo and tee also result in the same issue.

Platform information:

ffmpeg -buildconf
ffmpeg version N-90268-g9fe61b6 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --prefix=/home/lin/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/lin/ffmpeg_build/include
--extra-ldflags=-L/home/lin/ffmpeg_build/lib --bindir=/home/lin/bin
--enable-cuda-sdk --enable-cuvid --enable-libnpp
--extra-cflags=-I../nv_sdk --extra-ldflags=-L../nv_sdk
--extra-cflags=-I/usr/local/cuda/include/
--extra-ldflags=-L/usr/local/cuda/lib64/ --nvccflags='-gencode
arch=compute_61,code=sm_61 -O2' --enable-gpl --enable-libass
--enable-libfdk-aac --enable-libx264 --extra-libs=-lpthread
--enable-libx265 --enable-nvenc --enable-nonfree
  libavutil      56.  8.100 / 56.  8.100
  libavcodec     58. 14.100 / 58. 14.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100

  configuration:
    --prefix=/home/lin/ffmpeg_build
    --pkg-config-flags=--static
    --extra-cflags=-I/home/lin/ffmpeg_build/include
    --extra-ldflags=-L/home/lin/ffmpeg_build/lib
    --bindir=/home/lin/bin
    --enable-cuda-sdk
    --enable-cuvid
    --enable-libnpp
    --extra-cflags=-I../nv_sdk
    --extra-ldflags=-L../nv_sdk
    --extra-cflags=-I/usr/local/cuda/include/
    --extra-ldflags=-L/usr/local/cuda/lib64/
    --nvccflags='-gencode arch=compute_61,code=sm_61 -O2'
    --enable-gpl
    --enable-libass
    --enable-libfdk-aac
    --enable-libx264
    --extra-libs=-lpthread
    --enable-libx265
    --enable-nvenc
    --enable-nonfree

Attachments (2)

out1.zip (269.3 KB) - added by zaterio 5 weeks ago.
out2.zip (271.1 KB) - added by zaterio 5 weeks ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 9 months ago by Brainiarc7

Notes:

On the tee and fifo muxers, setting the output format to HLS results in the same problem.

Edited to clarify on the last bit.

comment:2 Changed 9 months ago by vishwadixit

Hi,

Can you please use this patch and confirm the issue fix, https://patchwork.ffmpeg.org/patch/7951/

Regards,
Vishwanath

comment:3 Changed 9 months ago by Brainiarc7

Hello,

The issue is fixed with the provided patch. Thanks so much.

comment:4 Changed 9 months ago by stevenliu

  • Resolution set to fixed
  • Status changed from new to closed

Changed 5 weeks ago by zaterio

Changed 5 weeks ago by zaterio

comment:5 Changed 5 weeks ago by zaterio

Similar behavior in last commit (Nov 2018)

[root@localhost 2]# /usr/local/ffmpeg-master-nvenc-fdk-aac/bin/ffmpeg -buildconf
ffmpeg version N-92394-g75625c5 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --prefix=/usr/local/ffmpeg-master-nvenc-fdk-aac --pkg-config-flags=--static --extra-cflags=-I/usr/src/ffmpeg_build/include --extra-cflags=-I/usr/local/cuda-9.2/include/ --extra-ldflags=-L/usr/local/cuda-9.2/lib64/ --extra-ldflags=-L/usr/src/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --enable-gpl --enable-libx264 --enable-nonfree --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp --enable-libfdk_aac
  libavutil      56. 23.101 / 56. 23.101
  libavcodec     58. 39.100 / 58. 39.100
  libavformat    58. 22.100 / 58. 22.100
  libavdevice    58.  6.100 / 58.  6.100
  libavfilter     7. 43.100 /  7. 43.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100

  configuration:
    --prefix=/usr/local/ffmpeg-master-nvenc-fdk-aac
    --pkg-config-flags=--static
    --extra-cflags=-I/usr/src/ffmpeg_build/include
    --extra-cflags=-I/usr/local/cuda-9.2/include/
    --extra-ldflags=-L/usr/local/cuda-9.2/lib64/
    --extra-ldflags=-L/usr/src/ffmpeg_build/lib
    --extra-libs=-lpthread
    --extra-libs=-lm
    --enable-gpl
    --enable-libx264
    --enable-nonfree
    --enable-cuda
    --enable-cuvid
    --enable-nvenc
    --enable-libnpp
    --enable-libfdk_aac

# MPEGTS test

/usr/local/ffmpeg-master-nvenc-fdk-aac/bin/ffmpeg -loglevel debug \
-hwaccel cuvid -c:v h264_cuvid \
-y -i /home/trz/content/profile-abr_progresive_hp_r30_hls/avengers60fps.mp4  \
-filter_complex "[v:0]split=2[s0][s1];[0:a]asplit=2[ao1][ao2]" \
-map [s0] -map [ao1] -c:v h264_nvenc -preset hp -b:v 3000k -rc cbr -c:a libfdk_aac -b:a 96k -ar 48.0k -ac 2 \
-f mpegts 3000.ts \
-map [s1] -map [ao2] -c:v h264_nvenc -preset hp -b:v 1000k -rc cbr -c:a libfdk_aac -b:a 96k -ar 48.0k -ac 2 \
-f mpegts 1000.ts 2> out1.log
[root@localhost 2]# mediainfo 1000.ts 
General
ID                                       : 1 (0x1)
Complete name                            : 1000.ts
Format                                   : MPEG-TS
File size                                : 104 MiB
Duration                                 : 11 min 20 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 277 kb/s
[root@localhost 2]# mediainfo 3000.ts 
General
ID                                       : 1 (0x1)
Complete name                            : 3000.ts
Format                                   : MPEG-TS
File size                                : 271 MiB
Duration                                 : 11 min 20 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 3 337 kb/s

# HLS test

/usr/local/ffmpeg-master-nvenc-fdk-aac/bin/ffmpeg -loglevel debug \
-hwaccel cuvid -c:v h264_cuvid \
-y -i /home/trz/content/profile-abr_progresive_hp_r30_hls/avengers60fps.mp4  \
-filter_complex "[v:0]split=2[s0][s1];[0:a]asplit=2[ao1][ao2]" \
-map [s0] -map [ao1] -c:v h264_nvenc -preset hp -b:v 3000k -rc cbr -c:a libfdk_aac -b:a 96k -ar 48.0k -ac 2 \
-map [s1] -map [ao2] -c:v h264_nvenc -preset hp -b:v 1000k -rc cbr -c:a libfdk_aac -b:a 96k -ar 48.0k -ac 2 \
-f hls \
-var_stream_map "v:0,a:0 v:1,a:1" -hls_list_size 0 -hls_time 9 \
-master_pl_name master.m3u8 vs%v/manifest.m3u8 2> out2.log
[root@localhost 2]# cat master.m3u8 
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1205600,RESOLUTION=1920x1080,CODECS="avc1.4d402a,mp4a.40.2"
vs0/manifest.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=1205600,RESOLUTION=1920x1080,CODECS="avc1.4d402a,mp4a.40.2"
vs1/manifest.m3u8
[root@localhost 2]# mediainfo vs0/manifest15.ts 
General
ID                                       : 1 (0x1)
Complete name                            : vs0/manifest15.ts
CompleteName_Last                        : vs0/manifest75.ts
Format                                   : MPEG-TS
File size                                : 79.2 MiB
Duration                                 : 9 min 3 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 222 kb/s
[root@localhost 2]# mediainfo vs1/manifest15.ts 
General
ID                                       : 1 (0x1)
Complete name                            : vs1/manifest15.ts
CompleteName_Last                        : vs1/manifest75.ts
Format                                   : MPEG-TS
File size                                : 79.2 MiB
Duration                                 : 9 min 3 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 222 kb/s

comment:6 Changed 5 weeks ago by zaterio

  • Cc zaterio@grupoz.cl added
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 Changed 5 weeks ago by cehoyos

  • Component changed from undetermined to avformat
  • Resolution set to fixed
  • Status changed from reopened to closed
  • Version changed from unspecified to git-master
Note: See TracTickets for help on using tickets.