Hi all,

So I’ve noticed that ffmpeg does not always properly follow the number we 
specify for hls_time when generating hls content.

For example, if we have an MP4/AAC file at 44.1kHz sampling rate, we would 
expect that specifying 9.75238095238095 (420 frames) would return a manifest 
with the same exact amount of frames throughout.
Instead, we see the AAC encoder vary the amount of frames without any real 
explanation.

When we run the following command:

/home/ronakp/bin/ffmpeg -i "${FILE}.mp4" -codec copy -hls_time 9.75238095238095 
-hls_segment_type fmp4 -hls_flags single_file+append_list -hls_playlist_type 
vod "${FILE}_10sec_v7.m3u8"

We get a manifest that looks like so:

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="bk_acx0_006556_22_32_10sec_v7.m4s",BYTERANGE="738@0"
#EXT-X-DISCONTINUITY
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38733@738
bk_acx0_006556_22_32_10sec_v7.m4s
#EXTINF:9.752381,
#EXT-X-BYTERANGE:38531@39471
bk_acx0_006556_22_32_10sec_v7.m4s
#EXTINF:9.752381,
#EXT-X-BYTERANGE:38616@78002
bk_acx0_006556_22_32_10sec_v7.m4s
#EXTINF:9.752381,
#EXT-X-BYTERANGE:38545@116618
bk_acx0_006556_22_32_10sec_v7.m4s

Notice the first segment there contains 2 more AAC frames...

Now, when we run the following command:

/home/ronakp/bin/ffmpeg -i "${FILE}.mp4" -codec copy -hls_time 
0.975238095238095 -hls_segment_type fmp4 -hls_flags single_file+append_list 
-hls_playlist_type vod "${FILE}_10sec_v7.m3u8"

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="bk_reco_004353_22_32_1sec_v7.m4s",BYTERANGE="738@0"
#EXT-X-DISCONTINUITY
#EXTINF:0.975238,
#EXT-X-BYTERANGE:4110@738
bk_reco_004353_22_32_1sec_v7.m4s
#EXTINF:0.975238,
#EXT-X-BYTERANGE:3897@4848
bk_reco_004353_22_32_1sec_v7.m4s
#EXTINF:0.975238,
#EXT-X-BYTERANGE:4236@8745
bk_reco_004353_22_32_1sec_v7.m4s
#EXTINF:0.975238,

It seems to have the correct amount of frames everywhere.

Even more bizarre is if we run this command:

/home/ronakp/bin/ffmpeg -i "../${FILE}.mp4" -codec copy -hls_time 
9.75238095238095 -hls_segment_filename 'file%03d.ts' -hls_segment_type mpegts 
-hls_playlist_type vod "${FILE}_10sec_v3.m3u8"

The manifest looks like the following:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:9.799778,
file000.ts
#EXTINF:9.706889,
file001.ts
#EXTINF:9.753333,
file002.ts
#EXTINF:9.799778,
file003.ts
#EXTINF:9.753333,
file004.ts
#EXTINF:9.706889,
file005.ts
#EXTINF:9.799778,
file006.ts

The ts segments do not all have the same size, and seems like ffmpeg is unable 
to properly honor the supplied time.

And finally, when I run the following command:

/home/ronakp/bin/ffmpeg -i "${FILE}.mp4" -codec copy -f dash -single_file_name 
"${FILE}_1sec.m4s" -min_seg_duration 975238.095238095 -hls_playlist 1 
"${FILE}_1sec.mpd"

I get a manifest that looks like:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="bk_reco_004353_22_32_10sec.m4s",BYTERANGE="738@0"
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38996@738
bk_reco_004353_22_32_10sec.m4s
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38754@39734
bk_reco_004353_22_32_10sec.m4s
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38765@78488
bk_reco_004353_22_32_10sec.m4s
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38583@117253
bk_reco_004353_22_32_10sec.m4s
#EXTINF:9.798821,
#EXT-X-BYTERANGE:38752@155836
bk_reco_004353_22_32_10sec.m4s

Where every fragment has 1 extra frame in it.

Can someone please help get this fixed? The fragmentation should have been 
uniform throughout and exactly the same no matter which options I specify here.

For reference, I'm using the following versions of ffmpeg:

ffmpeg version N-90757-g2fc12f4 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.4.6 (GCC) 20110731 (Red Hat 4.4.6-3)
  configuration: --prefix=/home/ronakp/ffmpeg_build --pkg-config-flags=--static 
--extra-cflags=-I/home/ronakp/ffmpeg_build/include 
--extra-ldflags=-L/home/ronakp/ffmpeg_build/lib --extra-libs=-lpthread 
--extra-libs=-lm --bindir=/home/ronakp/bin --enable-gpl --enable-avisynth 
--enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis 
--enable-nonfree --enable-libvorbis --enable-version3 --disable-ffplay
  libavutil      56. 15.100 / 56. 15.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 18.100 /  7. 18.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100

Thanks,

Ronak

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to