jsmpeg icon indicating copy to clipboard operation
jsmpeg copied to clipboard

Mpeg1 Video bad quality

Open hadongtung opened this issue 7 years ago • 7 comments

Dear ... I'm so intersting with this project. I tryed encode video from mp4 - h264 format to Mpeg1-TS by guide. And my video output's quality is very bad. plz helpme, the best way to encode video with better quality?

My file source.zip

My output out.zip

And my ffmpeg command: ffmpeg -i source.mp4 -f mpegts -codec:v mpeg1video -codec:a mp2 -b 0 out.ts

Thank you so much!

hadongtung avatar Mar 09 '17 10:03 hadongtung

There is a -q option to use fixed quality scale. And if I remember right 1 is the best quality, and 31 the worst.

ffmpeg -i source.mp4 -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -q 1 out.ts

WebMaestroFr avatar Mar 09 '17 15:03 WebMaestroFr

@WebMaestroFr
Thank you so much! We tryed your method, it's realy good. Thank you!

hadongtung avatar Mar 10 '17 05:03 hadongtung

@WebMaestroFr Can you help me once again 👍 !!!!!

  • I download video from youtube with bellow infomation: size: 44MB resolution = 1920x1080 , bitrate = 125k, audio sample rate = 44khz

  • Then i resize video to 640x360 by adobe video encoder. Output: size: 86MB resolution: 640x360 bitrate: 157k audio: 48khz

  • Then in transcode 360p to MPG1-TS by command: ffmpeg -i source.mp4 -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -q 1 out.ts

Ouput: Size: 62MB resolution: 640x360 bitrate: 384k audio: 48khz

So i think the reason which output size 360P MPEG1-TS larger than Youtube 1080P is bitrate. (It's only my think :) ).

Can you help me the way to reduce video size for MPEG1-TS output but video quality still good?

Thank you so much!

hadongtung avatar Mar 11 '17 02:03 hadongtung

Can you help me the way to reduce video size for MPEG1-TS output but video quality still good?

No. the size of MPEG1 will be much larger for the same quality of other formats like h264.

zz85 avatar Mar 11 '17 03:03 zz85

You're setting -q 1, which is the best possible quality. Try setting it to 4 or 8 instead. Or set a fixed bitrate for the video instead (eg.: -b:v 1m for 1mbit/s).

@zz85 is of course right: you can't get the same quality and resolution as H264 or other modern codecs at the same size with MPEG1.

Also, ffmpeg can resize video files, so there's no need to go through adobe video encoder or any other programs:

ffmpeg -i source.mp4 -s 640x360 -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -q 4 out.ts

phoboslab avatar Mar 11 '17 21:03 phoboslab

There is a -q option to use fixed quality scale. And if I remember right 1 is the best quality, and 31 the worst.

ffmpeg -i source.mp4 -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -q 1 out.ts

Thanks, It's worked!

XBStation avatar Jun 16 '20 05:06 XBStation

I just want to add that sometimes i am experiencing a better quality ( less visible blocking artifacts ) with a two pass encoding, for example :

ffmpeg -y -i test.webm -c:v mpeg1video -b:v 1000k -pass 1 -an -f null /dev/null &&
ffmpeg -i test.webm -c:v mpeg1video -b:v 1000k -pass 2 -c:a mp2 -b:a 128k twopass.ts

Frames from Spring ( https://www.blender.org/press/spring-open-movie/ ) I encoded with low 1000k bitrate to underline the difference ( not all scenes or files/bitrate have this improvement ). Upper frame 1 pass, bottom frame 2 pass :

Screenshot from 2020-10-09 16-32-37

AndreaMonzini avatar Oct 09 '20 14:10 AndreaMonzini