How to add metadata to a specific subtitle stream with ffmpeg? - ffmpeg

I have this mkv video with multiple subtitles. the last one has no metadata and i would like to add title and language
Input #0, matroska,webm, from '1.mkv':
Metadata:
ENCODER : Lavf59.34.102
Duration: 00:34:58.02, start: 0.000000, bitrate: 10341 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn (default)
Metadata:
BPS-eng : 9953181
DURATION-eng : 00:34:57.973000000
NUMBER_OF_FRAMES-eng: 50301
NUMBER_OF_BYTES-eng: 2610188172
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:34:57.972000000
Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
Metadata:
BPS-eng : 384000
DURATION-eng : 00:34:58.016000000
NUMBER_OF_FRAMES-eng: 65563
NUMBER_OF_BYTES-eng: 100704768
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:34:58.016000000
Stream #0:2(ger): Subtitle: subrip
Metadata:
BPS-eng : 62
DURATION-eng : 00:33:30.427000000
NUMBER_OF_FRAMES-eng: 392
NUMBER_OF_BYTES-eng: 15624
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:33:40.687000000
Stream #0:3(eng): Subtitle: subrip (default)
Metadata:
BPS-eng : 60
DURATION-eng : 00:33:23.254000000
NUMBER_OF_FRAMES-eng: 474
NUMBER_OF_BYTES-eng: 15207
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:33:33.514000000
Stream #0:4(spa): Subtitle: subrip
Metadata:
BPS-eng : 65
DURATION-eng : 00:33:30.177000000
NUMBER_OF_FRAMES-eng: 473
NUMBER_OF_BYTES-eng: 16346
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:33:40.270000000
Stream #0:5(fre): Subtitle: subrip
Metadata:
BPS-eng : 54
DURATION-eng : 00:33:58.622000000
NUMBER_OF_FRAMES-eng: 463
NUMBER_OF_BYTES-eng: 13880
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:34:08.841000000
Stream #0:6(por): Subtitle: subrip
Metadata:
title : PT-PT
BPS-eng : 58
DURATION-eng : 00:33:30.135000000
NUMBER_OF_FRAMES-eng: 479
NUMBER_OF_BYTES-eng: 14728
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:33:40.395000000
Stream #0:7(por): Subtitle: subrip
Metadata:
title : PT-BR
BPS-eng : 52
DURATION-eng : 00:33:30.135000000
NUMBER_OF_FRAMES-eng: 479
NUMBER_OF_BYTES-eng: 13174
_STATISTICS_WRITING_APP-eng: mkvmerge v38.0.0 ('The Silent Type') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-11-02 14:19:53
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:33:40.395000000
Stream #0:8: Subtitle: subrip
Metadata:
DURATION : 00:34:56.804000000
i tried every way but i can't ( -map -metadata )
i also tried to add the metadata to the separate srt file but the output srt was exactly the same
ffmpeg -i input.srt -metadata language="ita" output.srt
another option I tried
ffmpeg -i 1.mkv -c:s mov_text -metadata:s:0:8 title="italiano" -c:v copy -c:a copy out88.mkv
can you help me?

Related

FFMPEG: how to select audio stream without language metadata

I have some source Video files with one or more audio streams inside.
I would to encode each source file with Italian language. Then I can do it.
ffmpeg -i source-file.avi -c:v ... -c:a ... -map 0:a:m:language:ita ...
But some source file has audio stream without Language metadata.
I look that it is possible to set Language metadata with "und" special value. Then I try to select the audio stream with this command:
ffmpeg -i source-file.avi -c:v ... -c:a ... -map 0:a:m:language:ita? -map 0:a:m:language:und? ...
(the "?" char say to ffmpeg that he do not fire exception if the audio stream do not exists).
Unfortunatelly this command do not works... It seems that ffmpeg search the "und" language instead of search a audio stream "without" language.
Video MetaData
This is the video MetaData where audio stream do not have language value:
Input #0, matroska,webm, from 'D:\My-Video.mkv':
Metadata:
title : My-Video
encoder : libebml v1.3.3 + libmatroska v1.4.4
creation_time : 2016-01-20T16:02:03.000000Z
Duration: 01:15:28.93, start: 0.000000, bitrate: 2775 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
BPS : 2387529
BPS-eng : 2387529
DURATION : 01:15:28.920000000
DURATION-eng : 01:15:28.920000000
NUMBER_OF_FRAMES: 113223
NUMBER_OF_FRAMES-eng: 113223
NUMBER_OF_BYTES : 1351616420
NUMBER_OF_BYTES-eng: 1351616420
_STATISTICS_WRITING_APP: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-01-20 16:02:03
_STATISTICS_WRITING_DATE_UTC-eng: 2016-01-20 16:02:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
Metadata:
BPS : 384000
BPS-eng : 384000
DURATION : 01:15:28.928000000
DURATION-eng : 01:15:28.928000000
NUMBER_OF_FRAMES: 141529
NUMBER_OF_FRAMES-eng: 141529
NUMBER_OF_BYTES : 217388544
NUMBER_OF_BYTES-eng: 217388544
_STATISTICS_WRITING_APP: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-01-20 16:02:03
_STATISTICS_WRITING_DATE_UTC-eng: 2016-01-20 16:02:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2(ita): Subtitle: dvd_subtitle, 720x576 (default)
Metadata:
BPS : 2218
BPS-eng : 2218
DURATION : 01:09:57.232000000
DURATION-eng : 01:09:57.232000000
NUMBER_OF_FRAMES: 965
NUMBER_OF_FRAMES-eng: 965
NUMBER_OF_BYTES : 1163769
NUMBER_OF_BYTES-eng: 1163769
_STATISTICS_WRITING_APP: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-01-20 16:02:03
_STATISTICS_WRITING_DATE_UTC-eng: 2016-01-20 16:02:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Can someone help me?
Thanks!

Invalid data stream in media could not be discarded by FFMPEG. Why is it staying and how to discard it?

I have downloaded a [short media][1] i intend to convert then i will use the result as basis to practice and test any and all FFMPEG commands i learn or use later.
That video seems to have an unknown invalid stream which never disappears no matter everything i tried to discard it. When i try to work with it later i get various problems like missing codec or no stream which is not the focus here but the reason why i got stubborn to remove the things i cannot deal with.
The following probing prints a warning in yellow color on last row.
> ffprobe -hide_banner -show_streams Movie_Countdown-youtube_I1vMKZ1kvg0.mov
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Movie_Countdown-youtube_I1vMKZ1kvg0.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2015-05-20T13:45:55.000000Z
Duration: 00:00:10.00, start: 0.000000, bitrate: 11474 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9930 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2015-05-20T13:45:55.000000Z
handler_name : Apple Video Media Handler
encoder : H.264
timecode : 00:00:00:00
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
Metadata:
creation_time : 2015-05-20T13:45:56.000000Z
handler_name : Apple Sound Media Handler
timecode : 00:00:00:00
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
Metadata:
creation_time : 2015-05-20T13:46:11.000000Z
handler_name : Time Code Media Handler
timecode : 00:00:00:00
Unsupported codec with id 0 for input stream 2
Below the streams output. I split the text so you see the warning without searching in the middle.
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Main
codec_type=video
codec_time_base=1/50
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
coded_width=1920
coded_height=1088
closed_captions=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/25
start_pts=0
start_time=0.000000
duration_ts=250
duration=10.000000
bit_rate=9930739
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=250
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2015-05-20T13:45:55.000000Z
TAG:language=eng
TAG:handler_name=Apple Video Media Handler
TAG:encoder=H.264
TAG:timecode=00:00:00:00
[/STREAM]
[STREAM]
index=1
codec_name=pcm_s16le
codec_long_name=PCM signed 16-bit little-endian
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=sowt
codec_tag=0x74776f73
sample_fmt=s16
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=16
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=480000
duration=10.000000
bit_rate=1536000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=480000
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2015-05-20T13:45:56.000000Z
TAG:language=eng
TAG:handler_name=Apple Sound Media Handler
TAG:timecode=00:00:00:00
[/STREAM]
[STREAM]
index=2
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=tmcd
codec_tag=0x64636d74
id=N/A
r_frame_rate=0/0
avg_frame_rate=25/1
time_base=1/25
start_pts=0
start_time=0.000000
duration_ts=250
duration=10.000000
bit_rate=3
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=1
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2015-05-20T13:46:11.000000Z
TAG:language=eng
TAG:handler_name=Time Code Media Handler
TAG:timecode=00:00:00:00
[/STREAM]
I scaled it down and recoded it for starters and i tried to discard the data stream with -dn and failed other methods i will mention at the end.
The output so far suggests that discarding should have worked since alternative datas are 0kB and no stream 2 is listed.
> ffmpeg -hide_banner -dn -i C:\Users\admin-dix\Downloads\Movie_Countdown-youtube_I1vMKZ1kvg0.mov -vf "scale=h=450:w=800" -f mp4 -c:a aac -c:v libx264 mov_countdown.mp4
Output #0, mp4, to 'mov_countdown.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
encoder : Lavf58.45.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 800x450 [SAR 1:1 DAR 16:9], q=-1--1, 0.04 fps, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 2015-05-20T13:45:55.000000Z
handler_name : Apple Video Media Handler
timecode : 00:00:00:00
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2015-05-20T13:45:56.000000Z
handler_name : Apple Sound Media Handler
timecode : 00:00:00:00
encoder : Lavc58.91.100 aac
frame= 250 fps= 43 q=-1.0 Lsize= 342kB time=00:00:10.00 bitrate= 280.1kbits/s speed= 1.7x
video:175kB audio:159kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.710857%
Then ffprobe disagrees, there is still the stream and the warning.
ffprobe mov_countdown.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mov_countdown.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:10.02, start: 0.000000, bitrate: 279 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x450 [SAR 1:1 DAR 16:9], 142 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : Apple Video Media Handler
timecode : 00:00:00:00
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : Apple Sound Media Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
Metadata:
handler_name : Apple Video Media Handler
timecode : 00:00:00:00
Unsupported codec with id 0 for input stream 2
I tried negative mapping as per this answer -map 0:d which failed. I did not understand -discard option as ffmpeg documentation refers to from the -vn,-an,-dn entries as it does not specify a stream.
Why does it do that and how can i remove that stream i do not know and do not want to care about in future tests ?
[1]: Clean Retro Movie Countdown - YouTube from Philippe Moesch https://www.youtube.com/watch?v=I1vMKZ1kvg0
The data stream is a timecode stream. When ffmpeg reads a MOV/MP4 file with such a stream, it stores the timecode as metadata. If the output muxer is MOV/MP4, it will read that metadata and store that timecode as a data track. Add -write_tmcd false to disable this behaviour.

How to use FFmpeg and GeForce Hardware to decode and encode 4K MKV movie to 1080p [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am struggling with the instruction provided to convert a 4k Movie to 1080p so I can run it easier on my plex server.
I have a Geforce 1080Ti and have enable cuda and all the necessary options when building ffmpeg.
I keep getting a weird error and I am stuck at the below point.
Here is my code that I am working on currently
REM #ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
COLOR 0A
TITLE CONVERT 4K TO 1080P USING GEFORCE HW
PUSHD "%~dp0"
SET "FF=C:\MAB\local64\bin-video\ffmpeg.exe"
FOR /R %%G IN (*.mkv) DO (
"%FF%" -hide_banner -hwaccel cuda -y -i "%%~dpnG.mkv" -c:v h264_nvenc -preset slow -pix_fmts yuv420p10le -vf scale='1920:-1' -c:a copy "%%~dpnG(1080p).mkv"
)
ECHO.
PAUSE
EXIT
below is the error output I get when running the above command
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, matroska,webm, from 'Mulan_2020.mkv':
Metadata:
title : mandtv.net
encoder : libebml v1.4.0 + libmatroska v1.6.2
creation_time : 2020-09-10T05:08:02.000000Z
Duration: 01:55:08.70, start: 0.000000, bitrate: 16704 kb/s
Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x1608 [SAR 1:1 DAR 160:67], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
Metadata:
BPS-eng : 15933746
DURATION-eng : 01:55:08.652000000
NUMBER_OF_FRAMES-eng: 165642
NUMBER_OF_BYTES-eng: 13760089087
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: eac3, 48000 Hz, 5.1, fltp (default) (forced)
Metadata:
title : En
BPS-eng : 768000
DURATION-eng : 01:55:08.704000000
NUMBER_OF_FRAMES-eng: 215897
NUMBER_OF_BYTES-eng: 663235584
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2(eng): Subtitle: subrip
Metadata:
title : English
BPS-eng : 35
DURATION-eng : 01:50:28.504000000
NUMBER_OF_FRAMES-eng: 1150
NUMBER_OF_BYTES-eng: 29135
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:3(ger): Subtitle: subrip
Metadata:
title : de
BPS-eng : 2
DURATION-eng : 00:03:07.062000000
NUMBER_OF_FRAMES-eng: 2
NUMBER_OF_BYTES-eng: 53
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:4(ger): Subtitle: subrip
Metadata:
title : de
BPS-eng : 27
DURATION-eng : 01:54:16.482000000
NUMBER_OF_FRAMES-eng: 933
NUMBER_OF_BYTES-eng: 23256
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:5(fre): Subtitle: subrip
Metadata:
title : fr
BPS-eng : 0
DURATION-eng : 01:40:51.510000000
NUMBER_OF_FRAMES-eng: 21
NUMBER_OF_BYTES-eng: 380
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:6(fre): Subtitle: subrip
Metadata:
title : fr
BPS-eng : 29
DURATION-eng : 01:54:19.902000000
NUMBER_OF_FRAMES-eng: 806
NUMBER_OF_BYTES-eng: 25098
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:7(spa): Subtitle: subrip
Metadata:
title : es
BPS-eng : 2
DURATION-eng : 00:03:21.201000000
NUMBER_OF_FRAMES-eng: 3
NUMBER_OF_BYTES-eng: 73
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:8(spa): Subtitle: subrip
Metadata:
title : es
BPS-eng : 30
DURATION-eng : 01:43:53.693000000
NUMBER_OF_FRAMES-eng: 783
NUMBER_OF_BYTES-eng: 24134
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:9(ita): Subtitle: subrip
Metadata:
title : it
BPS-eng : 2
DURATION-eng : 00:03:08.522000000
NUMBER_OF_FRAMES-eng: 2
NUMBER_OF_BYTES-eng: 67
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:10(ita): Subtitle: subrip
Metadata:
title : it
BPS-eng : 27
DURATION-eng : 01:54:16.649000000
NUMBER_OF_FRAMES-eng: 784
NUMBER_OF_BYTES-eng: 23506
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:11(por): Subtitle: subrip
Metadata:
title : pt
BPS-eng : 27
DURATION-eng : 01:54:16.649000000
NUMBER_OF_FRAMES-eng: 784
NUMBER_OF_BYTES-eng: 23202
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:12(por): Subtitle: subrip
Metadata:
title : pt
BPS-eng : 2
DURATION-eng : 00:03:08.522000000
NUMBER_OF_FRAMES-eng: 2
NUMBER_OF_BYTES-eng: 61
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:13(rus): Subtitle: subrip (default)
Metadata:
title : ru
BPS-eng : 0
DURATION-eng : 01:37:43.480000000
NUMBER_OF_FRAMES-eng: 9
NUMBER_OF_BYTES-eng: 420
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:14(rus): Subtitle: subrip
Metadata:
title : ru
BPS-eng : 50
DURATION-eng : 01:44:17.000000000
NUMBER_OF_FRAMES-eng: 850
NUMBER_OF_BYTES-eng: 39721
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:15(ukr): Subtitle: subrip
Metadata:
title : uk
BPS-eng : 50
DURATION-eng : 01:43:53.650000000
NUMBER_OF_FRAMES-eng: 848
NUMBER_OF_BYTES-eng: 39165
_STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-09-10 05:08:02
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_nvenc))
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (subrip (srt) -> ass (ssa))
Press [q] to stop, [?] for help
[h264_nvenc # 000002306685ccc0] 10 bit encode not supported
[h264_nvenc # 000002306685ccc0] Provided device doesn't support required NVENC features
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Can anyone spot what I'm missing?
#ECHO OFF
SETLOCAL
COLOR 0A
TITLE CONVERT 4K TO 1080P WITH GEFORCE HW ACCELERATION
:---------------------------------------------------------------------------------
REM CHANGE WORKING DIRECTORY TO THE SCRIPT'S DIRECTORY
PUSHD "%~dp0"
:---------------------------------------------------------------------------------
REM MAXIMIZE CMD WINDOW
IF NOT "%1"=="MAX" START /MAX CMD /D /C %0 MAX & EXIT /B
:---------------------------------------------------------------------------------
REM POINT FF VAR TO FFMPEG.EXE'S FULL PATH
SET "FF=C:\MAB\local64\bin-video\ffmpeg.exe"
REM RECURSIVELY SEARCH FOR VIDEO IN THE WORKING DIRECTORY
FOR /R %%G IN (*.mkv) DO (
"%FF%" -hide_banner -hwaccel cuda -y -i "%%~dpnG.mkv" -c:v nvenc_hevc -preset p7 -tune hq -vf scale='1920:-1' -c:a copy "%%~dpnG(1080p).mkv"
)
:---------------------------------------------------------------------------------
REM CHANGE THE COLOR OF THE CMD WINDOW WHEN FFMPEG HAS FINISHED
COLOR 0E
ECHO=
ECHO FFMPEG HAS FINISHED & ECHO=
PAUSE

how do i extract subtitles from a video using FFMPEG?

I tried with several videos but I am encountering the same error as:
'Output file #0 does not contain any stream'
if soft sub
ffmpeg -hide_banner -i 1.mkv
.
Input #0, matroska,webm, from '1.mkv':
Metadata:
encoder : libebml v1.3.6 + libmatroska v1.4.9
creation_time : 2020-06-27T08:04:52.000000Z
Duration: 01:02:06.37, start: 0.000000, bitrate: 662 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
Metadata:
BPS-eng : 500501
DURATION-eng : 01:02:05.834000000
NUMBER_OF_FRAMES-eng: 89420
NUMBER_OF_BYTES-eng: 233098262
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-06-27 08:04:52
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Subtitle: subrip
Metadata:
title : English#BonsaiHD.Fun
BPS-eng : 25
DURATION-eng : 01:01:07.500000000
NUMBER_OF_FRAMES-eng: 449
NUMBER_OF_BYTES-eng: 11798
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-06-27 08:04:52
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2(eng): Subtitle: subrip (default) (forced)
Metadata:
title : English_Forced##BonsaiHD.Fun
BPS-eng : 1
DURATION-eng : 00:57:12.917000000
NUMBER_OF_FRAMES-eng: 21
NUMBER_OF_BYTES-eng: 448
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-06-27 08:04:52
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:3(eng): Subtitle: subrip
Metadata:
title : English#BonsaiHD.Fun
BPS-eng : 36
DURATION-eng : 00:57:14.833000000
NUMBER_OF_FRAMES-eng: 594
NUMBER_OF_BYTES-eng: 15793
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-06-27 08:04:52
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:4(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 160 kb/s (default)
Metadata:
BPS-eng : 160000
DURATION-eng : 01:02:06.368000000
NUMBER_OF_FRAMES-eng: 116449
NUMBER_OF_BYTES-eng: 74527360
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2020-06-27 08:04:52
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
this video has 5 streams; 0:0 is video & 0:4 is audio & 0:1, 0:2, 0:3 are subtitles
to extract the sub in 0:1 stream in my file 1.mkv to subtitle1.ass or subtitle1.srt file
ffmpeg -v error -stats -i 1.mkv -vn -an -map 0:1 subtitle1.ass
STEP 1 : First list all the audio stream
STEP 2 : ffmpeg -i VIDEO.mkv, ffmpeg -i input.mkv
STEP 3 : Compile the command to extract the audio track

FFMPEG conversion error from MKV to MP4 using libfdk_aac codec

The purpose of doing this is because my "Smart" samsung TV doesn't play MKV files.
This thread mentions that there is no need for video conversion, just changing the container might suffice. After reading multiple threads on how to change the container of MKV to MP4, I downloaded and compiled the FFMPEG with libfdk_aac support from here. I tried converting a sample MKV file using this command:
ffmpeg -i "C:\VideoTest\Sample1.mkv" -c:v copy -c:a libfdk_aac -b:a 384k "C:\VideoTest\Sample2.mp4"
but getting the following errors (copied from command prompt):
[hevc # 0000000000308ae0] Could not find ref with POC 113
[hevc # 0000000000308ae0] Could not find ref with POC 111
[hevc # 0000000000308ae0] Could not find ref with POC 109
[hevc # 0000000000308ae0] Could not find ref with POC 107
Input #0, matroska,webm, from 'C:\VideoTest\Sample-1.mk
v':
Metadata:
encoder : libebml v1.3.0 + libmatroska v1.4.1
creation_time : 2014-07-16 08:54:02
Duration: 00:00:58.68, start: 0.042000, bitrate: 3520 kb/s
Chapter #0.0: start 0.000000, end 58.717000
Metadata:
title : Chapter 4
Stream #0:0: Video: hevc (Main), yuv420p(tv), 1920x816, SAR 1:1 DAR 40:17, 2
4 fps, 24 tbr, 1k tbn, 1k tbc (default)
Metadata:
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 64bit built on
Jun 9 2014 15:16:27
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 64bit buil
t on Jun 9 2014 15:16:27
_STATISTICS_WRITING_DATE_UTC: 2014-07-16 08:54:02
_STATISTICS_WRITING_DATE_UTC-eng: 2014-07-16 08:54:02
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
BPS : 2733260
BPS-eng : 2733260
DURATION : 00:00:58.667000000
DURATION-eng : 00:00:58.667000000
NUMBER_OF_FRAMES: 1408
NUMBER_OF_FRAMES-eng: 1408
NUMBER_OF_BYTES : 20044023
NUMBER_OF_BYTES-eng: 20044023
Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s (default)
Metadata:
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 64bit built on
Jun 9 2014 15:16:27
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 64bit buil
t on Jun 9 2014 15:16:27
_STATISTICS_WRITING_DATE_UTC: 2014-07-16 08:54:02
_STATISTICS_WRITING_DATE_UTC-eng: 2014-07-16 08:54:02
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
BPS : 767986
BPS-eng : 767986
DURATION : 00:00:58.625000000
DURATION-eng : 00:00:58.625000000
NUMBER_OF_FRAMES: 5496
NUMBER_OF_FRAMES-eng: 5496
NUMBER_OF_BYTES : 5627904
NUMBER_OF_BYTES-eng: 5627904
Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle, 1920x1080 (default)
Metadata:
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 64bit built on
Jun 9 2014 15:16:27
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 64bit buil
t on Jun 9 2014 15:16:27
_STATISTICS_WRITING_DATE_UTC: 2014-07-16 08:54:02
_STATISTICS_WRITING_DATE_UTC-eng: 2014-07-16 08:54:02
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
BPS : 17485
BPS-eng : 17485
DURATION : 00:00:56.750000000
DURATION-eng : 00:00:56.750000000
NUMBER_OF_FRAMES: 40
NUMBER_OF_FRAMES-eng: 40
NUMBER_OF_BYTES : 124036
NUMBER_OF_BYTES-eng: 124036
Output #0, mp4, to 'C:\VideoTest\Sample.mp4':
Metadata:
encoder : Lavf56.1.100
Chapter #0.0: start 0.000000, end 58.675000
Metadata:
title : Chapter 4
Stream #0:0: Video: hevc ([35][0][0][0] / 0x0023), yuv420p, 1920x816 [SAR 1:
1 DAR 40:17], q=2-31, 24 fps, 16k tbn, 1k tbc (default)
Metadata:
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 64bit built on
Jun 9 2014 15:16:27
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 64bit buil
t on Jun 9 2014 15:16:27
_STATISTICS_WRITING_DATE_UTC: 2014-07-16 08:54:02
_STATISTICS_WRITING_DATE_UTC-eng: 2014-07-16 08:54:02
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
BPS : 2733260
BPS-eng : 2733260
DURATION : 00:00:58.667000000
DURATION-eng : 00:00:58.667000000
NUMBER_OF_FRAMES: 1408
NUMBER_OF_FRAMES-eng: 1408
NUMBER_OF_BYTES : 20044023
NUMBER_OF_BYTES-eng: 20044023
Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, 5.1
, s16, 128 kb/s (default)
Metadata:
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 64bit built on
Jun 9 2014 15:16:27
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 64bit buil
t on Jun 9 2014 15:16:27
_STATISTICS_WRITING_DATE_UTC: 2014-07-16 08:54:02
_STATISTICS_WRITING_DATE_UTC-eng: 2014-07-16 08:54:02
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
BPS : 767986
BPS-eng : 767986
DURATION : 00:00:58.625000000
DURATION-eng : 00:00:58.625000000
NUMBER_OF_FRAMES: 5496
NUMBER_OF_FRAMES-eng: 5496
NUMBER_OF_BYTES : 5627904
NUMBER_OF_BYTES-eng: 5627904
encoder : Lavc56.0.101 libfdk_aac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (dts (dca) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[mp4 # 0000000003be0500] Invalid DTS: 656 PTS: -672 in output stream 0:0
av_interleaved_write_frame(): Invalid argument
[libfdk_aac # 00000000042fa640] Trying to remove 1024 samples, but the queue is
empty
[mp4 # 0000000003be0500] Encoder did not produce proper pts, making some up.
[libfdk_aac # 00000000042fa640] Trying to remove 1024 samples, but the queue is
empty
frame= 2 fps=0.0 q=-1.0 Lsize= 96kB time=00:00:00.04 bitrate=18415.0kbit
s/s
video:95kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing ov
erhead: 0.570364%
Conversion failed!
Also tried using this command:
ffmpeg -i input.wav -c:a libfdk_aac -b:a 128k output.mp4
But this screws up the video quality and I start seeing some bad pixelated patches during the playback.
Any help would be appreciated.
Just an FYI: I got this far by reading blogs and posts. I have 0 knowledge about video conversion.
If you can't play the video after your first command, then (evidently) your TV can't deal with the originally encoded video stream. So - give a shot at re-encoding with another codec. This will produce a high quality re-encoded version (it will take a while to re-encode):
ffmpeg -i input.mkv -qscale 1 -c:a libfdk_aac -b:a 384k output.mp4

Resources