lossless vs corruption

By: Dave Rice

18   0   631

Uploaded on 06/20/2014

Lossless codecs try to show an animated mandelbrot pattern while getting assaulted with data corruption. Starring: uyvy422, v210, Flash Screen Video, JPEG-LS, Lossless JPEG, Lossless jpeg2000, QuickTime Animation, FFv1 Version 1, Targa, Sun Rasterfile, and huffyuv.

Notes on creating this video: http://gist.github.com/dericed/87dcfc43108bcb00049f

Comments (3):

By anonymous    2017-09-20

How to create video and audio noise with ffmpeg

Using /dev/urandom

You can use /dev/urandom to generate video and audio noise (Windows users will have to use the geq filter as shown below). This is a small screeenshot, but of course the video will not be a static image:

colored noise

ffmpeg -f rawvideo -video_size 1280x720 -pixel_format yuv420p -framerate 25 \
-i /dev/urandom -ar 48000 -ac 2 -f s16le -i /dev/urandom -codec:a copy \
-t 5 output.mkv

This will create color video noise. If you just want black and white you can add the hue filter.

mono noise

ffmpeg -f rawvideo -video_size 1280x720 -pixel_format yuv420p -framerate 25 \
-i /dev/urandom -ar 48000 -ac 2 -f s16le -i /dev/urandom -codec:a copy \
-t 5 -vf hue=s=0 output.mkv

Using the nullsrc video source

According to the documentation:

The nullsrc source returns unprocessed video frames. It is mainly useful to be employed in analysis/debugging tools, or as the source for filters which ignore the input data.

Which basically means that it is useful as a "blank canvas" for other filters, such as the background that will be covered up when placing two videos side-by-side, but when used alone it can create odd somewhat random (but sometimes boring) effects:


ffmpeg -f lavfi -i nullsrc=s=1280x720 -t 60 output.mkv

Using filters

Alternatively, the geq (video "generic equation") filter (with nullsrc as its "blank canvas") can create video noise similar to the examples above, and the aevalsrc filter can create white noise audio:

mono noise

ffmpeg -f lavfi -i nullsrc=s=1280x720 -filter_complex \
"geq=random(1)*255:128:128;aevalsrc=-2+random(0)" \
-t 5 output.mkv

Note that this will create black and white video noise.

Adding random visual noise and errors to an existing video

Using the noise bitstream filter:

original imagemessed up with noise bsf
Original and screwed up images. The result is very dynamic, so a single image does not fully capture the effect.

ffmpeg -i input.mp4 -codec:v huffyuv -bsf:v noise -codec:a copy noise.mkv

According to the documentation:

A bitstream filter operates on the encoded stream data, and performs bitstream level modifications without performing decoding.

This bitstream filter can accept a value to increase or decrease the amount of noise. It's inverse, so a higher number is less noise, and 1 is the lowest number and therefore the most noise. You will need to experiment to see what works best for you.

This first example stream copied the audio and only glitched the video, but you can apply the filter to both audio and video by removing the stream specifier:

ffmpeg -i input.mp4 -codec:v huffyuv -c:a pcm_s16le -bsf noise=1000000 noise.mkv

Or provide separate values for video and audio:

ffmpeg -i input.mp4 -codec:v huffyuv -c:a pcm_s16le -bsf:v noise=1000000 -bsf:a noise=100 noise.mkv

This seems to work well with rawvideo or huffyuv for video, and pcm_s16le for audio, but I recommend experimenting. See lossless vs corruption (notes) for a video showing how different encoders react to noise corruption.

You can then re-encode this to a more portable or common format:

ffmpeg -i noise.mkv -codec:v libx264 -pix_fmt yuv420p output.mkv

See the H.264 and AAC encoding guides on the FFmpeg Wiki for more encoding info.

Forcing a pixel format

You can lie to ffmpeg and make it think that the colorspace and chroma subsampling is different that it actually is resulting in strange, error-like effects.

original imagelying to ffmpeg
Original and screwed up images. The result can be very dynamic, so a single image does not fully capture the effect.

  1. Probe your input.

    ffmpeg -i original.mp4

    Note the frame rate and video frame size.

  2. Refer to ffmpeg -pix_fmts and choose one of the available formats such as yuv420p16le.

  3. Create rawvideo and pipe it to another ffmpeg instance:

    ffmpeg -loglevel error -i original.mp4 -f rawvideo - | ffmpeg -y -f rawvideo -framerate 25 -video_size 1280x720 -pixel_format yuv420p16le -i - -pix_fmt yuv420p video.mp4

    The -framerate and -video_size values were copied from the original input file information shown in the console output of step 1. Of course you can also manipulate these for various effects.

  4. Mux audio if desired

    ffmpeg -i video.mp4 -i original.mp4 -map 0 -map 1:a -c copy output.mp4

Original Thread

By anonymous    2018-07-02

I have seen this video on youtube which apply ffmpeg noises by these commands, but when I tried to apply them on my video it does not work

    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v ffv1 -g 1 -bsf noise -t 10 ffv11v1.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v ffv1 -level 3 -g 1 -bsf noise -t 10 ffv1v3.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v v210 -bsf noise -t 10 -pix_fmt yuv422p10le v210.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v rawvideo -bsf noise -t 10 -pix_fmt uyvy422 -vtag 2vuy uyvy422.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v libx264 -crf 0 -qp 0 -bsf noise -t 10 -pix_fmt yuv420p h264.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v qtrle -bsf noise -t 10 qtrle.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v sunrast -bsf noise -t 10 sunrast.avi
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v targa -bsf noise -t 10 targa.avi
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v utvideo -bsf noise -t 10 utvideo.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v xwd -bsf noise -t 10 xwd.avi
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v zmbv -bsf noise -t 10 zmbv.avi
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v flashsv -bsf noise -t 10 flashsv.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v huffyuv -bsf noise -t 10 -pix_fmt yuv420p huffyuv.mov
    ffmpeg -f lavfi -i mandelbrot=s=320x240 -c:v libx264 -crf 0 -qp 0 -bsf noise -t 10 -pix_fmt yuv420p h264.mov

like this command :

ffmpeg -i /home/user/video.mp4 -codec:v huffyuv -f lavfi -c:v sunrast -bsf noise -t 10 videoNoised.avi

Original Thread

Submit Your Video

If you have some great dev videos to share, please fill out this form.