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

Parse HandBrakeCLI JSON output (Fixes #234) #333

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bloertscher
Copy link

@bloertscher bloertscher commented Oct 29, 2021

Uses the HandBrakeCLI --json option to get media info.

Tested with

  • ntodd/video-transcoding Docker image (ruby 2.4.0p0, HandBrake 1.1.2, ffmpeg version 4.1, Ubuntu 16.04)
  • ruby 2.7.0p0, HandBrake 1.3.3, ffmpeg version 4.2.4-1ubuntu0.1, Ubuntu 20.04

I ran transcode-video --dry-run on a bunch of DVD directory rips and a couple of .mkv and .mp4 files with no options and compared the output between video_transcoding-0.25.3 and video_transcoding-0.26.0 (this PR). The output for all of those was the same. When I added --crop detect --add-audio "spa" --add-subtitle "eng,spa", the only difference was that subtitle tracks were correctly added. My video library is very limited, however, and I didn't play with any of the other options.

convert-video doesn't always select the correct streams (the stream IDs aren't available in the HandBrake JSON output). Should now select the streams correctly, though it will only get the first video stream (which I think matches the old behavior, and is probably the most common use case).
detect-crop seems unaffected.

TODOs:

  • Add stream IDs to media.info. They are not available in the JSON output, so they need to be found elsewhere.
  • Needs a lot of further testing.

TODOs:
- Add stream IDs to media.info. They are not available in
the JSON output, so they need to be found elsewhere.
- Needs a lot of further testing.
@bloertscher bloertscher marked this pull request as ready for review October 29, 2021 01:02
@bloertscher bloertscher changed the title Parse HandBrakeCLI JSON output (Fixes donmelton/video_transcoding#234) Parse HandBrakeCLI JSON output (Fixes #234) Oct 29, 2021
Assumes that the order of audio and subtitle entries in the JSON output
is the same as order of streams in the input file.
Also note that the JSON output only considers the first video stream.
@lisamelton
Copy link
Owner

@bloertscher Thanks for the patch! I'll take a closer look at it in the next few days. In the meantime, keep iterating.

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

Successfully merging this pull request may close these issues.

2 participants