These forums are archived

See this post for further info

get_iplayer forums

Forum archived. Posting disabled.

Re-encode HD to 25fps with ffmpeg

user-2502

Hi, first of all thanks for a great utility.

A couple of small suggestions:

It would be nice to be able to download content at 1280x720 @ 25fps, not sure why anyone would want 50fps other than sport. I could convert 50>25fps (with ffmpeg?) but it's an extra hassle.

Is there an option to set the title to nothing in the mp4 file? I just want to use the filename as the title so I have to go into file properties/details and delete the title every time.

user-1893

ffmpeg can alter the title field without any need to re-mux the file (so it is fast).

I find that processing the download, keeping the frame rate at 50fps, but reducing the bit rate (to about 1.5Mbits/sec) halves the file size - but it's very slow - since a large file (4GB for a 2hr programme) has to be remuxed.

I see no noticeable difference on the output, compared with either SD/HD programmes.

user-2502

I found this works, but it's very slow:

ffmpeg -i input.mp4 -preset medium -crf 20 -r:v 25 -c:a copy output.mp4

crf defines the quality: 23 is default, 17 is effectively lossless. From a quick test 1280x720 converted to 25fps (crf=21) is about the same bitrate as SD 960x540 25fps, so crf=19/20 is probably about right.

I guess I could create a script to convert multiple files and run it overnight.

Sport I can understand, but I wonder why the BBC encode TV shows/drama at 50fps?

user-2502

p.s. here's a powershell script to convert multiple files:

$files = Get-ChildItem *.mp4
foreach ($file in $files)
{
$source = $file.BaseName + $file.Extension
$target = $file.BaseName + "_25fps" + $file.Extension
$bin = "ffmpeg.exe"
$args = "-i $source -preset medium -crf 20 -r:v 25 -c:a copy $target"
Write-Output "$bin $args"
Start-Process -FilePath $bin -ArgumentList $args -Wait
}

user-2502

p.s. add some quotes to deal with spaces in filenames:

$source = "`"" + $file.BaseName + $file.Extension + "`""
$target = "`"" + $file.BaseName + "_25fps" + $file.Extension + "`""

user-2212

(08-01-2020, 03:30 PM)I find that processing the download, keeping the frame rate at 50fps, but reducing the bit rate (to about 1.5Mbits/sec) halves the file size - but it's very slow - since a large file (4GB for a 2hr programme) has to be remuxed.

I see no noticeable difference on the output, compared with either SD/HD programmes.

... and to add to that, I found remuxing to a similar bit rate at both 50fps and then 25fps gave little difference in file size or quality either, making me wonder if the source itself [in my samples] really is 50fps or just puffed out to make things future proof.

2GB per hour does seem excessive for a 720 HD program. Anything I want to keep I now remux down to H.265, but offline, as that is REALLY slow but does give tiny files for a given subjective quality if your AV stuff supports it.

user-2502

Just a quick follow up, I discovered FFmpeg can use hardware acceleration if you have a suitable graphics card (Kepler and above).

With my NVidia GTX 760, encoding a 6 min 720 50fps sample to 720 25fps in software takes about 3 mins, whereas in hardware it takes <1 min and the CPU is only 40% utilised.

With software encoding the CPU runs continuously at 100%, but you can cap it at say 75% in power options / advanced / processor power mgt. It reduces volts, clock speed and temps, but obviously takes longer.

To use hardware acceleration, just replace the default software codec (libx264) with the gpu one (h264_nvenc):

SW:
ffmpeg -i input.mp4 -c:v libx264 -c:a copy -r:v 25 -preset medium -crf 19 output.mp4

HW:
ffmpeg -i input.mp4 -c:v h264_nvenc -c:a copy -r:v 25 -preset medium -crf 19 output.mp4

I guess doing the encoding on a RAM drive might also prolong the life of your SSD...

These forums are archived

See this post for further info