Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th September 2014, 03:24   #1  |  Link
agressiv
Registered Loser
 
agressiv's Avatar
 
Join Date: Dec 2004
Posts: 117
ffmpeg.exe as a general purpose encoder

I'm encoding all of my "extras" from various blu-rays to x264 or HEVC via ffmpeg.exe since, well, I don't care that much about cropping, indexing or the like, and I'm just scripting them in powershell without much thought.

What limitations does ffmpeg have on conversion versus using indexing and avisynth? Does it have just a greater chance at failure, similar to using something like DirectShowSource() ? I'm able to do a yadif (which I was surprised at) for some interlaced content, so it certainly isn't lacking in features.

I've never used ffmpeg.exe for a movie, but I'm curious to see what problems people have run into if they don't have anything they really need to do in avisynth scripts.

(Forgive me if this is in the wrong forum!)
agressiv is offline   Reply With Quote
Old 10th September 2014, 04:33   #2  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
ffmpeg is insanely powerful, and has become much more so since the introduction of avfilter; the x264 in it is the same, and the decoder is the same as LWlibav, ffms, and many directshow decoders (like LAV filters). What it can't do is fix badly broken transfers, but for everything else, it works just as well as a typical "Input->IVTC/Deint->optional light denoise or sharpen" Avisynth script, and it can sometimes be faster. The biggest downside is the plethora of command-line options that combine everything you'd otherwise do into one long line, but if you're scripting, you only have to figure them out once.
foxyshadis is offline   Reply With Quote
Old 10th September 2014, 07:32   #3  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
I'am "bash-ing" the ffmpeg for some years now (see ffdrop), (nothing really complicated), but since we are getting back to win editing stations a powershell example would be nice, care to share some agressiv?
__________________
certain other member
smok3 is offline   Reply With Quote
Old 10th September 2014, 23:29   #4  |  Link
agressiv
Registered Loser
 
agressiv's Avatar
 
Join Date: Dec 2004
Posts: 117
I guess I'm more curious on what hits the lack of indexing has. I'm assuming it's more for handling imperfect content than anything else. I've heard of audio sync issues, but that's about it.

Here is a place where we encode any sort of random video format (whether it be from iPhone, a Windows device, camcorder etc - and convert it into x264 MP4 for a web page.

Code:
$FFMPEGCommand = "D:\Movies\Utilities\ffmpeg.exe"
$FFProbeCommand = "D:\Movies\Utilities\ffprobe.exe"

$SourceDirectory = Get-ChildItem "\\mediaplatformfiles\MediaUpload\Prod" | Where-Object {$_.PSIsContainer}

foreach ($Directory in $SourceDirectory) {
	$OriginalVideo = Get-ChildItem ($Directory.FullName + "\Original") | Select-Object -ExpandProperty FullName
	$VideoPath = "D:\Staging\" + $Directory + "\Encoded"
	#$VideoPath = $Directory.FullName + "\Encoded"
	$TranscodedVideo = $VideoPath + "\" + $Directory + ".mp4"
	if (!(Test-Path $VideoPath)) {
		[xml]$VidXML = &$FFProbeCommand -v quiet -print_format xml -select_streams v -show_entries stream=codec_name $OriginalVideo
		New-Item ("D:\Staging\" + $Directory + "\Encoded") -Type Directory
		$TranscodedVideo = "D:\Staging\" + $Directory + "\Encoded\" + $Directory + ".mp4"
		
		#FFmpeg barfs on mss2 files
		if ($VidXML.ffprobe.streams.stream.codec_name -eq "mss2") {
			$TranscodedVideoAVI = "D:\Staging\" + $Directory + "\Encoded\" + $Directory + ".avi"
			&$FFMPEGCommand -i $OriginalVideo -acodec libvo_aacenc -movflags +faststart -preset slow -y $TranscodedVideoAVI
			&$FFMPEGCommand -i $TranscodedVideoAVI -vcodec copy -acodec copy -bsf:a aac_adtstoasc -y $TranscodedVideo
			Remove-Item -Path $TranscodedVideoAVI -Force -ErrorAction 'SilentlyContinue'
		} else {
			&$FFMPEGCommand -i $OriginalVideo -crf 27 -movflags +faststart -preset slow -y $TranscodedVideo
		}
	}
}
So, we're looping through some folders, looking for any single video which exists in a folder. We're then encoding that to a MP4 container with x264 and aac.

We're using ffprobe to see if the source stream has the mss2 codec. This is a Microsoft "screen" codec which is very low bitrate (e.g. Powerpoint screencaps) that ffmpeg barfs on if you attempt to encode it to x264 with metadata. However, it's just fine if you encode it to ASP MP4 through AVI. This "strange" combination is a result of a lot of experimentation. High CRF because this this is largely presentations, low quality captures of meetings etc - hardly anything approaching blu-ray. Disk space is a larger concern since this all replicates throughout the world.

Here is what I'm doing for my mpeg2 extras from blu-rays which are SD and interlaced:

Code:
$ffmpeg = "C:\Movies\Utilities\ffmpeg.exe"
$mpeg2 = Get-ChildItem "C:\Movies\Extras\mpeg2" | Sort-Object
foreach ($File in $mpeg2) {
	&$ffmpeg -i $File.FullName -filter:v yadif=1 -c:v libx265 -x265-params crf=20 -c:a libopus "C:\Movies\Extras\Final\$($File.Name)"
}
This simply doubles the framerate (yadif=1) and converts them to x265 and the OPUS codec.
agressiv is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.