VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Hi, how can I get the best (or good) results with FFMPEG command line MPEG-2 Video codec? I want to keep the bitrate at 5000kbps. I know 5000kbps is low for MPEG-2, I don't want a perfect picture, I just want it to look better. Here's my code.

    for %%a in ("*.*") do ffmpeg -i "%%a" -s 704x576 -pix_fmt yuv420p -r 25 -codec:v mpeg2_qsv -vf setfield=tff -flags +ilme+ildct -g 1 -b:v 5000k -minrate:v 0k -maxrate:v 9000k -bufsize:v 1835008 -scan_offset 1 -ar 48000 -acodec ac3 -b:a 384k -f dvd -muxrate 10080k -packetsize 2048 "DVD %%~na.vob"
    pause
    Quote Quote  
  2. The -g 1 is a big problem and likely your main issue, that means intra encoding (no p, b frames) . You would need many times more bitrate for it to look ok

    Use -g 15 for PAL dvd

    You can try multipass encoding too

    You can look at this thread for supposedly optimal ffmpeg mpeg2 encoding. (But the results are still worse than other mpeg2 encoders)
    http://forum.doom9.org/showthread.php?t=174620
    Quote Quote  
  3. Thanks for that tip, the video looks better using -g 15. But now I can't control my bitrate (outputting around 4000kbps no matter what my bitrate setting is).
    Quote Quote  
  4. Originally Posted by shampistols69 View Post
    Thanks for that tip, the video looks better using -g 15. But now I can't control my bitrate (outputting around 4000kbps no matter what my bitrate setting is).
    Not sure, you're using mpeg2_qsv the intel quick sync encoder, not the software mpeg2 ffmpeg encoder - maybe it's a limitation ? Try -c:v mpeg2video for the software encoder
    Quote Quote  
  5. To get the requested bitrate you have to use two pass encoding (I don't think the mpeg2_qsv encoder supports this). Or you can try setting the min, max, and average all to the same 5000k.
    Last edited by jagabo; 21st Sep 2024 at 22:52.
    Quote Quote  
  6. Thanks. My results are much better now.
    Quote Quote  
  7. So what are you doing now? Which "solution" did you pick?
    Quote Quote  
  8. for %%a in ("*.*") do ffmpeg -i "%%a" -s 720x576 -pix_fmt yuv420p -r 25 -codec:v mpeg2video -vf setfield=tff -flags +ilme+ildct -g 15 -b:v 5000k -minrate:v 5000k -maxrate:v 5000k -bufsize:v 1835008 -scan_offset 1 -ar 48000 -acodec ac3 -b:a 384k -f dvd -muxrate 10080k -packetsize 2048 "DVD %%~na.vob"
    pause
    Image Attached Files
    Last edited by shampistols69; 22nd Sep 2024 at 11:15.
    Quote Quote  
  9. @ shampistols69.
    Did the last code give you the results you wanted ?
    The 5000 bitrate for example.

    Since the change in the g setting helped.
    Try using twice the framerate for this.
    From the code you posted with -r 25 that would be -g 50.

    You might read this topic also:
    https://forum.videohelp.com/threads/404452-How-to-use-ffmpeg-to-de-telecine-%28de-inte...PAL-to-PAL-25p
    Last edited by cholla; 22nd Sep 2024 at 10:53.
    Quote Quote  
  10. So you switched to the software encoder and constant bitrate. If you want better overall quality you should switch to 2-pass encoding. That will get you the size (bitrate) you want with bits allocated as needed (ie, shots that need more than 5000 kbps will get more, shots that need less will get less, but all will remain between the specified min and max bitrates). So, run ffmpeg twice but add "-pass 1" to the first pass then "-pass 2" to the second.
    Quote Quote  
  11. Originally Posted by cholla View Post
    Since the change in the g setting helped.
    Try using twice the framerate for this.
    From the code you posted with -r 25 that would be -g 50.
    It appears he wants DVD compatible encoding so the GOP size is limited to 15 frames.
    Quote Quote  
  12. REPLY TO cholla

    That's confusing.

    Did you want me to change it to this? It's not DVD compliant (50fps). It made my screen crash and I had to restart my laptop.

    for %%a in ("*.*") do ffmpeg -i "%%a" -s 720x576 -pix_fmt yuv420p -r 50 -codec:v mpeg2video -vf setfield=tff -flags +ilme+ildct -g 50 -b:v 5000k -minrate:v 5000k -maxrate:v 5000k -bufsize:v 1835008 -scan_offset 1 -ar 48000 -acodec ac3 -b:a 384k -f dvd -muxrate 10080k -packetsize 2048 "DVD %%~na.vob"
    pause

    Keeping 25fps and using -g higher than 15 didn't make any noticeable change to me.

    The code above your comment gave me consistent 5000kbps. I'll attach a sample so you can see the result. The source is progressive 25fps, I used the code to make it DVD compliant.
    Quote Quote  
  13. Originally Posted by jagabo View Post
    So, run ffmpeg twice but add "-pass 1" to the first pass then "-pass 2" to the second.
    Thanks for the tip. Are your DMs open?
    Quote Quote  
  14. Originally Posted by jagabo View Post
    It appears he wants DVD compatible encoding so the GOP size is limited to 15 frames.
    @jagabo,
    Is there a way to detect the -g used in a video ?
    More specifically a .vob

    If a software like AVStoDVD was use to create a DVD & "Keep MPEG2 DVD Compliant Video:" was checked.
    Would it correct the -g ?
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!