1

Example 1: ffmpeg -i input.avi -c:v libxvid output.mp4

The code that I get as output is:

ffmpeg -i input_1.avi -c:v libxvid output_1.mp4
ffmpeg version git-2020-02-16-8578433 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, avi, from 'input_1.avi':
  Duration: 00:00:02.53, start: 0.000000, bitrate: 498000 kb/s
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080, 504300 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (libxvid))
Press [q] to stop, [?] for help
Output #0, mp4, to 'output_1.mp4':
  Metadata:
    encoder         : Lavf58.38.101
    Stream #0:0: Video: mpeg4 (libxvid) (mp4v / 0x7634706D), yuv420p, 1920x1080, q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.70.100 libxvid
frame=   76 fps= 41 q=31.0 Lsize=     313kB time=00:00:02.50 bitrate=1024.0kbits/s speed=1.35x
video:311kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.371668%

Example 2:

Maybe the libxvid was not the best example. What if I would use a lossless compression such as x264:

ffmpeg -i input.avi -c:v libx264 -preset veryslow -crf 0 output.mp4

What command do you use if you want to ask ffmpeg to decompress a video file for you?

7
  • I don't understand your question. What kind of output do you want to get? "Decompress" as in an uncompressed, raw video file?
    – slhck
    Commented Mar 26, 2020 at 10:08
  • 1
    Does this answer your question? Can compressed videos be decoded back to their uncompresed original format?
    – harrymc
    Commented Mar 26, 2020 at 10:39
  • As far as I understand: a compressed file could have hidden information in it. For example noise is filtered and suppressed but the information is not necessarily lost. I was wondering that if you would decompress it, if there is still hidden information lost or maybe it can be found again and that the data could look more like the original file.
    – makimaki
    Commented Mar 27, 2020 at 12:51
  • No, that's not how information theory or rate-distortion theory works. Once you filter out noise, it is gone. The information is not present in the output file. There is no way to extract more information than what is encoded.
    – slhck
    Commented Mar 27, 2020 at 13:04
  • 1
    PS I think this is an XY problem (xyproblem.info). What is your real issue? What is your use case? If you explained that better, we could give you a better answer.
    – slhck
    Commented Mar 27, 2020 at 13:56

2 Answers 2

3

Assuming your input file is using 4:2:0 color space, you can decode the (lossily) encoded video and output the raw frames to an AVI container:

ffmpeg -i output.mp4 -c:v rawvideo -pix_fmt yuv420p output.avi

ffmpeg will "decompress" (i.e. decode) the MPEG-4 video stream from the output.mp4 file and write it as raw video to the output.avi file.

Raw video is uncompressed, but since the original video was already compressed using a lossy algorithm (e.g. by libxvid), any quality loss present in output.mp4 will obviously also be present in output.avi. You will just get a much bigger output file.

3
  • Thank you for your reaction. I tried your suggestion and it seems to work. There is only one thing that I do not really understand yet about the file sizes: My uncompressed (original) file is 154000kB, compressed with xvid is 313 kB, and then decompressed with rawivdeo -pix_fmt yuv420p gives a file of size 230858 kB. So the decompressed file becomes bigger than the original file, how is this possible?
    – makimaki
    Commented Mar 27, 2020 at 12:46
  • Please show the output of ffmpeg -i input.avi – edit your original question and include the code, please preview the post to make sure the formatting is correct. Normally you'd expect the same file size for rawvideo.
    – slhck
    Commented Mar 27, 2020 at 13:01
  • Your original video is using gray, which means is does not have any color planes. By encoding it to yuv420p raw video, you get a different output. Hence my introduction "assuming your input file is using 4:2:0".
    – slhck
    Commented Mar 27, 2020 at 13:31
-1

You just compressed (lossly) your original (compressed) avi file in another format. you could do ffmpeg -i output.mp4 -c:v msmpeg4v2 -c:a copy new_avi.avi

Obviously any quality loss in the mp4 is lost forever (you need the original source file to get quality back)

ffmpeg -i output.mp4 -c:v copy -c:a copy output.avi will instead just replace the container (mp4 to avi).

4
  • This will only re-encode the already encoded video with msmpeg4v2, so it'll introduce even more quality loss and definitely will not be "decompressed" in the end.
    – slhck
    Commented Mar 26, 2020 at 10:23
  • All formats used by OP are lossy formats and only way to convert between is re-encoding. Unless it's just a matter of replacing the container that, of course, could be done, but I wouldn't define it as de-compression.
    – DDS
    Commented Mar 26, 2020 at 10:28
  • 1
    AVIs aren't necessarily compressed, they can contain raw frames...
    – Attie
    Commented Mar 26, 2020 at 10:36
  • I wasn't aware of that
    – DDS
    Commented Mar 26, 2020 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .