Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mp4 to HLS using ffmpeg

Tags:

I'm trying to convert a local .mp4 video to HLS using ffmpeg in an iOS app. I have integrated the ffmpeg wrapper using pods and generated all the segmented .ts files and the m3u8 file, but some of the .ts file segments are not listed in the .m3u8 playlist file as shown below. It is always listing the last 5 video segments.

#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:2 #EXT-X-MEDIA-SEQUENCE:13 #EXTINF:2, out13.ts #EXTINF:1, out14.ts #EXTINF:2, out15.ts #EXTINF:2, out16.ts #EXTINF:1, out17.ts #EXT-X-ENDLIST 

I used the following codes to generate the HLS.

    FFmpegWrapper *wrapper = [[FFmpegWrapper alloc] init];     [wrapper convertInputPath:inputFilePath outputPath:outputFilePath options:nil progressBlock:^(NSUInteger bytesRead, uint64_t totalBytesRead, uint64_t totalBytesExpectedToRead) {      } completionBlock:^(BOOL success, NSError *error) {         success?NSLog(@"Success...."):NSLog(@"Error : %@",error.localizedDescription);     }]; 

Is there any other methods to do this?

like image 558
Vishnu Kumar. S Avatar asked Jun 18 '15 10:06

Vishnu Kumar. S


People also ask

Does FFmpeg support HLS?

For this task we will use ffmpeg , a powerful tool that supports conversion of various video formats from one to another, including HLS both as input and output.

How do I create an HLS stream in FFmpeg?

Basic Steps to HLS Packaging using FFmpegread an input video from disk. scale/resize the video to the multiple resolutions required. transcode the audio to the required bitrates. combine the video and audio, package each combination, and create the individual TS segments and the playlists.

Can FFmpeg convert video?

FFmpeg is an open-source audio and video converter that supports most industry-standard codecs and can convert from one file format to another quickly and easily. It also lets you capture video and audio from a live source and process it.


1 Answers

Default list size while converting to HLS is 5. So, you are getting the last 5 .ts files. You must set -hls_list_size 0 to include all the generated .ts files.

ffmpeg -i input.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8 More here

like image 184
budthapa Avatar answered Sep 27 '22 19:09

budthapa