Re: discrepancy between sox and ffmpeg when extracting parts of flac file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please try to trim the lines of your emails
(including the Subject) so that they fit to 80 chars
for those reading this in a terminal.

On Feb 25 13:32:37, sox-users@xxxxxxxxxxxxxxxxxxxxx wrote:
> I have a large flac file (24bits 96kHz) A.flac containing several songs.
> I can extract those bei using either sox (B.flac) or ffmpeg (C.flac)
> with the same splitting points:
> 
> sox T04.flac B.flac trim 22:26.342 =34:41.708
> ffmpeg -i T04.flac -ss 22:26.342 -to 34:41.708 -compression_level 12 -c copy C.flac

You are not just _extracting_ a portion of A.flac,
you are also _encoding_ the extracted portion into flac,
with two different encoders.

What happens if you extract into wav files?

> Unfortunately, the results seem to differ in important aspects:

That shouldn't be a surprise.

> - C.flac that is larger (despite using "-compression_level 12")
> - soxi C.flac as well as ffprobe C.flac shows the wrong lengh,
> namely the length of A.flac

You mean T04.flac; so you are not showing us the actual commands,
or their actual output. Use script(1) to show what actually happened.

The -ss and -to should probably come before -i
to specify the portion of the _input_ you want:

	-ss position (input/output)
	When used as an input option (before "-i"),
	seeks in this input file to position.

	-to position (input/output)
	Stop writing the output or reading the input at position. 

Perhaps you re-encoded the whole A.flac into C.flac,
that's why they have the same length.

> - soxi B.flac and ffprobe B.flac show the correct length

The sox line above is correct, extracting what you wanted.

On Feb 25 22:33:04, sox-users@xxxxxxxxxxxxxxxxxxxxx wrote:
> ffmpeg: 4.4.3
> sox:    14.4.2_p20210509-r2

It's not a matter of versions; they are two different encoders,
and different encoders encode differently, and your ffmpeg line is wrong.

Fix the extraction command first, and extract into wav with both.
Those outputs should be (almost) identical.

> T04.flac and A.flac are indeed the same file, I forgot to adjust
> the name in my original post.

Right.

> B.flac has size 147,664,506, C.flac has been deleted but was in the
> region of 160,000,000. 

I don't believe that: you say C.flac has the same length as A.flac,
which is a collection of songs, and B.flac is just the one song.
Yet these sizes differ by about 13M out of 160M, less than 10%.

> Re-encoding C.flac (sox C.flac CC.flac)

This has nothing to do with your problem.

> A.flac had been extracted from A.mkv by means of ffmpeg;

Doesn't matter: A.flac is the starting point
for both the sox extraction and the ffmpeg extraction.
How you got A.flac has nothing to do with it.

> I don't think sox can do that.

SoX is an audio tool, it doesn't know anything about mkv files.

> I needed A.flac to determine the splitting points (using audacity).

You needed A.flac so that you have a file
which both ffmpeg and sox can read n the first place.

> Now that I know the splitting points, I'll try to extract C.flac
> directly from A.mkv using ffmpeg.

No. Only ffmpeg can extract form a mkv file, SoX cannot.
If the source isn't the same, what are you even comparing?

> As far as I know, I cannot do that with sox, though.

Exactly.

> However, I need to re-create A.mkv first

No you don't: you already have A.flac
which you can feed to both sox and ffmpeg.

I suspoect the whole problem is that your ffmpeg line is wrong.

	Jan



_______________________________________________
Sox-users mailing list
Sox-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sox-users



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux