| 160 | } |
| 161 | |
| 162 | func extractFFmpegError(logStr string) string { |
| 163 | priority := []string{"Error", "Invalid", "failed", "No "} |
| 164 | matches := make(map[string]string) |
| 165 | lines := strings.Split(strings.TrimSpace(logStr), "\n") |
| 166 | for i := 0; i < len(lines); i++ { |
| 167 | line := strings.TrimSpace(lines[i]) |
| 168 | for _, kw := range priority { |
| 169 | if _, ok := matches[kw]; !ok && strings.Contains(line, kw) { |
| 170 | matches[kw] = line |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | for _, kw := range priority { |
| 176 | if line, ok := matches[kw]; ok { |
| 177 | return line |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | if len(lines) > 0 { |
| 182 | return lines[len(lines)-1] |
| 183 | } |
| 184 | return "" |
| 185 | } |