harryjackson / ffmpeg_split

Split an ffmpeg file by chapter
Apache License 2.0
55 stars 20 forks source link

first chunk gets dropped #10

Closed fenugrec closed 5 months ago

fenugrec commented 10 months ago

If the first defined Chapter doesn't start at 0, some data gets dropped . Example :

$ ffmpeg -i STE-000.wav
  Metadata:
    encoded_by      : ZOOM Handy Recorder H4n
    date            : 2023-11-05
    creation_time   : 17:54:35
    time_reference  : 3094800000
    coding_history  : A=PCM,F=48000,W=16,M=stereo,T=ZOOM Handy Recorder H4n
  Duration: 00:00:05.05, bitrate: 1537 kb/s
  Chapters:
    Chapter #0:0: start 0.617000, end 1.554000
      Metadata:
        title           : 01
    Chapter #0:1: start 1.554000, end 2.525000
      Metadata:
        title           : 02
    Chapter #0:2: start 2.525000, end 5.054667
      Metadata:
        title           : 03

In that example, the script creates 3 files, and the recording between 0 and 0.617 is dropped.

Tested with this file, a 5-second recording with 3 split points : STE-000.wav.zip

harryjackson commented 5 months ago

I'm not comfortable adding something that doesn't exist. There are three chapters and it prints them out. If it's considered a bug, we should throw an error, but I don't think we should add anything that's not already there.

fenugrec commented 5 months ago

There are three chapters and it prints them out

Well, in .wav files, these markers are actually cue points and not chapters :

The cue-points chunk identifies a series of positions in the waveform data stream. ( Multimedia Programming Interface and Data Specifications 1.0 )

So it wouldn't necessarily make sense to have a cue point defined at 0.0 ; in any case Zoom decided not to generate one and unfortunately I cannot change that. I wonder if other audio recorders also behave this way. ffmpeg calls them chapters probably just stay consistent accross codecs and containers.

fenugrec commented 5 months ago

If it's considered a bug, we should throw an error

Well I wouldn't say a bug, at least not in all cases, but I think a warning would be nice. I was batch processing files and it actually took me a bit of time to realize I was losing important parts.