kaegi / alass

"Automatic Language-Agnostic Subtitle Synchronization"
GNU General Public License v3.0
994 stars 52 forks source link

`ffprobe` error when using `.mkv` files (`missing field duration`) #3

Closed Geniusssmit closed 4 years ago

Geniusssmit commented 4 years ago

image

kaegi commented 4 years ago

That's unfortunate :(

I've now re-uploaded a new alass-windows64 that can handle calls to alass.bat from different directories than the extracted directory (might be related to your problem). Please use this version.

stderr: 20.mkv: No such file or directory means that the file 20.mkv can not be found in the directory you call alass.bat from... For me this kind of path resolution works. Can you please post how you call alass and what files lie in the same directory?

Geniusssmit commented 4 years ago

alass.bat contents: @echo off set ALASS_FFMPEG_PATH=.\ffmpeg\bin\ffmpeg.exe set ALASS_FFPROBE_PATH=.\ffmpeg\bin\ffprobe.exe .\bin\alass-cli.exe %*

alass 20.mkv 20.srt output.srt

folder(I just renamed one episode and messed up timings) image

error: image

kaegi commented 4 years ago

That looks a lot better! Now ffprobe can find 20.mkv (ffprobe is used to get the audio stream id and duration of the stream). The error missing field 'duration' is actually not that critical, because the duration is only used to calculate the progress for a progress bar. Other ways to get the duration are a little bit more complicated...

Would you mind posting the result of '.\ffmpeg\bin\ffprobe.exe -v error -show_streams -of json 20.mkv'? It should be a relatively long JSON info describing the streams in the mkv file. Maybe there is something in it that can be used instead (otherwise progess information has to be disabled).


@echo off
set ALASS_FFMPEG_PATH=.\ffmpeg\bin\ffmpeg.exe
set ALASS_FFPROBE_PATH=.\ffmpeg\bin\ffprobe.exe
.\bin\alass-cli.exe %*

is the old batch file. The new one looks like this:

@echo off
set ALASS_FFMPEG_PATH=%~dp0ffmpeg\bin\ffmpeg.exe
set ALASS_FFPROBE_PATH=%~dp0ffmpeg\bin\ffprobe.exe
"%~dp0bin\alass-cli.exe" %*

%~dp0 is replaced by the folder of the batch file with a trailing slash - thus making all paths absolute.

Geniusssmit commented 4 years ago

I don't know exactly how to do that, should I add " -v error -show_streams -of json 20.mkv " to .bat file like this? Contents: @echo off set ALASS_FFMPEG_PATH=%~dp0ffmpeg\bin\ffmpeg.exe set ALASS_FFPROBE_PATH=%~dp0ffmpeg\bin\ffprobe.exe -v error -show_streams -of json 20.mkv "%~dp0bin\alass-cli.exe" %*

alass 20.mkv 20.srt output.srt

After executing: image

kaegi commented 4 years ago

No just run ffprobe with the arguments by itself. ffprobe and ffmpeg are separate programs that are shipped inside the alass-windows64 zip file. These two programs can do all kinds of tasks on media files. alass only calls these programs like one would on the command line but alass grabs and consumes their output.

Running .\ffmpeg\bin\ffprobe -v error -show_streams -of json 20.mkv by itself on the command line shows us the output that alass sees.

Geniusssmit commented 4 years ago

{ "streams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_time_base": "1001/48000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "width": 1920, "height": 1080, "coded_width": 1920, "coded_height": 1088, "has_b_frames": 2, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "16:9", "pix_fmt": "yuv420p", "level": 50, "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "true", "nal_length_size": "4", "r_frame_rate": "24000/1001", "avg_frame_rate": "24000/1001", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "bits_per_raw_sample": "8", "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0 }, "tags": { "language": "jpn", "BPS-eng": "8704304", "DURATION-eng": "00:23:42.088000000", "NUMBER_OF_FRAMES-eng": "34096", "NUMBER_OF_BYTES-eng": "1547285910", "_STATISTICS_WRITING_APP-eng": "mkvmerge v28.2.0 ('The Awakening') 64-bit", "_STATISTICS_WRITING_DATE_UTC-eng": "2019-07-27 04:01:05", "_STATISTICS_TAGS-eng": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES" } }, { "index": 1, "codec_name": "flac", "codec_long_name": "FLAC (Free Lossless Audio Codec)", "codec_type": "audio", "codec_time_base": "1/48000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "sample_fmt": "s16", "sample_rate": "48000", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "bits_per_raw_sample": "16", "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0 }, "tags": { "language": "jpn", "BPS-eng": "806056", "DURATION-eng": "00:23:42.090000000", "NUMBER_OF_FRAMES-eng": "16666", "NUMBER_OF_BYTES-eng": "143285579", "_STATISTICS_WRITING_APP-eng": "mkvmerge v28.2.0 ('The Awakening') 64-bit", "_STATISTICS_WRITING_DATE_UTC-eng": "2019-07-27 04:01:05", "_STATISTICS_TAGS-eng": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES" } } ] }

kaegi commented 4 years ago

Hmm, no stream has any duration information... (DURATION-eng is just a tag, nothing to rely on). The problem seems that the .mkv file format does not save this piece of information in the header. There might be ways around that (decoding the end of the video/audio stream). I will investigate this issue in the next couple of days. Thank you for your support!

edrevo commented 4 years ago

I'm in the same boat. Here's my json, in case that helps:

{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main 10",
            "codec_type": "video",
            "codec_time_base": "1/25",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 1920,
            "height": 960,
            "coded_width": 1920,
            "coded_height": 960,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "2:1",
            "pix_fmt": "yuv420p10le",
            "level": 120,
            "color_range": "tv",
            "refs": 1,
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/1000",
            "start_pts": 0,
            "start_time": "0.000000",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "BPS": "4134402",
                "BPS-eng": "4134402",
                "DURATION": "00:55:59.280000000",
                "DURATION-eng": "00:55:59.280000000",
                "NUMBER_OF_FRAMES": "83982",
                "NUMBER_OF_FRAMES-eng": "83982",
                "NUMBER_OF_BYTES": "1736076910",
                "NUMBER_OF_BYTES-eng": "1736076910",
                "_STATISTICS_WRITING_APP": "mkvmerge v20.0.0 ('I Am The Sun') 64-bit",
                "_STATISTICS_WRITING_APP-eng": "mkvmerge v20.0.0 ('I Am The Sun') 64-bit",
                "_STATISTICS_WRITING_DATE_UTC": "2019-06-28 03:05:37",
                "_STATISTICS_WRITING_DATE_UTC-eng": "2019-06-28 03:05:37",
                "_STATISTICS_TAGS": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES",
                "_STATISTICS_TAGS-eng": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/48000",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 6,
            "channel_layout": "5.1",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/1000",
            "start_pts": 20,
            "start_time": "0.020000",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "language": "eng",
                "BPS": "323509",
                "BPS-eng": "323509",
                "DURATION": "00:55:59.296000000",
                "DURATION-eng": "00:55:59.296000000",
                "NUMBER_OF_FRAMES": "157467",
                "NUMBER_OF_FRAMES-eng": "157467",
                "NUMBER_OF_BYTES": "135845453",
                "NUMBER_OF_BYTES-eng": "135845453",
                "_STATISTICS_WRITING_APP": "mkvmerge v20.0.0 ('I Am The Sun') 64-bit",
                "_STATISTICS_WRITING_APP-eng": "mkvmerge v20.0.0 ('I Am The Sun') 64-bit",
                "_STATISTICS_WRITING_DATE_UTC": "2019-06-28 03:05:37",
                "_STATISTICS_WRITING_DATE_UTC-eng": "2019-06-28 03:05:37",
                "_STATISTICS_TAGS": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES",
                "_STATISTICS_TAGS-eng": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"
            }
        }
    ]
}

Very cool project, btw. Rust FTW!

kaegi commented 4 years ago

Does ffprobe -v error -of json -show_entries format=duration Your.mkv work for you?

kaegi commented 4 years ago

Or even better:

ffprobe -v error -of json -show_entries format=duration:stream=index,codec_long_name,channels,duration,codec_type Your.mkv

That should query all interesting pieces of information at the same time.

Geniusssmit commented 4 years ago

{ "programs": [

],
"streams": [
    {
        "index": 0,
        "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
        "codec_type": "video"
    },
    {
        "index": 1,
        "codec_long_name": "FLAC (Free Lossless Audio Codec)",
        "codec_type": "audio",
        "channels": 2
    }
],
"format": {
    "duration": "1422.090000"
}

}

kaegi commented 4 years ago

Perfect :) It does indeed work!

kaegi commented 4 years ago

Should be fixed now! Please try the new release.

Geniusssmit commented 4 years ago

Now it's looped or something image

kaegi commented 4 years ago

This issue with .mkv is resolved anyway. Actually, I've been wondering why all your screenshots show the same output multiple times. alass does not do that. This has probably something to with the way you start alass. Could you please upload a screenshot how exactly you are starting alass?

The output file should be generated nonetheless, so you can hopefully enjoy your synchronized subtile file!

Geniusssmit commented 4 years ago

I just double click on it image

kaegi commented 4 years ago

Well, writing alass in in alass.bat calls alass.bat again in the last line. What can do is create my-alass.bat in the same directory with:

alass 20.mkv 20.srt output.srt
pause

And double click on it (pause can be removed if you want the terminal to close automatically).

If you insist on doing it inside alass.bat you can replace %* (in the last original line) by 20.mkv 20.srt output.srt. This is the line that calls the real alass-cli.exe. alass.bat is only needed to set the paths to ffprobe and ffmpeg.

Geniusssmit commented 4 years ago

thanks!

kaegi commented 4 years ago

No problem!

tissatussa commented 1 year ago

ffprobe -v error -of json -show_entries format=duration:stream=index,codec_long_name,channels,duration,codec_type Your.mkv

That should query all interesting pieces of information at the same time.

woow ! i didn't know this syntax .. it even works when adding the properties ",width,height" : these properties will be a new entry in the video stream section. Helped me a lot !

iperov commented 10 months ago

['format']['duration'] in mkv is not always correct. In my sample video file it is larger then real by 200 sec.