lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

Options "--add-subtitle" and "--main-audio" does not seem to work. #350

Open muhrizali opened 1 month ago

muhrizali commented 1 month ago

Hello, @lisamelton I have been using your tools for long time now (really love them by the way!). I have encoded thousands of mainly Japanese anime video ".mkv" files and have never encountered this issue. Yesterday, I got a new TV show and decided to use these tools on them to add to my collection.

I was using the following command: transcode-video --no-auto-burn --add-subtitle all --main-audio jpn ./input/* -o output/

All the video files in the input folder are consistent, meaning they all have similar subtitle and audio tracks.

But the output transcoded files does not seem to follow the instructions. There are no subtitles added in the output but JPN audio track was added.

But later, when I tested the audio track, changing it to --main-audio eng, that does not seem to work too, as there was no ENG track in the output file, JPN audio track added again.

I have even scanned the first file from input folder:

+ title 1:
  + stream: input/Frieren Beyond Journey's End - S01E01 (WEB 1080p x265 10-bit AAC Opus) [0F7F64F6].mkv
  + duration: 00:26:00
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + chapters:
    + 1: duration 00:01:30
    + 2: duration 00:17:27
    + 3: duration 00:05:23
    + 4: duration 00:01:30
    + 5: duration 00:00:11
  + audio tracks:
    + 1,  (Opus, 2.0 ch) (iso639-2: jpn)
    + 2, English (AAC LC, 2.0 ch) (iso639-2: eng)
  + subtitle tracks:
    + 1, English (SSA)
    + 2, English (SSA)

I am sure I am missing something here, but I am not sure what. I really appreciate if you could guide me a little. I know that the tool is not meant to be used for multiple files, but I have used the batch-transcode-video script at https://github.com/nwronski/batch-transcode-video from @nwronski and it is giving me the same results.

lisamelton commented 1 month ago

@muhrizali Do the --no-auto-burn --add-subtitle all --main-audio jpn options work when you apply them to a single input?

muhrizali commented 1 month ago

@lisamelton No, the options does not seem to have any effect even in the case of single inputs.

In case it would be helpful, I have found the section in the log file that I think represents the "job configuration" for the encoding task: There are no subtitle tracks added.

[18:48:28] Starting Task: Encoding Pass
[18:48:28] work: skipping crop/scale filter
[18:48:28] job configuration:
[18:48:28]  * source
[18:48:28]    + ./input/Frieren Beyond Journey's End - S01E01 (WEB 1080p x265 10-bit AAC Opus) [0F7F64F6].mkv
[18:48:28]    + title 1, chapter(s) 1 to 5
[18:48:28]    + container: matroska,webm
[18:48:28]    + data rate: 17972 kbps
[18:48:28]  * destination
[18:48:28]    + /mnt/storage/Downloads/Frieren Beyond Journey's End - Season 1 (WEB 1080p x265 10-bit AAC Opus) [Dual Audio]/output/Frieren Beyond Journey's End - S01E01 (WEB 1080p x265 10-bit AAC Opus) [0F7F64F6].mkv
[18:48:28]    + container: Matroska (libavformat)
[18:48:28]      + chapter markers
[18:48:28]  * video track
[18:48:28]    + decoder: hevc 10-bit (yuv420p10le)
[18:48:28]    + filters
[18:48:28]      + Framerate Shaper (mode=0)
[18:48:28]        + frame rate: same as source (around 23.976 fps)
[18:48:28]      + Format (format=yuv420p)
[18:48:28]    + Output geometry
[18:48:28]      + storage dimensions: 1920 x 1080
[18:48:28]      + pixel aspect ratio: 1 : 1
[18:48:28]      + display dimensions: 1920 x 1080
[18:48:28]    + encoder: H.264 (libx264)
[18:48:28]      + preset:  medium
[18:48:28]      + options: vbv-maxrate=6000:vbv-bufsize=12000:crf-max=25:qpmax=34
[18:48:28]      + profile: high
[18:48:28]      + level:   4.0
[18:48:28]      + quality: 1.00 (RF)
[18:48:28]      + color profile: 1-1-1
[18:48:28]      + chroma location: left
[18:48:28]  * audio track 1
[18:48:28]    + name: Japanese 2.0 Opus
[18:48:28]    + decoder: 日本語 (Opus, 2.0 ch) (track 1, id 0x1)
[18:48:28]      + samplerate: 48000 Hz
[18:48:28]    + mixdown: Stereo
[18:48:28]    + encoder: AAC (libavcodec)
[18:48:28]      + bitrate: 128 kbps, samplerate: 48000 Hz
Encoding: task 1 of 1, 0.00 %[18:48:28] sync: expecting 37424 video frames
Encoding: task 1 of 1, 0.00 %[18:48:28] encx264: min-keyint: 24, keyint: 240
muhrizali commented 1 month ago

Just now, I have tried the same command with a different video file wondering if the issue was present in the original ".mkv" file but the outputs in the log file were identical. The commands have no effect there too.

muhrizali commented 4 weeks ago

Man, you are certainly taking your sweet time.

lisamelton commented 4 weeks ago

@muhrizali My apologies for taking so long to respond. Life sometimes gets in the way.

Thank you for the extra information. But I honestly have no idea why this is happening. I can't reproduce this so I suspect something in your inputs is unexpected by my script. I just don't see what that might be based on the scan you provided.

This is why I'm in the process of re-writing transcode-video and completely replacing its media query code with something much more stable.

Again, I'm sorry I can't help you solve this problem now.

muhrizali commented 4 weeks ago

I have done my own little research and found out that the problem is in the version of HandBrakeCLI. The problem arises with the release of version 1.7.x.

Though I couldn't be able to test myself, I have read somewhere that previous version series 1.6.x was working fine.

dirtystylus commented 1 week ago

Confirming that HandbrakeCLI 1.7.x ignored any flags passed in by transcode-video, so --add-audio and --add-subtitle fail silently.

I downgraded to HandbrakeCLI 1.6.1 and confirmed that --add-audio and --add-subtitle flags worked as expected.

I’m on MacOS and typically would use homebrew for installing handbrake, but only the latest version is available, so I manually downloaded it from handbrake.fr.

muhrizali commented 4 days ago

I downgraded to HandbrakeCLI 1.6.1 and confirmed that --add-audio and --add-subtitle flags worked as expected.

I wanted to downgraded to version 1.6.X on my ubuntu Linux but it is a real PITA to build it from the source. Tried it many times with no success.