1

I have a theora/vorbis ogg video file. However, what I notice is that, using gzip/xz can reduce the file size by 20%/75%. Therefore, I suspect the internal format does not really compress the contents well. Is there a way to compress the video/audio more losslessly without using an external compression format? A solution using ffmepg is preferred.

Output of mediainfo:

Format                                   : Ogg
File size                                : 90.9 MiB
Duration                                 : 27 min 52 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 456 kb/s
Writing application                      : Lavf57.56.101

Video
ID                                       : 1911251410 (0x71EB61D2)
Format                                   : Theora
Duration                                 : 27 min 52 s
Bit rate                                 : 298 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 30.000 FPS
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.005
Stream size                              : 59.4 MiB (65%)
Writing library                          : Lavf57.56.101

Audio
ID                                       : 2001534440 (0x774CFDE8)
Format                                   : Vorbis
Format settings, Floor                   : 1
Duration                                 : 27 min 52 s
Bit rate mode                            : Variable
Bit rate                                 : 131 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Stream size                              : 26.1 MiB (29%)
Writing library                          : Lavf57.56.101
1
  • 2
    When I compress a video like that with 7-Zip, it’s practically the same size. There must be something wrong with your video file or you somehow saw a wrong file size reported.
    – Daniel B
    Jun 20 '17 at 9:30
2

The short answer is: no.

When you compress your file into an archive (such as zip, 7z, rar, gzip,...), the algorithm is looking for ways to store the given information in a shorter way. This is for example done via Huffman coding, where the algorithm checks for the frequency of values and then stores the mot frequent value in the shortest number, the second most used in the second smallest number,... (this is extremely oversimplified - please read the linked wikipedia article for a better explanation. Also, of course, the Huffman coding is only one - very simple - example of compression). This also explains why compressing an archive often further reduces the file-size.

So your 75% file size reduction is because the compression tool finds a more efficient way to store the information than the video- and audioencoder did. However, usually, there is no way to tell an encoder how to store the information, as this is something that is specified in the standard. Sometimes a newer version of the encoding program can help because of better implementations of the standard, but usually, that just applies for brand-new codecs.

Your video-player, however, can't handle multiple compressions simultaneously. I think that this is mostly because it would need quite some ressources (both RAM and CPU) to decompress the archive-file and then read the file itself. Also, it would still need to decompress the whole thing first, just as you need to do, because it is quite difficult to estimate from a file you don't have where which stream is stored and so on and so forth.

So if you need to work with theora/vorbis, there isn't much you can do about it. Otherwise, if file-size is your priority, I would recommend looking into VP8 / VP9 / x264 / x265. If you want to go the VP9-way, I recommend something along FFmpeg's Encode/VP9-Guide (linked just above):

ffmpeg -i <input> -c:v libvpx-vp9 -crf 15 -b:v 0 -c:a copy <output>

replace <input> and <output> with the respective file-names (and file-extensions). Both *.mkv and *.webm work (I only tried these two), however, *.webm seems to require Vorbis as an audio codec (e.g. -c:a libvorbis -q:a 6 instead of -c:a copy), where *.mkv doesn't seem to have requirements. -crf specifies a constant rate factor (imagine it as "constant visual quality"), where lower values mean better quality.

All of the above of course assumes that your files were encoded efficiently (e.g. not specifying a bitrate of 6 Gb/s) and with a properly working program. I for one have never been able to compress much out of any lossy compressed audio- or videofile (but I seldomly use theora or vorbis).

12
  • Thank you for the answer. In this case, can you provide a way to convert the internal encoding to VP9?
    – xuhdev
    Jun 20 '17 at 16:22
  • Along FFmpeg's Encode/VP9 - Guide: ffmpeg -i <input> -c:v libvpx-vp9 -crf 15 -b:v 0 -c:a copy <output>, where <input> and <output> are to be replaced with the correlating files. -crf specifies a constant rate factor (imagine it as "constant visual quality") and of course, you can always change the audio-codec (-c:a), too.
    – flolilo
    Jun 20 '17 at 16:59
  • I got the following error: [libvpx-vp9 @ 0x555641b6e1c0] v1.6.1 [ogg @ 0x555641b64980] Unsupported codec id in stream 0 Could not write header for output file #0 (incorrect codec parameters ?): Invalid argumentStream mapping: Stream #0:0 -> #0:0 (theora (native) -> vp9 (libvpx-vp9)) Stream #0:1 -> #0:1 (copy) Last message repeated 1 times
    – xuhdev
    Jun 20 '17 at 20:55
  • Without the code you used, I can't even guess at what's wrong. I tried the code myself and on my machine, it works as expected.
    – flolilo
    Jun 20 '17 at 21:50
  • The code is exactly what you showed ffmpeg -i <input> -c:v libvpx-vp9 -crf 15 -b:v 0 -c:a copy <output>
    – xuhdev
    Jun 22 '17 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.