sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
From: Jan Stary <hans@stare.cz>
To: sox-users@lists.sourceforge.net
Subject: Re: discrepancy between sox and ffmpeg when extracting parts of flac file
Date: Sun, 26 Feb 2023 01:37:29 +0100	[thread overview]
Message-ID: <Y/qpycgNQqM+cOau@www.stare.cz> (raw)
In-Reply-To: <6s29gK5drQTAbb6c6x9z9zT5z6IVBkqGdU3mDr_rzk2-Lwth__JIis-Fj4tVTdINxTtCZou4ZPluTUmIc-s3q0c8VjGAAvy_VEBNnqqA-zY=@protonmail.com> <hgm5uo9_nUsgeNNOPQHlRL9QtMXTlPuUfGrDHiY9b0zUNx25npm9dxZXrjxeZJTp_atcEebIvsO8yFc6hGbCyWBNjWqDSLdu_b3JUkKZd2c=@protonmail.com>

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@lists.sourceforge.net 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@lists.sourceforge.net 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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

      parent reply	other threads:[~2023-02-26  0:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 13:32 discrepancy between sox and ffmpeg when extracting parts of flac file Jürgen Koslowski via Sox-users
2023-02-25 16:20 ` Jeremy Nicoll - ml sox users
2023-02-25 22:33   ` Jürgen Koslowski via Sox-users
2023-02-26  0:37 ` Jan Stary [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.sourceforge.net/lists/listinfo/sox-users

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/qpycgNQqM+cOau@www.stare.cz \
    --to=sox-users@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).