Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a homebrew formula for libcaption #27

Open
bbgdzxng1 opened this issue May 10, 2018 · 5 comments
Open

Creating a homebrew formula for libcaption #27

bbgdzxng1 opened this issue May 10, 2018 · 5 comments

Comments

@bbgdzxng1
Copy link

bbgdzxng1 commented May 10, 2018

I would like to create a brew formula for libcaption to make install easier for users.

Does anyone have a working brew formula which we could contribute to the homebrew project?

Below uses brew to create a basic template.

$ brew create 'https://github.com/szatmary/libcaption/archive/master.zip'

EDITED: Removed old version of libcaption.rb.

@szatmary
Copy link
Owner

This is a great effort. Thank you for doing this.

@bbgdzxng1
Copy link
Author

I'm not entirely sure that the brew formula will work for all users at this stage, so I would welcome any feedback from the community, especially those with experience of the awesome homebrew.

Big public thanks to @szatmary for libcaption. I'm not sure there is any other FOSS software out there which handles encoding of CEA/EIA 608/708.

@bbgdzxng1
Copy link
Author

bbgdzxng1 commented Aug 26, 2018

Below is a proposed libcaption.rb for release version 0.7, which appears to compile libcaption successfully, with necessary dependencies. Any feedback or improvements are welcome.

Save the following snippet to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libcaption.rb

libcaption.rb

class Libcaption < Formula
  desc "Library for the creation and parsing of closed caption data"
  homepage "https://github.com/szatmary/libcaption"

  url "https://github.com/szatmary/libcaption/archive/0.7.tar.gz"
  # version "0.7"
  sha256 "125c9c55e1d5f0dc37ef151fa9583dd2fcfaefe7699d348c7292e634859e527e"
  revision 0

  # --HEAD version
  head "https://github.com/szatmary/libcaption.git"

  depends_on "cmake" => :build
  depends_on "ffmpeg" => :build
  depends_on "re2c" => :build

  def install
    system "cmake", ".", *std_cmake_args
    system "make", "install"
  end

  test do
    # Create an FLV video file
    INPUT_VIDEO = testpath/"input_video.flv"
    system "ffmpeg", "-report", "-hide_banner",
    "-f", "lavfi", "-i", "smptebars=duration=2:size=640x360:rate=30",
    "-c:v", "libx264", "-crf", "23", "-preset", "ultrafast",
    "-f", "flv", INPUT_VIDEO
    # system "ffprobe", "-i", INPUT_VIDEO

    INPUT_CAPTION_FILE = testpath/"input_caption.srt"
    INPUT_CAPTION_FILE.write <<~EOS
      1
      00:00:00,000 --> 00:00:02,000
      Caption Text
    EOS
    OUTPUT_FILE = testpath/"output.flv"
    system bin/"flv+srt", INPUT_VIDEO, INPUT_CAPTION_FILE, OUTPUT_FILE
    assert_predicate OUTPUT_FILE, :exist?
  end
end

Simple installation for users

$ brew install libcaption

Testing the brew formula, for maintainers

$ brew info libcaption
  libcaption: stable 0.7
  Library for the creation and parsing of closed caption data
  https://github.com/szatmary/libcaption
  Not installed

# Run brew's formula audit tools, checking the integrity of the formula
$ brew audit --strict libcaption

$ brew install --dry-run libcaption

$ brew install libcaption

# Run the test process (create an flv using FFmpeg, create an srt, use Libcaption flv+srt, check output exists)
$ brew test libcaption

# Reinstall / Uninstall
$ brew reinstall libcaption
$ brew uninstall libcaption

# Install latest version from HEAD
$ brew install libcaption --HEAD
$ brew uninstall libcaption

# Return back to stable version 0.7
$ brew install libcaption

@bbgdzxng1
Copy link
Author

I have submitted a PR to Homebrew Core Homebrew/homebrew-core#34453

Unfortunately, @BrewTestBot is waiting for libcaption to gain further traction.

GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)

Latest version is...

class Libcaption < Formula
  desc "Library for the creation and parsing of closed caption data"
  homepage "https://github.com/szatmary/libcaption"

  url "https://github.com/szatmary/libcaption/archive/0.7.tar.gz"
  sha256 "125c9c55e1d5f0dc37ef151fa9583dd2fcfaefe7699d348c7292e634859e527e"

  depends_on "cmake" => :build
  depends_on "ffmpeg" => [:build, :test]
  depends_on "re2c" => :build

  def install
    system "cmake", ".", *std_cmake_args
    system "make", "install"
  end

  test do
    # Create an FLV video file
    INPUT_VIDEO = testpath/"input_video.flv"
    system "ffmpeg", "-report", "-hide_banner",
    "-f", "lavfi", "-i", "smptebars=duration=2:size=640x360:rate=30",
    "-c:v", "libx264", "-crf", "23", "-preset", "ultrafast",
    "-f", "flv", INPUT_VIDEO

    INPUT_CAPTION_FILE = testpath/"input_caption.srt"
    INPUT_CAPTION_FILE.write <<~EOS
      1
      00:00:00,000 --> 00:00:02,000
      Caption Text
    EOS
    OUTPUT_FILE = testpath/"output.flv"
    system bin/"flv+srt", INPUT_VIDEO, INPUT_CAPTION_FILE, OUTPUT_FILE
    assert_predicate OUTPUT_FILE, :exist?
  end
end

@bbgdzxng1
Copy link
Author

GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)

Still waiting for libcaption to get further traction before it can be included in Homebrew Core. At end of 2019, there are:

  • 26 forks
  • 15 watchers
  • 60 stars

@szatmary If I were to put together a final formula, would you consider adding a homebrew-libcaption repo to host the Homebrew tap file? Users could then install libcaption with:

$ brew tap szatmary/libcaption
$ brew install libcaption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants