[ 
https://issues.apache.org/jira/browse/TIKA-5083?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tim Allison reopened TIKA-5083:
-------------------------------

Apologies for my delay! Thank you for modernizing the FlacParser.

My bot found these issues... wdyt?
{noformat}
  Edge-case findings  1. ffmpeg's default block size breaks the scan 
(FlacParser.java:124-128). Seven of eight default-settings files (44.1k, 48k, 
11.025k, 12k, 24-bit, truncated, trailing junk) throw 
NegativeArraySizeException after
     2–67 frames; a 30 s 44.1 kHz stereo file dies at 1.06 s. The eighth, a 
mono sine, completes but reports 0.01 s for 30 s.
     - Cause: upstream FlacAudioFrame maps block-size code 5 (4608, ffmpeg's 
default at 44.1/48 kHz) to 0 — blockSizeRaw < 5 should be <= 5. Decoding then 
misaligns and resyncs on false sync codes.
     - Control: the same audio with -frame_size 4096 or 1152 gives exactly 30.0 
s.
     - Effect in Tika: nothing catches the exception, so the parse fails.
  2. Non-table sample rates also break it. 11025 Hz with -frame_size 4096 
throws after 28 frames. Upstream never assigns sampleRateRaw, so the 
extended-rate header bytes are not consumed.
  3. Header sample rate 0 yields xmpDM:duration = ∞. The else branch also runs 
when the rate is 0, and extractDuration only checks > 0. Needs a rate guard and 
Double.isFinite.
  4. Memory now scales with file size on hostile input. A sync code followed by 
400 MB of zeros hits OutOfMemoryError at -Xmx256m, because the frame reader 
buffers every byte of a frame and a zero run never ends it.
     Previously the audio data was never read.
  5. Cost and noise.
     - A one-hour, 394 MB file takes 11.4 s (about 35 MB/s) where the parse 
used to be constant-time.
     - The library prints "had to skip N bytes of junk" to System.err on every 
resync: 42 lines for one 3 MB file.  Test coverage  All three new fixtures are 
single-frame with block size 960, so the frame loop, resync and code-5 path are 
never exercised. That is why CI is green. A multi-frame fixture at ffmpeg 
defaults would have caught
  finding 1.  Suggested fix  - Catch IOException | RuntimeException around 
calculate() and drop the duration instead of failing the parse.
  - Only take the fallback when the header sample rate is above 0, and require 
a finite result.
  - Fix codes 5 and 12–14 upstream in VorbisJava and bump the version before 
trusting the number; a partial scan currently reports a confidently wrong 
duration.
  - Decide whether a full-file scan should be on by default or behind a config 
flag.
 {noformat}

> FlacParser should use the new FlacAudioStatistics calculator if there is no 
> duration set in the header
> ------------------------------------------------------------------------------------------------------
>
>                 Key: TIKA-5083
>                 URL: https://issues.apache.org/jira/browse/TIKA-5083
>             Project: Tika
>          Issue Type: Improvement
>          Components: parser
>    Affects Versions: 4.3.0
>            Reporter: Nick Burch
>            Priority: Minor
>             Fix For: 4.3.0
>
>
> {{FlacParser}} was brought over from the VorbisJava project (along with its 
> friends) last year as part of the 4.x release. One improvement that didn't 
> come, as the wasn't a matching release of the {{vorbis-java-core}} library 
> with it in, was the ability to calculate the duration of a Flac file if the 
> header didn't include that.
> Now that there is the 0.10 release, and before the {{vorbis-java-tika}} 
> module is retired in favour of the code now in Tika, need to bring that 
> enhancement over.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to