[FFmpeg-user] verifying losslessness after merging two mono tracks into single stereo track

Moritz Barsnick barsnick at gmx.net
Wed Sep 18 16:00:22 EEST 2019


On Wed, Sep 18, 2019 at 12:07:45 +0000, Kieran O'Leary wrote:
> This is the command I used to do a one second test where the
> intention is to merge two mono audio tracks into one stereo track - i
> was hoping that there was a way to do this without a filter but i
> guess not?:

You do need a filter, as you are technically merging two streams into
one. There is no other method to do so.

> ffmpeg -i "input.mov"  -filter_complex "
> [0:2][0:3]join=inputs=2:channel_layout=stereo[a]" -map "[a]"  -c:a pcm_s24le -c:
> v copy -t 1 output.mov

[...]

> What is the best way to verify that the process was lossless?
>
> I tried the following which seems very clumsy:
> 1. Export the two original audio tracks as seperate wav files with  (i know i could have done it in one command but I just knocked this together)
> ffmpeg -i input.mov -c:a copy -t 1 -map 0:2  left.wav
> ffmpeg -i input.mov -c:a copy -t 1 -map 0:3  right.wav

That is indeed clumsy. You can check the framemd5 from the original and
the result without dumping to intermediate files:

(Untested)
$ ffmpeg -i input.mov -c:a copy -t 1 -map 0:2 -f framemd5 -
$ ffmpeg -i input.mov -c:a copy -t 1 -map 0:3 -f framemd5 -
$ ffmpeg -i output.mov -c:a copy -c:a -map_channel 0.0.0 -f framemd5 -
$ ffmpeg -i output.mov -c:a copy -c:a -map_channel 0.0.1 -f framemd5 -

Actually, the frame* muxers even differentiate between their different
output streams anyway, by means of an index, so you can do:

$ ffmpeg -i input.mov -c:a copy -t 1 -map 0:2 -map 0:3 -f framemd5 -
for the input.

(This works with the copy codec because inputs and outputs are
pcm_s24le and expected to be identical. Otherwise you would need to
force it, or in the case of the framehash/framemd5 muxers, that's their
default codec anyway.)

I'm not sure on this caveat but: Note that the frame muxers work on
audio *packets*, IIUC. If a muxer decides to repacket the audio samples
differently, I assume you might get different "frame" hashes. You might
want to instead use the hash/md5 muxers, but they will not tell you
where the difference lies if something was snipped from the end.

Cheers,
Moritz


More information about the ffmpeg-user mailing list