<commit_before>////////////////////////////////////////////////////////////////////////////////
// ffmpeg tool
////////////////////////////////////////////////////////////////////////////////
/*global require, exports, console */
var	$path = require('path'),
	tool = require('../tools/tool').tool,
	execSync = require('child_process').execSync,

ffmpeg = function () {
	var

	self = Object.create(tool, {
		executable: {value: 'ffmpeg'},
		stderr: {value: true}
	});

	// collect video data using ffprobe
	function ffprobe(handler, inPath) {
	
		// ffprobe arguments:	
		var args = [
			'-of', 'json',
			'-show_streams',
			'-show_format',
			'-sexagesimal',
			'-v', 'quiet',
			inPath
		];
		var metadata = {};		
		
		// execute ffprobe:
		var result = JSON.parse(execSync('ffprobe ' + args.join(" ") ));
		
		// check where is the 'video' to collect the data		  
		for (i = 0; i < result.streams.length; i++) {
			if ( result.streams[i]['codec_type'] === 'video' ) {
				var arr = i;
				break;
			}
		}
		
		// fields to collect:		  
		var field = [
			'dimensions',
			'duration',
			'codec_name'
		];
		
		// collecting data
		for (i in field) {
			switch(field[i]){
				case 'dimensions':
					var width=JSON.stringify(result.streams[arr][ 'width' ]);
					var height=JSON.stringify(result.streams[arr][ 'height' ]);
					metadata[ field[i] ]= width + 'x' + height;
					break;
				case 'duration':<commit_msg>ffmpeg.js: fixing videos with space in file name<commit_after>////////////////////////////////////////////////////////////////////////////////
// ffmpeg tool
////////////////////////////////////////////////////////////////////////////////
/*global require, exports, console */
var	$path = require('path'),
	tool = require('../tools/tool').tool,
	execSync = require('child_process').execSync,

ffmpeg = function () {
	var

	self = Object.create(tool, {
		executable: {value: 'ffmpeg'},
		stderr: {value: true}
	});

	// collect video data using ffprobe
	function ffprobe(handler, inPath) {
	
		// ffprobe arguments:	
		var args = [
			'-of', 'json',
			'-show_streams',
			'-show_format',
			'-sexagesimal',
			'-v', 'quiet',
			'"' + inPath + '"'
		];
		var metadata = {};		
		
		// execute ffprobe:
		var result = JSON.parse(execSync('ffprobe ' + args.join(" ") ));
		
		// check where is the 'video' to collect the data		  
		for (i = 0; i < result.streams.length; i++) {
			if ( result.streams[i]['codec_type'] === 'video' ) {
				var arr = i;
				break;
			}
		}
		
		// fields to collect:		  
		var field = [
			'dimensions',
			'duration',
			'codec_name'
		];
		
		// collecting data
		for (i in field) {
			switch(field[i]){
				case 'dimensions':
					var width=JSON.stringify(result.streams[arr][ 'width' ]);
					var height=JSON.stringify(result.streams[arr][ 'height' ]);
					metadata[ field[i] ]= width + 'x' + height;
					break;
				case 'duration':
{'fraction_non_alphanumeric': 0.2677766215747485, 'fraction_numerical': 0.000693721817551162, 'mean_word_length': 1.910191725529768, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6116086', 'n_tokens_mistral': 1089, 'n_tokens_neox': 894, 'n_words': 218}