Log in

View Full Version : Are lossless .mkv files really lossless?


GAP
13th November 2021, 05:32
I found an FFMPEG script for the lossless encoding for .mkv files. The question I have is, are lossless .mkv files really lossless? Or should I stick with .mp4?

nevcairiel
13th November 2021, 10:58
Both MKV and MP4 are just containers. If its lossless depends on what you put into them and how you handle it. In other words, its impossible to say.

VoodooFX
13th November 2021, 16:16
The question I have is, are lossless .mkv files really lossless?
Yes they are lossless.

kedautinh12
13th November 2021, 17:52
Yes they are lossless.

Really?? I download format vp9 in youtube with mkv container and you say it's lossless???

StainlessS
13th November 2021, 18:05
I found an FFMPEG script for the lossless encoding for .mkv files.
Yes they are lossless.
Really??
GAP is taliking about lossless conversion to alternate container, so lossless with respect to original container [assuming that the un-supplied script does it without re-encode].

EDIT: So something like this


setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."


REM Where to place output file, No terminating Backslash.
set OUTDIR=".\OUTPUT"

REM Below, can add SPACE separated source extensions, eg " *.ASF".
FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM) DO (
%FFMPEG% -i "%INDIR%\%%A" -vcodec copy -acodec copy "%OUTDIR%\%%~nxA.MKV"

)


Pause

VoodooFX
13th November 2021, 18:16
Really?? I download format vp9 in youtube with mkv container and you say it's lossless???

Yes. Read the question carefully. There is nothing about "vp9".
I understand OP question as "Will lossless video still be lossless in mkv container?"

GAP
25th November 2021, 18:59
Here is the script in question:

c:a pcm_s16le -c:v libx264rgb -qp 0 -pix_fmt rgb24 -f matroska

I understand OP question as "Will lossless video still be lossless in mkv container?"

I guess that was what I was asking.

VoodooFX
25th November 2021, 20:00
I guess that was what I was asking.
Yeap, you was asking that, but now you are asking different question about script.

I didn't knew it was possible to have RGB in x264. In what colorspace is your input file?

GAP
2nd December 2021, 05:49
The colorspace on my videos are usually RGB according to Mediainfo.

StainlessS
4th December 2021, 01:25
GAP,
the BAT/CMD script in post #5 will simply copy both video and audio streams into MKV, no change [both lossless, uncompressed RGB if uncompressed RGB source, x264 if x264 source etc].

Batch processes all file containers [in INDIR directory] mentioned on this line [can add containers]

REM Below, can add SPACE separated source extensions, eg " *.ASF". # THIS LINE IS COMMENT
FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM) DO (


With destination directory OUTDIR, and output container in BLUE, ie MKV

%FFMPEG% -i "%INDIR%\%%A" -vcodec copy -acodec copy "%OUTDIR%\%%~nxA.MKV"


EDIT:
And if ffmpeg location is already in your environment path, then can change

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

to

REM Where to Find ffmpeg
set FFMPEG="ffmpeg.exe"

Or change the FFMPEG path line to wherever it lives on your system.

EDIT: May fail if SPACES or non ASCII chars in filenames/directories.

Reclusive Eagle
18th January 2022, 20:18
Really?? I download format vp9 in youtube with mkv container and you say it's lossless???

Youtube compresses so the source file that was uploaded was lossless but the file is then compressed to YouTubes standards.

MKV is a container.
It is made to store large amounts of data without compression.

The only way the video stored in MKV's loses data is if the codec is lossy.
Or if its been re-encoded multiple times.

If you render a video into an mkv using a true lossless codec.
Your source is a mirror image of the pre-rendered file.


VP9 is made for website efficiency. Any "mainstream" format made to be viewed is compressed.
So PNG 8 Bit is compressed. JPEG is normally compressed etc.

VP9 is a high efficiency codec. Not a high quality one.
If your source is a 10GB 10 min file and you encode it with VP9 it will probably be reduced to 3GB or less.
I.E Compression