项目作者: robertsanseries

项目描述 :
Vala wrapper around the FFmpeg command line tool
高级语言: Vala
项目地址: git://github.com/robertsanseries/ffmpeg-cli-wrapper.git
创建时间: 2018-06-12T00:44:53Z
项目社区:https://github.com/robertsanseries/ffmpeg-cli-wrapper

开源协议:MIT License

下载



FFmpeg Cli Wrapper


Vala wrapper around the FFmpeg command line tool









How this library works:

This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it.

Installation

You can download FFmpeg Cli Wrapper via Github Here

or If you want install via Vanat. *recommended

  1. $ vanat require robertsanseries/ffmpeg-wrapper

Requirements

  • FFmpeg 2.8.14+
  • Vala 0.36+

Documentation

You can find the complete documentation on our Wiki. Or parse the source code.

Basic exemple

  1. FFmpeg ffmpeg2 = new FFmpeg ()
  2. .set_input ("/home/robertsanseries/Documentos/doc.mp4")
  3. .set_output ("/home/robertsanseries/Documentos/doc.avi")
  4. .set_format ("avi")
  5. .set_override_output (true);
  6. // output: ffmpeg -y -hide_banner -i /home/robertsanseries/Documentos/doc.mp4 -f avi /home/robertsanseries/Documentos/doc.avi
  7. GLib.message (ffmpeg2.get_command ());
  8. FFconvert ffconvert = new FFconvert (ffmpeg2);
  9. GLib.MainLoop mainloop = new GLib.MainLoop();
  10. ffconvert.convert.begin ((obj, async_res) => {
  11. try {
  12. GLib.Subprocess subprocess = ffconvert.convert.end (async_res);
  13. if (subprocess != null && subprocess.wait_check ()) {
  14. GLib.message ("Success");
  15. } else {
  16. GLib.message ("Error");
  17. }
  18. } catch (Error e) {
  19. GLib.critical (e.message);
  20. }
  21. mainloop.quit();
  22. });
  23. mainloop.run();
  24. FFprobe ffprobe = ffmpeg2.get_ffprobe ();
  25. // output: /home/robertsanseries/Documentos/doc.mp4
  26. stdout.printf(ffprobe.format.filename);

Basic Usage

To use the FFmpeg Cli Wrapper you need to add the namespace:

  1. using com.github.robertsanseries.FFmpegCliWrapper;

Starting the class:

  1. FFmpeg ffmpeg = new FFmpeg ();

You may already set some optional values when starting the class:

  • Input
  • Output
  • Override Files
  • Force Format
Input & Output.
  1. FFmpeg ffmpeg = new FFmpeg (
  2. "/home/Vídeos/MarcusMiller.mkv",
  3. "/home/Vídeos/MarcusMiller.avi"
  4. );
Input & Output & Override Files .
  1. FFmpeg ffmpeg = new FFmpeg (
  2. "/home/Vídeos/MarcusMiller.mkv",
  3. "/home/Vídeos/MarcusMiller.avi",
  4. true
  5. );
Input & Output & Override Files & Force Format.
  1. FFmpeg ffmpeg = new FFmpeg (
  2. "/home/Vídeos/MarcusMiller.mkv",
  3. "/home/Vídeos/MarcusMiller.avi",
  4. true,
  5. "avi"
  6. );

You can set the values in two other ways:

#1:
  1. FFmpeg ffmpeg = new FFmpeg ();
  2. ffmpeg.set_input ("/home/Vídeos/MarcusMiller.mkv");
  3. ffmpeg.set_output ("/home/Vídeos/MarcusMiller.avi");
  4. ffmpeg.set_format ("avi");
  5. ffmpeg.set_override_output (true);
#2:
  1. FFmpeg ffmpeg = new FFmpeg ()
  2. .set_input ("/home/Vídeos/MarcusMiller.mkv")
  3. .set_output ("/home/Vídeos/MarcusMiller.avi")
  4. .set_format ("avi")
  5. .set_override_output (true);

Use the get_cmd () function to get the generated command string:

  1. FFmpeg ffmpeg = new FFmpeg ();
  2. ffmpeg.set_input ("/home/Vídeos/MarcusMiller.mkv");
  3. ffmpeg.set_output ("/home/Vídeos/MarcusMiller.avi");
  4. ffmpeg.set_format ("avi");
  5. ffmpeg.set_override_output (true);
  6. stdout.printf (ffmpeg.get_cmd ());
  1. $ ffmpeg -y -i /home/Vídeos/MarcusMiller.mkv -f avi /home/Vídeos/MarcusMiller.avi

Test

compile

  1. $ valac --pkg json-glib-1.0 --pkg gio-2.0 --pkg gee-0.8 src/FFconvert.vala src/FFmpeg.vala src/FFprobe.vala src/exceptions/CodecNotEnabledException.vala src/exceptions/FileOrDirectoryNotFoundException.vala src/exceptions/NullReferenceException.vala src/utils/StringUtil.vala test/FFmpegTest.vala src/exceptions/IllegalArgumentException.vala src/exceptions/IOException.vala src/probe/FFprobeDisposition.vala src/probe/FFprobeFormat.vala src/probe/FFprobeStream.vala -o ffmpeg-cli-wrapper

execute

  1. $ ./ffmpeg-cli-wrapper

License

This project is licensed under the MIT license.