@@ -7,7 +7,7 @@ use std::{
77use chrono:: DateTime ;
88use nom:: { bytes:: streaming, IResult } ;
99
10- use crate :: { bbox:: to_boxes, values:: get_cstr } ;
10+ use crate :: { bbox:: to_boxes, values:: filter_zero } ;
1111#[ allow( deprecated) ]
1212use crate :: {
1313 bbox:: {
@@ -216,10 +216,7 @@ fn convert_video_tags(entries: Vec<(String, EntryValue)>) -> BTreeMap<TrackInfoT
216216 . map ( |v| ( TrackInfoTag :: GpsIso6709 , EntryValue :: Text ( v) ) )
217217 } else if k == "udta.auth" {
218218 v. as_u8array ( )
219- // The first 4 bytes is zero, skip them
220- . and_then ( |d| if d. len ( ) > 4 { Some ( & d[ 4 ..] ) } else { None } )
221- // .map(|v| (TrackInfoTag::Author, EntryValue::U8Array(v.to_owned())))
222- . and_then ( |b| get_cstr ( b) . ok ( ) )
219+ . and_then ( parse_udta_auth)
223220 . map ( |v| ( TrackInfoTag :: Author , EntryValue :: Text ( v) ) )
224221 } else if k. starts_with ( "udta." ) {
225222 let tag = TryInto :: < TrackInfoTag > :: try_into ( k. as_str ( ) ) . ok ( ) ;
@@ -258,6 +255,21 @@ fn parse_udta_gps(data: &[u8]) -> Option<String> {
258255 }
259256}
260257
258+ const ISO_639_2_UND : [ u8 ; 2 ] = [ 0x55 , 0xc4 ] ;
259+
260+ fn parse_udta_auth ( data : & [ u8 ] ) -> Option < String > {
261+ // Skip leading zero bytes
262+ let data = filter_zero ( data) ;
263+
264+ // Skip leading language flags.
265+ // Refer to: https://exiftool.org/forum/index.php?topic=11498.0
266+ if data. starts_with ( & ISO_639_2_UND ) {
267+ String :: from_utf8 ( data. into_iter ( ) . skip ( 2 ) . collect ( ) ) . ok ( )
268+ } else {
269+ String :: from_utf8 ( data) . ok ( )
270+ }
271+ }
272+
261273/// *Deprecated*: Please use [`crate::MediaParser`] instead.
262274///
263275/// Analyze the byte stream in the `reader` as a MOV file, attempting to extract
0 commit comments