neurospeech / xamarin-android-ffmpeg

Xamarin Android FFMpeg binding
MIT License
30 stars 6 forks source link

Lower video quality #13

Closed NVentimiglia closed 5 years ago

NVentimiglia commented 7 years ago

I would like to reduce video resolution. how can I do this ?

I found this post, Which has the correct commands it seems.

https://superuser.com/questions/714804/converting-video-from-1080p-to-720p-with-smallest-qualiti-loss-using-ffmpeg

So I came up with this from the sample.


  public async Task<File> ConvertFileAsync(
            File inputFile,
            Action<string> logger = null,
            Action<int, int> onProgress = null)
        {
            File ouputFile = new File(inputFile.CanonicalPath + ".mpg");

            ouputFile.DeleteOnExit();

            List<string> cmd = new List<string>();
            cmd.Add("-y");
            cmd.Add("-i");
            cmd.Add(inputFile.CanonicalPath);

            MediaMetadataRetriever m = new MediaMetadataRetriever();
            m.SetDataSource(inputFile.CanonicalPath);

            cmd.Add("-vf scale=-1:720");
            cmd.Add("-c:v libx264");

            cmd.Add("-b:v");
            cmd.Add("1M");

            cmd.Add("-b:a");
            cmd.Add("128k");            

            cmd.Add("-f");
            cmd.Add("mpeg");

Am i doing it right ?

NVentimiglia commented 7 years ago

I see this warning

"WARNING: linker: /data/data/demo1/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix."

It appears that FFMPEG is not writing the output.

My cmd string looks like this

-y -i /storage/emulated/0/Android/data/demo/files/Movies/Sample/video_12cb4d46-f2be-422c-ba4c-6bc729dcb2f7.mp4 -vf scale=640:360 -c:a copy /storage/emulated/0/Android/data/demo/files/Movies/Sample/video_12cb4d46-f2be-422c-ba4c-6bc729dcb2f7_min.mp4 /storage/emulated/0/Android/data/demo/files/Movies/Sample/video_12cb4d46-f2be-422c-ba4c-6bc729dcb2f7_min.mp4

neurospeech commented 7 years ago

From Android 6 and after, FFMpeg is not supported due to text relocation. This is the reason, I have mentioned using other Nuget package at https://github.com/neurospeech/xamarin-android-ffmpeg/