add cropdetect stub
This commit is contained in:
@@ -212,6 +212,41 @@ def unmux(ctx,
|
|||||||
ctx.obj['logger'].warning(f"Skipping File {sourcePath} ({ex})")
|
ctx.obj['logger'].warning(f"Skipping File {sourcePath} ({ex})")
|
||||||
|
|
||||||
|
|
||||||
|
@ffx.command()
|
||||||
|
@click.pass_context
|
||||||
|
|
||||||
|
@click.argument('paths', nargs=-1)
|
||||||
|
@click.option('--nice', type=int, default=99, help='Niceness of started processes')
|
||||||
|
@click.option('--cpu', type=int, default=0, help='Limit CPU for started processes to percent')
|
||||||
|
def cropdetect(ctx,
|
||||||
|
paths,
|
||||||
|
label,
|
||||||
|
output_directory,
|
||||||
|
subtitles_only,
|
||||||
|
nice,
|
||||||
|
cpu):
|
||||||
|
|
||||||
|
existingSourcePaths = [p for p in paths if os.path.isfile(p)]
|
||||||
|
ctx.obj['logger'].debug(f"\nUnmuxing {len(existingSourcePaths)} files")
|
||||||
|
|
||||||
|
ctx.obj['resource_limits'] = {}
|
||||||
|
ctx.obj['resource_limits']['niceness'] = nice
|
||||||
|
ctx.obj['resource_limits']['cpu_percent'] = cpu
|
||||||
|
|
||||||
|
for sourcePath in existingSourcePaths:
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
fp = FileProperties(ctx.obj, sourcePath)
|
||||||
|
cropParams = fp.findCropParams()
|
||||||
|
|
||||||
|
click.echo(cropParams)
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
ctx.obj['logger'].warning(f"Skipping File {sourcePath} ({ex})")
|
||||||
|
|
||||||
|
|
||||||
@ffx.command()
|
@ffx.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,69 @@ class FileProperties():
|
|||||||
return json.loads(ffprobeOutput)['streams']
|
return json.loads(ffprobeOutput)['streams']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def findCropParams(self):
|
||||||
|
"""Returns ffprobe stream data as array with elements according to the following example
|
||||||
|
{
|
||||||
|
"index": 4,
|
||||||
|
"codec_name": "hdmv_pgs_subtitle",
|
||||||
|
"codec_long_name": "HDMV Presentation Graphic Stream subtitles",
|
||||||
|
"codec_type": "subtitle",
|
||||||
|
"codec_tag_string": "[0][0][0][0]",
|
||||||
|
"codec_tag": "0x0000",
|
||||||
|
"r_frame_rate": "0/0",
|
||||||
|
"avg_frame_rate": "0/0",
|
||||||
|
"time_base": "1/1000",
|
||||||
|
"start_pts": 0,
|
||||||
|
"start_time": "0.000000",
|
||||||
|
"duration_ts": 1421035,
|
||||||
|
"duration": "1421.035000",
|
||||||
|
"disposition": {
|
||||||
|
"default": 1,
|
||||||
|
"dub": 0,
|
||||||
|
"original": 0,
|
||||||
|
"comment": 0,
|
||||||
|
"lyrics": 0,
|
||||||
|
"karaoke": 0,
|
||||||
|
"forced": 0,
|
||||||
|
"hearing_impaired": 0,
|
||||||
|
"visual_impaired": 0,
|
||||||
|
"clean_effects": 0,
|
||||||
|
"attached_pic": 0,
|
||||||
|
"timed_thumbnails": 0,
|
||||||
|
"non_diegetic": 0,
|
||||||
|
"captions": 0,
|
||||||
|
"descriptions": 0,
|
||||||
|
"metadata": 0,
|
||||||
|
"dependent": 0,
|
||||||
|
"still_image": 0
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"language": "ger",
|
||||||
|
"title": "German Full"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# ffmpeg -i <input.file> -vf cropdetect -f null -
|
||||||
|
ffprobeOutput, ffprobeError, returnCode = executeProcess(["ffmpeg" "-i",
|
||||||
|
self.__sourcePath,
|
||||||
|
"-vf", "cropdetect",
|
||||||
|
"-t", "180",
|
||||||
|
"-f", "null", "-"
|
||||||
|
])
|
||||||
|
|
||||||
|
errorLines = ffprobeError.split('\n')
|
||||||
|
|
||||||
|
for el in errorLines:
|
||||||
|
|
||||||
|
print(el)
|
||||||
|
|
||||||
|
|
||||||
|
# return json.loads(ffprobeOutput)['streams']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getMediaDescriptor(self):
|
def getMediaDescriptor(self):
|
||||||
return MediaDescriptor.fromFfprobe(self.context, self.getFormatData(), self.getStreamData())
|
return MediaDescriptor.fromFfprobe(self.context, self.getFormatData(), self.getStreamData())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user