| Conditions | 4 |
| Paths | 5 |
| Total Lines | 53 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 2 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 33 | private function HLSFilter(HLS $hls): array |
||
| 34 | { |
||
| 35 | $filter = []; |
||
| 36 | $reps = $hls->getRepresentations(); |
||
| 37 | $path_parts = $hls->getPathInfo(); |
||
| 38 | $dirname = str_replace("\\", "/", $path_parts["dirname"]); |
||
| 39 | list($seg_sub_dir, $base_url) = $this->getSubDirectory($hls, $dirname); |
||
| 40 | $full_seg_filename = $dirname . "/" . $seg_sub_dir . $path_parts["filename"]; |
||
| 41 | |||
| 42 | foreach ($reps as $key => $rep) { |
||
| 43 | if ($key) { |
||
| 44 | $filter = array_merge($filter, $this->getFormats($hls)); |
||
| 45 | } |
||
| 46 | |||
| 47 | $filter[] = "-s:v"; |
||
| 48 | $filter[] = $rep->getResize(); |
||
| 49 | $filter[] = "-crf"; |
||
| 50 | $filter[] = "20"; |
||
| 51 | $filter[] = "-sc_threshold"; |
||
| 52 | $filter[] = "0"; |
||
| 53 | $filter[] = "-g"; |
||
| 54 | $filter[] = "48"; |
||
| 55 | $filter[] = "-keyint_min"; |
||
| 56 | $filter[] = "48"; |
||
| 57 | $filter[] = "-hls_list_size"; |
||
| 58 | $filter[] = $hls->getHlsListSize(); |
||
| 59 | $filter[] = "-hls_time"; |
||
| 60 | $filter[] = $hls->getHlsTime(); |
||
| 61 | $filter[] = "-hls_allow_cache"; |
||
| 62 | $filter[] = (int)$hls->isHlsAllowCache(); |
||
| 63 | $filter[] = "-b:v"; |
||
| 64 | $filter[] = $rep->getKiloBitrate() . "k"; |
||
| 65 | $filter = array_merge($filter, $this->getAudioBitrate($rep)); |
||
| 66 | $filter[] = "-maxrate"; |
||
| 67 | $filter[] = intval($rep->getKiloBitrate() * 1.2) . "k"; |
||
| 68 | $filter[] = "-hls_segment_type"; |
||
| 69 | $filter[] = $hls->getHlsSegmentType(); |
||
| 70 | $filter[] = "-hls_fmp4_init_filename"; |
||
| 71 | $filter[] = $path_parts["filename"] . "_" . $hls->getHlsFmp4InitFilename(); |
||
| 72 | $filter[] = "-hls_segment_filename"; |
||
| 73 | $filter[] = $this->getSegmentFilename($full_seg_filename, $rep, $hls->getHlsSegmentType()); |
||
| 74 | $filter = array_merge($filter, $this->getBaseURL($base_url)); |
||
| 75 | $filter = array_merge($filter, $this->getKeyInfo($hls)); |
||
| 76 | $filter = array_merge($filter, $hls->getAdditionalParams()); |
||
| 77 | $filter[] = "-strict"; |
||
| 78 | $filter[] = $hls->getStrict(); |
||
| 79 | |||
| 80 | if (end($reps) !== $rep) { |
||
| 81 | $filter[] = $dirname . "/" . $path_parts["filename"] . "_" . $rep->getHeight() . "p.m3u8"; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | return $filter; |
||
| 86 | } |
||
| 155 | } |