phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.36k stars 1.43k forks source link

Mpeg1 Video bad quality #140

Open hadongtung opened 7 years ago

hadongtung commented 7 years ago

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!

WebMaestroFr commented 7 years ago

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
hadongtung commented 7 years ago

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

hadongtung commented 7 years ago

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

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!

zz85 commented 7 years ago

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.

phoboslab commented 7 years ago

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
XBStation commented 4 years ago

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!

AndreaMonzini commented 4 years ago

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