This repository was archived by the owner on Sep 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -263,7 +263,41 @@ func (t *Transcoder) GetMetadata() (transcoder.Metadata, error) {
263
263
if err = json .Unmarshal (outb .Bytes (), & metadata ); err != nil {
264
264
return nil , err
265
265
}
266
-
266
+ metadata .Infos = map [string ]string {}
267
+ reader := bufio .NewReader (& errb )
268
+ var prefix string
269
+ var hasMetadata bool
270
+ for {
271
+ byteLine , isPrefix , err := reader .ReadLine ()
272
+ if err != nil && err != io .EOF {
273
+ return metadata , err
274
+ }
275
+ line := string (byteLine )
276
+ if isPrefix {
277
+ prefix += line
278
+ continue
279
+ }
280
+ line = prefix + line
281
+ line = strings .TrimLeft (line , ` ` )
282
+ if ! hasMetadata {
283
+ if strings .HasPrefix (line , `Metadata:` ) {
284
+ hasMetadata = true
285
+ }
286
+ } else {
287
+ parts := strings .SplitN (line , `:` , 2 )
288
+ if len (parts ) == 2 {
289
+ parts [0 ] = strings .TrimRight (parts [0 ], ` ` )
290
+ if len (parts [0 ]) > 0 && parts [0 ] != `Metadata:` {
291
+ parts [1 ] = strings .TrimSpace (parts [1 ])
292
+ metadata .Infos [parts [0 ]] = parts [1 ]
293
+ }
294
+ }
295
+ }
296
+ prefix = ""
297
+ if err == io .EOF {
298
+ break
299
+ }
300
+ }
267
301
t .metadata = metadata
268
302
269
303
return metadata , nil
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ import "github.com/admpub/transcoder"
4
4
5
5
// Metadata ...
6
6
type Metadata struct {
7
- Format Format `json:"format"`
8
- Streams []Streams `json:"streams"`
7
+ Format Format `json:"format"`
8
+ Streams []Streams `json:"streams"`
9
+ Infos map [string ]string `json:"infos"`
9
10
}
10
11
11
12
// Format ...
You can’t perform that action at this time.
0 commit comments