ffmpeg parameter to compress h.262 videos (TV-TS-Stream)

Gloster

Member
Joined
Feb 7, 2024
Messages
134
Reaction score
23
Credits
1,236
Compression of h.262 (TV-TS-Stream e.g.: RTL ...) to h.265 (libx265), crf 18, additional I use
-vf yadif,nlmeans="1.4:7:5:3:3"
1. yadif if interlace then to 25p (in the example below not used)
2. nlmeans to reduce noise
Video: mpeg2video yuv420p(tv, progressive), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn

My intention is to compress the video to half the size, but the results, checked with vivictpp are not acceptable. The less quality after compression will be clearly seen.
On the other hand, TV-TS-Stream HD 720p (h,264), compressed to 1/4 via libx265 (crf 15 - 18), also checked with vivictpp, no difference could be seen, subjective same quality.

No idea what to do, to compress h.262 videos. If I reduce crf, the reduced size of the compressed video is not acceptable (200-300MB) in respect to loss of quality.
 



To h.264
Code:
ffmpeg -i input.ts -vf "yadif,nlmeans=1.4:7:5:3:3" -c:v libx264 -preset slow -crf 18 -c:a aac output.mp4

To h.265
Code:
ffmpeg -i input.ts -vf "yadif,nlmeans=1.4:7:5:3:3" -c:v libx265 -preset slow -crf 18 -c:a aac output.mp4

You can also try "two-pass" encoding.
Code:
ffmpeg -i input.ts -vf "yadif,nlmeans=1.4:7:5:3:3" -c:v libx264 -b:v 1000k -pass 1 -an -f mp4 /dev/null && \
ffmpeg -i input.ts -vf "yadif,nlmeans=1.4:7:5:3:3" -c:v libx264 -b:v 1000k -pass 2 -c:a aac output.mp4

If that's not enough, you can try to reduce scaling.

Code:
ffmpeg -i input.ts -vf "yadif,nlmeans=1.4:7:5:3:3,scale=640:480" -c:v libx265 -preset slow -crf 18 -c:a aac output.mp4
 
or you could convert mp2 to mp4 [assuming the tv is mpeg] then try compressing
 
This page did not help me :


I search for parameter especially for h.262 + non square pixels (see above SAR 64:45).
 
You might want to check out HandBrake.
https://handbrake.fr/

1737249804006.gif
 
HandBrake use the same libraries (e.g.: libx265) as ffmpeg. Also it has problems with non square pixels (similar as like Avidemux), the video will be transformed to square pixels (a former problem of vivictpp, refer to
https://github.com/vivictorg/vivictpp/issues/51. Some pictures as example you will see.)

But I did check the used filter of HandBrake, an interesting filter "unsharp". I did check it with ffmpeg :
Bash:
#!/bin/sh
for f in *.ts; do ffmpeg -y -i "$f" -map 0:v -map 0:a -vcodec libx265 -crf 21 -preset slow -vf nlmeans="1.4:7:5:3:3",unsharp="3:3:1.0" -c:a copy "$(basename "$f" .ts).mkv";done

The filter unsharp will increase the file size, crf 21 (former value18) will decrease the size.
But I got better video results with crf 21 + unsharp="3:3:1.0" compared with crf 18 without unsharp filter (checked with vivictpp). Also the size of the video will be reduced by 15% compared with crf 18 only.
But the encoding time will be increased, approximately by < 5%.
 
Last edited:
Also the filter unsharp did not help. The video complete encoded, with crf21 + unsharp its nearly the same size as with crf 18 only.
 

Members online


Latest posts

Top