verifying losslessness after merging two mono tracks into single stereo track

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

verifying losslessness after merging two mono tracks into single stereo track

Kieran O'Leary
Hi,

I have a video file that has two 24-bit PCM audio tracks which should just be one paired stereo track.
After looking at the wiki, it seems that this is the best command?



------
This email has been scanned for spam and malware by The Email Laundry.


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: verifying losslessness after merging two mono tracks into single stereo track

Kieran O'Leary
I am very sorry  - Outlook Web App sent the email when I tried to copy paste the command - also it won't let me bottom post! i promise that future emails will be in the correct format.

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?:
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
ffmpeg version N-92623-g2c64a6bcd2 Copyright (c) 2000-2018 the FFmpeg developers

  built with gcc 8.2.1 (Rev1, Built by MSYS2 project) 20181130
  configuration:  --disable-autodetect --enable-amf --enable-bzlib --enable-cuda
 --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --e
nable-nvenc --enable-zlib --enable-sdl2 --disable-debug --enable-ffnvcodec --ena
ble-nvdec --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvp
x --enable-libx264 --enable-libx265 --enable-libdav1d --enable-fontconfig --enab
le-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmy
sofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enabl
e-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --e
nable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl -
-enable-avisynth --enable-libxvid --enable-libaom --enable-version3 --enable-chr
omaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --e
nable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable
-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug
 --enable-libopenh264 --enable-libopenmpt --enable-librtmp --enable-librubberban
d --enable-libssh --enable-libtesseract --enable-libxavs --enable-libzmq --enabl
e-libzvbi --enable-opencl --enable-opengl --enable-libvmaf --enable-libcodec2 --
enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-l
ibs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cfla
gs=-DLIBSSH_STATIC --extra-ldflags='-Wl,--allow-multiple-definition' --extra-cfl
ags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_N
ODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --ex
tra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads --extra-cfl
ags=-DKVZ_STATIC_LIB --enable-nonfree
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 41.101 / 58. 41.101
  libavformat    58. 23.102 / 58. 23.102
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    creation_time   : 2019-09-18T09:27:36.000000Z
  Duration: 01:37:57.56, start: 0.000000, bitrate: 223490 kb/s
    Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt4
70bg/bt709, top coded first (swapped)), 720x576, 221184 kb/s, SAR 16:15 DAR 4:3,
 25 fps, 25 tbr, 25k tbn, 25k tbc (default)
    Metadata:
      creation_time   : 2019-09-18T09:27:36.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : 10 bit YCbCr
      timecode        : 00:58:04:15
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2019-09-18T09:27:36.000000Z
      handler_name    : Time Code Media Handler
      reel_name       : Untitled
      timecode        : 00:58:04:15
    Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32
(24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2019-09-18T09:27:36.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32
(24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2019-09-18T09:27:36.000000Z
      handler_name    : Apple Sound Media Handler
File 'output.mov' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:2 (pcm_s24le) -> join:input0
  Stream #0:3 (pcm_s24le) -> join:input1
  join -> Stream #0:0 (pcm_s24le)
Press [q] to stop, [?] for help
Output #0, mov, to 'output.mov':
  Metadata:
    encoder         : Lavf58.23.102
    Stream #0:0: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32, 23
04 kb/s (default)
    Metadata:
      encoder         : Lavc58.41.101 pcm_s24le
size=     282kB time=00:00:01.00 bitrate=2309.9kbits/s speed=41.1x
video:0kB audio:281kB subtitle:0kB other streams:0kB global headers:0kB muxing o
verhead: 0.256944%

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

2. Export the new output.mov with the single stereo track as a WAV, then used the following to make seperate tracks out of the channels: with ffmpeg -i output.mov -c:a pcm_s24le -map_channel 0.0.0 left_merge.wav -c:a pcm_s24le -map_channel 0.0.1 right_merge.wav

3. Use framemd5s to compare the various wavs to make sure that the same samples are produced in the source and output.

The framemd5s were indeed identical aside from the last sample, which may have had something to do with trimming at 1 second.

is there an easier way to verify that the same audio is produced in the source  audio files as with the merged stereo track?

Best,

Kieran.





------
This email has been scanned for spam and malware by The Email Laundry.


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: verifying losslessness after merging two mono tracks into single stereo track

Moritz Barsnick
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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: verifying losslessness after merging two mono tracks into single stereo track

Carl Eugen Hoyos-2
In reply to this post by Kieran O'Leary
Am Mi., 18. Sept. 2019 um 14:08 Uhr schrieb Kieran O'Leary
<[hidden email]>:

>
> I am very sorry  - Outlook Web App sent the email when I tried to copy paste the command - also it won't let me bottom post! i promise that future emails will be in the correct format.
>
> 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?:
> 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
> ffmpeg version N-92623-g2c64a6bcd2 Copyright (c) 2000-2018 the FFmpeg developers
>
>   built with gcc 8.2.1 (Rev1, Built by MSYS2 project) 20181130
>   configuration:  --disable-autodetect --enable-amf --enable-bzlib --enable-cuda
>  --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --e
> nable-nvenc --enable-zlib --enable-sdl2 --disable-debug --enable-ffnvcodec --ena
> ble-nvdec --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvp
> x --enable-libx264 --enable-libx265 --enable-libdav1d --enable-fontconfig --enab
> le-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmy
> sofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
> --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enabl
> e-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --e
> nable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl -
> -enable-avisynth --enable-libxvid --enable-libaom --enable-version3 --enable-chr
> omaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --e
> nable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable
> -libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug
>  --enable-libopenh264 --enable-libopenmpt --enable-librtmp --enable-librubberban
> d --enable-libssh --enable-libtesseract --enable-libxavs --enable-libzmq --enabl
> e-libzvbi --enable-opencl --enable-opengl --enable-libvmaf --enable-libcodec2 --
> enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-l
> ibs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cfla
> gs=-DLIBSSH_STATIC --extra-ldflags='-Wl,--allow-multiple-definition' --extra-cfl
> ags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_N
> ODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --ex
> tra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads --extra-cfl
> ags=-DKVZ_STATIC_LIB --enable-nonfree
>   libavutil      56. 24.101 / 56. 24.101
>   libavcodec     58. 41.101 / 58. 41.101
>   libavformat    58. 23.102 / 58. 23.102
>   libavdevice    58.  6.101 / 58.  6.101
>   libavfilter     7. 46.101 /  7. 46.101
>   libswscale      5.  4.100 /  5.  4.100
>   libswresample   3.  4.100 /  3.  4.100
>   libpostproc    55.  4.100 / 55.  4.100
> Guessed Channel Layout for Input Stream #0.2 : mono
> Guessed Channel Layout for Input Stream #0.3 : mono
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
>   Metadata:
>     creation_time   : 2019-09-18T09:27:36.000000Z
>   Duration: 01:37:57.56, start: 0.000000, bitrate: 223490 kb/s
>     Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt4
> 70bg/bt709, top coded first (swapped)), 720x576, 221184 kb/s, SAR 16:15 DAR 4:3,
>  25 fps, 25 tbr, 25k tbn, 25k tbc (default)
>     Metadata:
>       creation_time   : 2019-09-18T09:27:36.000000Z
>       handler_name    : Apple Video Media Handler
>       encoder         : 10 bit YCbCr
>       timecode        : 00:58:04:15
>     Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
>     Metadata:
>       creation_time   : 2019-09-18T09:27:36.000000Z
>       handler_name    : Time Code Media Handler
>       reel_name       : Untitled
>       timecode        : 00:58:04:15
>     Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32
> (24 bit), 1152 kb/s (default)
>     Metadata:
>       creation_time   : 2019-09-18T09:27:36.000000Z
>       handler_name    : Apple Sound Media Handler
>     Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32
> (24 bit), 1152 kb/s (default)
>     Metadata:
>       creation_time   : 2019-09-18T09:27:36.000000Z
>       handler_name    : Apple Sound Media Handler
> File 'output.mov' already exists. Overwrite ? [y/N] y
> Stream mapping:
>   Stream #0:2 (pcm_s24le) -> join:input0
>   Stream #0:3 (pcm_s24le) -> join:input1
>   join -> Stream #0:0 (pcm_s24le)
> Press [q] to stop, [?] for help
> Output #0, mov, to 'output.mov':
>   Metadata:
>     encoder         : Lavf58.23.102
>     Stream #0:0: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32, 23
> 04 kb/s (default)
>     Metadata:
>       encoder         : Lavc58.41.101 pcm_s24le
> size=     282kB time=00:00:01.00 bitrate=2309.9kbits/s speed=41.1x
> video:0kB audio:281kB subtitle:0kB other streams:0kB global headers:0kB muxing o
> verhead: 0.256944%
>
> 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
>
> 2. Export the new output.mov with the single stereo track as a WAV, then used the following to make seperate tracks out of the channels: with ffmpeg -i output.mov -c:a pcm_s24le -map_channel 0.0.0 left_merge.wav -c:a pcm_s24le -map_channel 0.0.1 right_merge.wav
>
> 3. Use framemd5s to compare the various wavs to make sure that the same samples are produced in the source and output.
>
> The framemd5s were indeed identical aside from the last sample, which may have had something to do with trimming at 1 second.
>
> is there an easier way to verify that the same audio is produced in the source  audio files as with the merged stereo track?

Once again you are trying to use FFmpeg to check FFmpeg, this may work
in special cases, it cannot work in the general case.
From a quick look, the most likely part of FFmpeg to fail above is the
mov demuxer: Iiuc, you are using it both to create the samples and to
check their correctness - this is simply wrong.
(An example where it may work is when you can create a file that is
bit-identical with the original input file. But we have also discussed
in the past that this is unlikely due to the fact that FFmpeg - even
with lossless encoding - is not a tool for file archiving.)

I believe you can check your workflow with mplayer -demuxer mov
-dumpaudio -aid, most likely also with vlc and GStreamer, maybe even
with afconvert

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".