bentasker / HLS-Stream-Creator

Simple Bash Script to take a media file, segment it and create an M3U8 playlist for serving using HLS
BSD 3-Clause "New" or "Revised" License
273 stars 101 forks source link

Bitrate missing from output when encoding forks are done #9

Closed scotia70 closed 8 years ago

scotia70 commented 8 years ago

Hi, great script. I've found a cosmetic issue, here's the output from a run. Note the bitrate number is missing from some of the the "encoding completed" lines.

#HLS-Stream-Creator.sh -i camera-01-20160209T101155.mp4 -s 10 -b 28,96,512,1600
ffmpeg command found.... continuing
Generating HLS segments for bitrate 28k - this may take some time
Generating HLS segments for bitrate 96k - this may take some time
Generating HLS segments for bitrate 512k - this may take some time
Generating HLS segments for bitrate 1600k - this may take some time
All transcoding processes started, awaiting completion
Encoding for bitrate (0) 28k completed
Encoding for bitrate (0) k completed
Encoding for bitrate (0) k completed
Encoding for bitrate (0) k completed

I believe it's to do with the way the PIDS array is emptied. If you reverse the order of the bitrates (and hence they are likely to finish last to first, then the output is ok.

Thanks

bentasker commented 8 years ago

Hi

Thanks - I've had this marked down as HLS-10 (http://projects.bentasker.co.uk/jira_projects/browse/HLS-10.html) for a while but never got as far as looking further into it.

I think you're right, if the bitrate order is reversed the issue goes away - fancy creating a pull for the changes?

Thanks

scotia70 commented 8 years ago

Will do.

bentasker commented 8 years ago

This issue should now be fixed. When a ffmpeg process completes we remove both it's parent PID and the bitrate from the relevant arrays. The key difference being that after each cycle the script was then stripping any null values from the PIDS array but not BITRATE_PROCESSES