[SUCCESS] Video compressing workflow in Linux?

Started by ivanatora, December 02, 2012, 05:21:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ivanatora

Hello ML users :)

First steps with video here. I have 50D that makes gorgeous videos thanks to ML. I'd like to compress them a bit. I'm going to use video rarely and I don't see myself as a video producer, so a little quality loss is acceptable. I'm shooting in 480p instead of HD.
The resulting MOV files are beautiful, but every step I try to encode these is screwing them really bad. I understand there are going to be compression artifacts, but the results are worse than I expected.
I tried with mencoder in that way:
mencoder -ovc xvid  -xvidencopts bitrate=1000 -o output.avi MVI_1792.MOV
Experimented a bit with the bitrate parameter (btw what is the default bitrate for ML? I haven't tweaked any settings for this). The output video quality varied between "crap" and "very bad".
Then I tried to upload the MOV directly to YouTube and the result was maybe even worse:
http://www.youtube.com/watch?v=t2M0PGaqb8g
The only good thing I saw there is the "reduce camera shake" option. It makes the handheld shot movie very smooth.

How do you proceed with video files in Linux?

1%

I kinda feel like you don't. Linux workflow for editing and even encoding is kinda crappy compared to windows. I tried a few of the OSS NLEs and nothing is up to the quality of commercial products. You can compress some stuff but for editing its no good. Try handbrake for linux if you want to make it easy. Also 480P is really really resized on these cameras so it looks not so good.

gigidread

Hi!
You can try this program: http://www.squared5.com/
It works pretty well with Wine.
Otherwise I use ffmpeg, or Kdenlive for basic editing.
Gigi

ivanatora

What options are you using with ffmpeg? I have it and if I can get a good result with it, it will be wonderful.
Could you post some command line samples?

gigidread

Hi!
I'm using ffmpeg to convert videos from H264 to Mjpeg (to upload on Videostock sites and to edit easily with my old computer), and what I do is to put all the files that I want to convert in a folder and then I run this script (some things are in Italian, just change adapt the address of your folder...)

#!/bin/bash

# Roba da convertire
roba=/home/gigi/Videos/Mjpeg/Convertire/*

# Inizio del ciclo
for file in /home/gigi/Videos/Mjpeg/Convertire/*; do `ffmpeg -i $file -r 30 -s hd1080 -vcodec mjpeg  -qmax 1 -qmin 1 -acodec copy $file.mov` ;done


exit 0;



You can adapt the script changing the quality and the format... Check http://ffmpeg.org/ffmpeg.html#Video-Options

Gigi


Shizuka

just use x264 and be done with it... mjpeg and xvid are outdated codecs (well, if you want to use mjpeg for fast decompression, that's another story)

gigidread

Quote from: Shizuka on December 22, 2012, 10:30:06 PM
just use x264 and be done with it... mjpeg and xvid are outdated codecs (well, if you want to use mjpeg for fast decompression, that's another story)

Unfortunately Mjpeg and Photojpeg are the major codecs accepted for stock videos... I would love to use H264, but I just can't... :-(

ivanatora

Okay, that's weird. I tried your ffmpeg command to compress video, but it resulted in file that was waay bigger than the original :) Ofcourse, I changed -s hd1080 to -s hd480 (since I'm shooting in 480p, there is no need to scale it up).
First, the aspect ration seems wrong. The output video was 852x480, while the original was 640x480, but I assume it is a matter of tunning of the -s parameter.
Second, I got awful white noise in all underxposed parts. Like someone was lit christmas decoration in every shadow :P

The filesize was a bit up, but I assume it was because of the wrong frame size:


-rw-r--r-- 1 ivanatora ivanatora 272M 2012-12-23 22:48 MVI_2355.mov
-rw-rw-rw- 1 ivanatora ivanatora 163M 2012-12-23 20:15 MVI_2355.MOV


Shizuka

Quote from: ivanatora on December 23, 2012, 10:03:29 PM
Okay, that's weird. I tried your ffmpeg command to compress video, but it resulted in file that was waay bigger than the original :) Ofcourse, I changed -s hd1080 to -s hd480 (since I'm shooting in 480p, there is no need to scale it up).
First, the aspect ration seems wrong. The output video was 852x480, while the original was 640x480, but I assume it is a matter of tunning of the -s parameter.
Second, I got awful white noise in all underxposed parts. Like someone was lit christmas decoration in every shadow :P

The filesize was a bit up, but I assume it was because of the wrong frame size:


-rw-r--r-- 1 ivanatora ivanatora 272M 2012-12-23 22:48 MVI_2355.mov
-rw-rw-rw- 1 ivanatora ivanatora 163M 2012-12-23 20:15 MVI_2355.MOV



That's because converting h264 to mjpeg isn't compression, it's decompression (or more precisely, recompression to a less efficient format).

Since you already have ffmpeg, try this:
ffmpeg -i <input file> -acodec aac -vcodec libx264 <output.mp4>

Note that "aac" and "libx264" may differ in your builds of ffmpeg. Use ffmpeg -codecs to find x264 and AAC encoder. Also note that for audio compression, neither of the two ffmpeg encoders (at least in my build: libvo_aacenc, aac) is actually decent. For a decent AAC encoder, you'll need to use neroaacenc.

ivanatora

It seems I don't have ffmpeg compiled with x264:

$ ffmpeg -codecs
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.9-0ubuntu0.10.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Jun 12 2012 16:27:34, gcc: 4.4.3
ffmpeg: missing argument for option '-codecs'

Maybe it is too old version. I will try to get a recent one running on my oldie Ubuntu.

About sound - I don't need any, since 50D doesn't have a hardware mic and records no sound when shooting video.

deleted.account

@ivanatora, the noise in your shadows that you now see I'd hazard a guess is because you've been used to looking at your source files in a media player that doesn't respect the full range flag in the h264 source, so shadows have been crushed and highlights blown, now you've converted the full range luma levels into 16 - 235 because ffmpeg does respect the full range flag so squeezes full levels into 16-235, detail you'd not been seeing is now visible.

You'll notice on ffmpeg CLI it complains of incompatible pixel format yuvj420p - yuv420P with many transcodes from Canon h264.

If you play your original MOVs with ffplay on the CLI you may see what you are now seeing in the transcode.


ivanatora

I followed instructions in this HOWTO and now I'm able to use H264 :)

-rw-rw-rw- 1 ivanatora ivanatora 163M 2012-12-23 20:15 MVI_2355.MOV
-rw-r--r-- 1 ivanatora ivanatora  22M 2012-12-24 12:24 out.mp4

File size decreased about 8 times with almost no quality loss. Thank you, all!

I have one just theoretical question. If I have audio recorded in another file (I could record it with my phone - AMR format, for example), how could I insert it into that video?

EDIT: And after some research I found the answer:


ffmpeg -i audio.wav -i out.mp4 -strict -2 -ar 22050 test.mp4

deleted.account.01

u try sony vegas ? im not fully sure if they have  SV for linux but im pretty sure they are

http://www.youtube.com/watch?v=1eHEAfNFJ0k

turningpointup

There are three methods to compress a large MOV file:

Method one: Convert video to H.264 MP4
Method two: Reduce video Frame Size
Method three: Decrease video Bitrate

Here is a step by step guide on how to compress MOV files with the above methods at: http://www.idealshare.net/video-converter/compress-mov-file.html

It also helps to compress almost all kinds of video files size such as compress MP4 files, compress AVI files, compress WMV files, compress MKV files;

timmdd

HI
I think you can use some third party software to convert the MOV videos into all popular video formats, so i wanna recommend thisHD Video Converter Factory Pro, hope you can try it :D It is quite useful.

Best

markanini

Quote from: timmdd on September 23, 2015, 12:16:33 PM
HI
I think you can use some third party software to convert the MOV videos into all popular video formats, so i wanna recommend thisHD Video Converter Factory Pro, hope you can try it :D It is quite useful.

Best

Quote from: Anedgett on October 27, 2016, 10:22:43 AM
I think the best way to compressing video must meet the next standards: the size get smaller, the video quality must be as original as possible; and the output video must be successfully played on the player. A video converter can perfectly meets the above standards. I used it to convert MKV to PS4 at the first time. With the more times used, I found it can as a DTS converter to convert audio and it can compress the video and audio keeping the original quality. Since the software can automatically set the optimum parameters.
As discussed in previous replies there's plenty of options to place the untouched video and audio streams in to a more compatible format like mp4 and make it playable on devices like PS4. No need to re-encode unless you're short on storage.
Gear: Canon 600D & Magic Lantern Nightly.