public EncodeWithFilters(VideoFilter videoFilter, AudioFilter audioFilter, bool overrideBitrate, uint customBitrate) { _videoFilter = videoFilter; _audioFilter = audioFilter; _overrideBitrate = overrideBitrate; _customBitrate = customBitrate; }
private FilterSpecs GetCustomFilter(List <FilterSpecs> list, VideoFilter filter, string eqName, double min, double med, double max) { if (filter.Value == 0.0) { return(null); } double calc; if (filter.Value >= 0) { calc = ((filter.Value) / 50) * (max - med) + med; } else { calc = ((filter.Value) / 50) * (med - min) + med; } string decl = string.Format(CultureInfo.InvariantCulture, "{0}={1:F2}", eqName, calc); var prev = list.FirstOrDefault(s => s.Spec.StartsWith("eq=")); if (prev == null) { return(new FilterSpecs("eq=" + decl, VideoInputCapabilityFormat.MJpeg)); } else { prev.Spec = prev.Spec + ":" + decl; return(null); } }
private async Task CheckFavorites() { try { var filter = new VideoFilter() { SortType = StatusSortType.Random, Visible = true }; filter.Pagination.RecordsPerPage = 1000000000; var response = await new MahwousRepositories().VideosRepository.GetFiltered(filter); if (response.Response != null && response.Response.Count > 0) { videos = response.Response.Where(v => Preferences.Get("favorites", -1, v.Id.ToString()) != -1).ToList(); } else { await CheckFavorites(); } } catch { await CheckFavorites(); } }
private async Task LoadVideos() { try { Category category = await new MahwousRepositories().CategoriesRepository.Get(categoryId); VideoFilter filter = new VideoFilter() { SortType = StatusSortType.Random, Visible = true }; filter.Categories.Add(category); filter.Pagination.Page = pageNumber; var response = await new MahwousRepositories().VideosRepository.GetFiltered(filter); if (response.Response != null && response.Response.Count > 0) { if (videos == null) { videos = response.Response.ToList(); } else { videos.AddRange(response.Response); } pageNumber++; } } catch { await LoadVideos(); } }
public IActionResult Index(VideoFilter filter = null) { var videos = _videoRepository.getQueryable().Where(a => a.is_enabled == true); ViewBag.pagerInfo = _paginatedMetaService.GetMetaData(videos.Count(), filter.page, 5); videos = videos.Skip(filter.number_of_rows * (filter.page - 1)).Take(5); ViewBag.events = videos.ToList(); return(View(videos.ToList())); }
public static void CompressVideo(string inputPath, string outputPath, Action <string> callback) { Activity activity = new Activity(); _callback = callback; ProgressDialog progress = new ProgressDialog(Forms.Context); progress.Indeterminate = true; progress.SetProgressStyle(ProgressDialogStyle.Spinner); progress.SetMessage("Compressing Video. Please wait..."); progress.SetCancelable(false); progress.Show(); Task.Run(() => { var _workingDirectory = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; var sourceMp4 = inputPath; var destinationPath1 = outputPath; FFMpeg ffmpeg = new FFMpeg(Android.App.Application.Context, _workingDirectory); TransposeVideoFilter vfTranspose = new TransposeVideoFilter(TransposeVideoFilter.NINETY_CLOCKWISE); var filters = new List <VideoFilter>(); filters.Add(vfTranspose); var sourceClip = new Clip(System.IO.Path.Combine(_workingDirectory, sourceMp4)) { videoFilter = VideoFilter.Build(filters) }; var br = System.Environment.NewLine; var onComplete = new MyCommand((_) => { _callback(destinationPath1); progress.Dismiss(); }); var onMessage = new MyCommand((message) => { System.Console.WriteLine(message); }); var callbacks = new FFMpegCallbacks(onComplete, onMessage); string[] cmds = new string[] { "-y", "-i", sourceClip.path, "-strict", "experimental", "-vcodec", "libx264", "-preset", "ultrafast", "-crf", "30", "-acodec", "aac", "-ar", "44100", "-q:v", "20", "-vf", sourceClip.videoFilter, // "mp=eq2=1:1.68:0.3:1.25:1:0.96:1", destinationPath1, }; ffmpeg.Execute(cmds, callbacks); }); }
private void SetValue(string name, VideoFilter value) { try { SetValue(name, (int)value); } catch (Exception ex) { Logger.Error(ex); } }
private VideoFilter GetValue(string name, VideoFilter defValue) { try { var iValue = GetValue(name, (int)defValue); if (Enum.IsDefined(typeof(VideoFilter), iValue)) { return((VideoFilter)iValue); } return(defValue); } catch (Exception ex) { Logger.Error(ex); return(defValue); } }
public IActionResult Index(VideoFilter filter = null) { var videos = _videoRepository.getQueryable(); if (!string.IsNullOrWhiteSpace(filter.title)) { videos = videos.Where(a => a.title.Contains(filter.title)); } ViewBag.pagerInfo = _paginatedMetaService.GetMetaData(videos.Count(), filter.page, filter.number_of_rows); videos = videos.Skip(filter.number_of_rows * (filter.page - 1)).Take(filter.number_of_rows); var videoDetails = videos.ToList(); var videoIndexVM = getViewModelFrom(videoDetails); return(View(videoIndexVM)); }
public static string GetFilterArguments(VideoFilter filter) => GetFilterArguments(filter, "v");
void Start() { _workingDirectory = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; var sourceMp4 = "cat1.mp4"; var destinationPathAndFilename = System.IO.Path.Combine(_workingDirectory, "cat1_out.mp4"); var destinationPathAndFilename2 = System.IO.Path.Combine(_workingDirectory, "cat1_out2.mp4"); var destinationPathAndFilename4 = System.IO.Path.Combine(_workingDirectory, "cat1_out4.wav"); if (File.Exists(destinationPathAndFilename)) { File.Delete(destinationPathAndFilename); } CreateSampleFile(Resource.Raw.cat1, _workingDirectory, sourceMp4); var ffmpeg = new FFMpeg(this, _workingDirectory); var sourceClip = new Clip(System.IO.Path.Combine(_workingDirectory, sourceMp4)); var result = ffmpeg.GetInfo(sourceClip); var br = System.Environment.NewLine; // There are callbacks based on Standard Output and Standard Error when ffmpeg binary is running as a process: var onComplete = new MyCommand((_) => { RunOnUiThread(() => _logView.Append("DONE!" + br + br)); }); var onMessage = new MyCommand((message) => { RunOnUiThread(() => _logView.Append(message + br + br)); }); var callbacks = new FFMpegCallbacks(onComplete, onMessage); // 1. The idea of this first test is to show that video editing is possible via FFmpeg: // It results in a 150x150 movie that eventually zooms on a cat ear. This is desaturated, and there's a fade in. var filters = new List <VideoFilter> (); filters.Add(new FadeVideoFilter("in", 0, 100)); filters.Add(new CropVideoFilter("150", "150", "0", "0")); filters.Add(new ColorVideoFilter(1.0m, 1.0m, 0.0m, 0.5m, 1.0m, 1.0m, 1.0m, 1.0m)); var outputClip = new Clip(destinationPathAndFilename) { videoFilter = VideoFilter.Build(filters) }; outputClip.H264_CRF = "18"; // It's the quality coefficient for H264 - Default is 28. I think 18 is pretty good. ffmpeg.ProcessVideo(sourceClip, outputClip, true, new FFMpegCallbacks(onComplete, onMessage)); //2. This is a similar version version in command line only: string[] cmds = new string[] { "-y", "-i", sourceClip.path, "-strict", "-2", "-vf", "mp=eq2=1:1.68:0.3:1.25:1:0.96:1", destinationPathAndFilename2, "-acodec", "copy", }; ffmpeg.Execute(cmds, callbacks); // 3. This lists codecs: string[] cmds3 = new string[] { "-codecs", }; ffmpeg.Execute(cmds, callbacks); // 4. This convers to WAV // Note that the cat movie just has some silent house noise. ffmpeg.ConvertToWaveAudio(sourceClip, destinationPathAndFilename4, 44100, 2, callbacks, true); // Etc... // Rules of thumb: // a) Provide the minimum of info to ffmpeg to not mix it up // b) These helpers are cool to test capabilities, but useless otherwise, and crashy: Use command lines. // c) Try to compile a newer FFmpeg :) }
private void SetFilterValueSource() { List <VideoFilter> sortFilters = new List <VideoFilter>(); string filterString = "新上架;最热门;好评榜"; string[] filters = filterString.Split(new char[] { ';' }); foreach (var item in filters) { VideoFilter filter = new VideoFilter(); filter.filterValue = item; filter.filterType = FilterType.SORT; sortFilters.Add(filter); } sortListBox.ItemsSource = sortFilters; List <VideoFilter> areaFilters = new List <VideoFilter>(); string areaString = "全部;中国;美国;意大利;韩国;英国;日本;德国;加拿大;法国;香港;台湾"; string[] areaFilterValues = areaString.Split(new char[] { ';' }); foreach (var item in areaFilterValues) { VideoFilter filter = new VideoFilter(); filter.filterType = FilterType.AREA; filter.filterValue = item; areaFilters.Add(filter); } areaListBox.ItemsSource = areaFilters; List <VideoFilter> typeFilterValue = new List <VideoFilter>(); string typeFilterString = "全部;犯罪;科幻;悬疑;惊悚;战争;剧情;警匪"; string[] typeFilters = typeFilterString.Split(new char[] { ';' }); foreach (var item in typeFilters) { VideoFilter filter = new VideoFilter(); filter.filterType = FilterType.TYPE; filter.filterValue = item; typeFilterValue.Add(filter); } typeListBox.ItemsSource = typeFilterValue; List <VideoFilter> dateFilterValue = new List <VideoFilter>(); string dateFilterString = "全部;2015;2014;2013;2012;2011;2010;00年代;90年代;80年代;70年代;60年代"; string[] dateFilters = dateFilterString.Split(new char[] { ';' }); foreach (var item in dateFilters) { VideoFilter filter = new VideoFilter(); filter.filterType = FilterType.DATE; filter.filterValue = item; dateFilterValue.Add(filter); } dateListBox.ItemsSource = dateFilterValue; List <VideoFilter> payFilterValue = new List <VideoFilter>(); string payFilterString = "全部;免费;付费;会员"; string[] payFilterValues = payFilterString.Split(new char[] { ';' }); foreach (var item in payFilterValues) { VideoFilter filter = new VideoFilter(); filter.filterType = FilterType.PAY; filter.filterValue = item; payFilterValue.Add(filter); } payListBox.ItemsSource = payFilterValue; }