You are not logged in.
I have a point-and shoot camera that does 1080p hi-def video (Panasonic DMC-SZ7) --
It creates files in
/mnt/camera/PRIVATE/AVCHD/BDMV/STREAM. For example:
% ls /mnt/camera/PRIVATE/AVCHD/BDMV/STREAM
total 3.8G
-rwx------ 1 asdf asdf 1.3G Aug 10 08:24 00000.MTS*
-rwx------ 1 asdf asdf 927M Aug 10 11:28 00001.MTS*
-rwx------ 1 asdf asdf 1.6G Aug 10 20:05 00002.MTS*Here's the `mediainfo` dump for one of those files:
General
ID : 0 (0x0)
Complete name : 00000.MTS
Format : BDAV
Format/Info : Blu-ray Video
File size : 1.30 GiB
Duration : 11mn 12s
Overall bit rate mode : Variable
Overall bit rate : 16.6 Mbps
Maximum Overall bit rate : 18.0 Mbps
Video
ID : 4113 (0x1011)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : No
Format settings, ReFrames : 2 frames
Format settings, GOP : M=3, N=15
Codec ID : 27
Duration : 11mn 12s
Bit rate mode : Variable
Bit rate : 15.7 Mbps
Maximum bit rate : 16.2 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.253
Stream size : 1.23 GiB (95%)
Audio
ID : 4352 (0x1100)
Menu ID : 1 (0x1)
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : 129
Duration : 11mn 12s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 15.4 MiB (1%)
Text
ID : 4608 (0x1200)
Menu ID : 1 (0x1)
Format : PGS
Codec ID : 144
Duration : 11mn 11sAs you can see, 11 minutes of video at 30 FPS takes up just over 1.5GB.
My question: is there a more efficient encoding that would require less space but not lose much quality?
I have handbrake, ffmpeg, etc installed but I really don't understand this.
% whereis whatis whence which whoami whois who
Offline
Well, the easiest example would be
ffmpeg -i /mnt/camera/PRIVATE/AVCHD/BDMV/STREAM/00000.MTS output.mkvIn this example I chose the format "mkv". In this case ffmpeg chosed x264 for video and ogg vorbis for audio. The quality is quite nice, good enough for many people.
Offline
So, thanks -- I modified it a little bit and I think I understand it now.
% ffmpeg -threads 8 -i 00000.MTS -codec:s copy -codec:v copy -codec:a flac 00000.mkv8 threads for parallelization, subtitle copy, video copy, convert audio to flac and put it an matroska container.
Thanks!
% whereis whatis whence which whoami whois who
Offline
If your goal is to decrease the size, you should look into x264 and try to work the video down to good size/quality ratio. I would not transcode to anything other than H.264 though as loss of quality will increase. 16.2 Mbp/s is most likely gigantic overkill, so you have room to play. You'll need to take some extra steps if you intend to keep Blu-Ray compatibility though. I've never done it, so I don't know what those steps are.
If it were me, I'd just copy the audio codec as it is. You probably made it bigger by going to flac and the quality is exactly the same. Matroska containers, as well as mp4, can handle AC3.
Last edited by skottish (2013-08-11 22:31:48)
Offline
You're right, using flac increased the size but not by much.
I went with flac b/c @sekret's suggested incantation had a vorbis default, which probably won't work if I share it with someone on a non-*nix system.
Anyway, you were right -- this spell with the libx264 video codec:
ffmpeg -threads 8 -i 00000.MTS -codec:s copy -codec:v libx264 -codec:a copy 00000.mkvReduced the size from 1.3G to 346M. Thanks!
% whereis whatis whence which whoami whois who
Offline
You're right, using flac increased the size but not by much.
I went with flac b/c @sekret's suggested incantation had a vorbis default, which probably won't work if I share it with someone on a non-*nix system.
Anyway, you were right -- this spell with the libx264 video codec:
ffmpeg -threads 8 -i 00000.MTS -codec:s copy -codec:v libx264 -codec:a copy 00000.mkvReduced the size from 1.3G to 346M. Thanks!
You're welcome.
I'm curious, at that big of a drop how's the quality? What's the output of mediainfo on the new file?
Offline
ffmpeg -threads 8 -i 00000.MTS -codec:s copy -codec:v libx264 -codec:a copy 00000.mkvReduced the size from 1.3G to 346M. Thanks!
I must be missing something. This command converted my 26 MB MTS file (Canon Vixia, 1080p) to a 44 MB MKV file.
Does anyone know why?
Offline
I'm curious, at that big of a drop how's the quality?
Not discernably better or worse. Certianly acceptable for my purposes, no surprises.
What's the output of mediainfo on the new file?
General
Unique ID : 215024101460296907370475472157250113814 (0xA1C422B52828C4B6AB74501A60E35116)
Complete name : 00000.mkv
Format : Matroska
Format version : Version 2
File size : 345 MiB
Duration : 11mn 12s
Overall bit rate : 4 309 Kbps
Writing application : Lavf55.12.100
Writing library : Lavf55.12.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 11mn 12s
Bit rate : 4 031 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.065
Stream size : 323 MiB (94%)
Writing library : x264 core 133 r2339 585324f
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Default : Yes
Forced : No
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 11mn 12s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 15.4 MiB (4%)
Default : Yes
Forced : No
Text
ID : 3
Format : PGS
Codec ID : S_HDMV/PGS
Codec ID/Info : The same subtitle format used on BDs/HD-DVDs
Default : Yes
Forced : No% whereis whatis whence which whoami whois who
Offline
@print,
Thanks. That actually looks pretty good. Please read below for some ideas.
print wrote:ffmpeg -threads 8 -i 00000.MTS -codec:s copy -codec:v libx264 -codec:a copy 00000.mkvReduced the size from 1.3G to 346M. Thanks!
I must be missing something. This command converted my 26 MB MTS file (Canon Vixia, 1080p) to a 44 MB MKV file.
Does anyone know why?
FFmpeg is using *some* defaults for x264. When print started with a gigantic file at 16 Mbp/s, no matter what happens, the defaults are going to reduce its size. If your camera is shooting in H.264, then more than likely the quality is lower than FFmpeg's defaults for x264.
I highly recommend that if one is going to encode H.264 using x264, that they get to learn at least its preset and tune options (not FFmpeg's presets). As well, following this matrix so that you're producing standards compliant H.264 files will save headaches with distribution (for instance with QuickTIme):
http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
Last edited by skottish (2013-08-12 03:26:44)
Offline
ffmpeg uses the x264 presets, tunes, and profiles directly. Defaults are "-crf 23 -preset medium". See the FFmpeg and x264 Encoding Guide for more info.
Offline