1

I have encoded my videos using ffmpeg and H264, and this is my ffmpeg command (2 pass encoding):

ffmpeg -y -i Edited\ Clips/arsenalVScristalPalas.mp4 -movflags faststart -c:v libx264 -x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0:subq=6' -deblock 0:0 -flags +loop -preset slow -tune zerolatency -b:v 2048k -maxrate 2048k -bufsize 3000k -vf "scale=-1280:720" -pass 1 -acodec libmp3lame -b:a 128k -coder 1 -me_range 16 -sc_threshold 42 -bf 10 -qmin 0 -qmax 51 -trellis 2 -rc_lookahead 60 -ss 00:01:00 -t 00:01:00 -f mp4 /dev/null


ffmpeg -i Edited\ Clips/arsenalVScristalPalas.mp4 -movflags faststart -c:v libx264 -x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0:subq=6' -deblock 0:0 -flags +loop -preset slow -tune zerolatency -b:v 2048k -maxrate 2048k -bufsize 3000k -vf "scale=-1280:720" -pass 2 -acodec libmp3lame -b:a 128k -coder 1 -me_range 16 -sc_threshold 42 -bf 10 -qmin 0 -qmax 51 -trellis 2 -rc_lookahead 60 -ss 00:01:00 -t 00:01:00  2pass15.mp4

I need the video to be in the highest quality (at the 2000kbps bitrate). I have another video with the same bitrate (from another source), but It has a better quality than my video. I need to reach that quality.

I used mediainfo to get the encoding options for that video, and here is the information:

General Complete name : arsenalVScristalPalas_hd.mp4 Format
: MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/avc1/mp41) File size : 171 MiB Duration
: 11mn 1s Overall bit rate : 2 164 Kbps Encoded date : UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00 Writing application : Lavf57.63.100

Video ID : 1 Format
: AVC Format/Info : Advanced Video Codec Format profile : Main@L3.1 Format settings, CABAC : Yes Format settings, ReFrames
: 6 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration
: 11mn 1s Bit rate : 2 048 Kbps Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode
: Constant Frame rate : 50.000 fps Color space : YUV Chroma subsampling
: 4:2:0 Bit depth : 8 bits Scan type
: Progressive Bits/(Pixel*Frame) : 0.044 Stream size : 160 MiB (94%) Writing library
: x264 core 148 r2643 5c65704 Encoding settings
: cabac=1 / ref=6 / deblock=1:1:1 / analyse=0x1:0x131 / me=umh / subme=9 / psy=1 / psy_rd=0.40:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=5 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=10 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=300 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=2048 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=2048 / vbv_bufsize=5000 / nal_hrd=none / filler=0 / ip_ratio=1.41 / aq=1:0.60 Language : English Encoded date : UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00

Audio ID : 2 Format
: AAC Format/Info : Advanced Audio Codec Format profile : HE-AAC / LC Codec ID
: 40 Duration : 11mn 1s Duration_LastFrame : -23ms Bit rate mode
: Constant Bit rate : 128 Kbps Channel(s) : 2 channels Channel positions : Front: L R Sampling rate
: 48.0 KHz / 24.0 KHz Frame rate : 23.438 fps (1024 spf) Compression mode : Lossy Stream size : 10.1 MiB (6%) Language
: English Default : Yes Alternate group : 1 Encoded date
: UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00

and this is the information of my video:

General Complete name : 2pass14.mp4 Format : MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/avc1/mp41) File size : 15.4 MiB Duration
: 1mn 0s Overall bit rate : 2 150 Kbps Encoded date : UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00 Writing application : Lavf56.40.101

Video ID : 1 Format
: AVC Format/Info : Advanced Video Codec Format profile : High@L3.2 Format settings, CABAC : Yes Format settings, ReFrames
: 5 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration
: 1mn 0s Bit rate : 2 048 Kbps Width
: 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode
: Constant Frame rate : 50.000 fps Color space : YUV Chroma subsampling
: 4:2:0 Bit depth : 8 bits Scan type
: Progressive Bits/(Pixel*Frame) : 0.044 Stream size : 14.4 MiB (94%) Writing library
: x264 core 148 r2643 5c65704 Encoding settings
: cabac=1 / ref=5 / deblock=1:3:3 / analyse=0x3:0x113 / me=umh / subme=6 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=10 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=300 / keyint_min=25 / scenecut=42 / intra_refresh=0 / rc_lookahead=0 / rc=2pass / mbtree=0 / bitrate=2048 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=2048 / vbv_bufsize=3000 / nal_hrd=none / filler=0 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00 Language
: English Encoded date : UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00

Audio ID : 2 Format
: MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode
: Joint stereo Mode extension : MS Stereo Codec ID : 6B Duration
: 1mn 0s Duration_LastFrame : -1ms Bit rate mode : Constant Bit rate : 128 Kbps Maximum bit rate : 2 048 Kbps Channel(s)
: 2 channels Sampling rate : 48.0 KHz Compression mode : Lossy Stream size
: 938 KiB (6%) Language : English Default : Yes Alternate group
: 1 Encoded date : UTC 1904-01-01 00:00:00 Tagged date : UTC 1904-01-01 00:00:00

is there anything that I am doing wrong?? any suggestions on how to improve my output quality??

and here is a demo of videos,

the video that has a better quality:

https://ufile.io/b7a1b

my video, that I need to improve quality:

https://ufile.io/363f11

  • 1
    Quite a few parameters are different, but for starters, set -rc-lookahead to 60. Try to set as many parameters as you can within x264opts and they will get more reliably flagged if there's a typo. – Gyan Mar 13 '17 at 17:54
  • 1
    What are you using for source material? Has it already been encoded in the past? The quality of lossy compression is HIGHLY dependent on the quality of the source material. If it has been lossy compressed previously, the quality you will get will be significantly lower per bit as loss compounds, generally pretty close to exponentially. – AJ Henderson Mar 13 '17 at 18:48
  • 1
    -tune zerolatency is going to kill quality. It disables b-frames and cabac. – SlimSCSI Mar 14 '17 at 6:22
  • @AJHenderson yes, the source has been encoded before and I expected to have some quality loss, but the other video is also using the same video, but it has a better quality. It has been encoded before with h264 codec, and its lossy. – evan Mar 16 '17 at 10:23
  • @SlimSCSI realy? So I should remove it?? I have enabled cabac with coder 1, and when I get video information with mediainfo, it says cabac is set to 1. – evan Mar 16 '17 at 10:26

Your Answer

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

Browse other questions tagged or ask your own question.