[youtube|ffmpeg] Automatically correct video with non-square pixels (Fixes #4674)
This commit is contained in:
		
							parent
							
								
									fb4b030aaf
								
							
						
					
					
						commit
						6271f1cad9
					
				
					 7 changed files with 89 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -6,6 +6,7 @@ from .ffmpeg import (
 | 
			
		|||
    FFmpegAudioFixPP,
 | 
			
		||||
    FFmpegEmbedSubtitlePP,
 | 
			
		||||
    FFmpegExtractAudioPP,
 | 
			
		||||
    FFmpegFixupStretchedPP,
 | 
			
		||||
    FFmpegMergerPP,
 | 
			
		||||
    FFmpegMetadataPP,
 | 
			
		||||
    FFmpegVideoConvertorPP,
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +25,7 @@ __all__ = [
 | 
			
		|||
    'FFmpegAudioFixPP',
 | 
			
		||||
    'FFmpegEmbedSubtitlePP',
 | 
			
		||||
    'FFmpegExtractAudioPP',
 | 
			
		||||
    'FFmpegFixupStretchedPP',
 | 
			
		||||
    'FFmpegMergerPP',
 | 
			
		||||
    'FFmpegMetadataPP',
 | 
			
		||||
    'FFmpegPostProcessor',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,6 +50,10 @@ class FFmpegPostProcessor(PostProcessor):
 | 
			
		|||
        programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
 | 
			
		||||
        return dict((p, get_exe_version(p, args=['-version'])) for p in programs)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def available(self):
 | 
			
		||||
        return self._executable is not None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def _executable(self):
 | 
			
		||||
        if self._downloader.params.get('prefer_ffmpeg', False):
 | 
			
		||||
| 
						 | 
				
			
			@ -540,3 +544,22 @@ class FFmpegAudioFixPP(FFmpegPostProcessor):
 | 
			
		|||
        os.rename(encodeFilename(temp_filename), encodeFilename(filename))
 | 
			
		||||
 | 
			
		||||
        return True, info
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FFmpegFixupStretchedPP(FFmpegPostProcessor):
 | 
			
		||||
    def run(self, info):
 | 
			
		||||
        stretched_ratio = info.get('stretched_ratio')
 | 
			
		||||
        if stretched_ratio is None or stretched_ratio == 1:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        filename = info['filepath']
 | 
			
		||||
        temp_filename = prepend_extension(filename, 'temp')
 | 
			
		||||
 | 
			
		||||
        options = ['-c', 'copy', '-aspect', '%f' % stretched_ratio]
 | 
			
		||||
        self._downloader.to_screen('[ffmpeg] Fixing aspect ratio in "%s"' % filename)
 | 
			
		||||
        self.run_ffmpeg(filename, temp_filename, options)
 | 
			
		||||
 | 
			
		||||
        os.remove(encodeFilename(filename))
 | 
			
		||||
        os.rename(encodeFilename(temp_filename), encodeFilename(filename))
 | 
			
		||||
 | 
			
		||||
        return True, info
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue