ffmpeg failed to drop stream with unsupported codec [duplicate] - ffmpeg

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.

Related

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.

cutting mp4 with codec copy results no audio in browser

I'm editing a video clip with ffmpeg. The original does not play in Firefox browser by itself. It does normally in Chromium. I do something like:
ffmpeg -ss 00:05:10 -i INPUT.mp4 -c copy OUTPUT.mp4
the resulting clip plays in Firefox but there's no audio. This happens in Firefox (82.0.3), but not in Chromium (86.0.4240.75). In chromium the sound is ok.
If audio is reencoded with
ffmpeg -ss 00:05:10 -i INPUT.mp4 -c:v copy -ab 360kb OUTPUT.mp4
resulting clip is playing ok in Firefox.
Could anyone explain what is happening here and is it possible to cut the mp4 without reencoding audio resulting in a clip that plays in Firefox too?
Some data:
ffmpeg version 3.4.8-0ubuntu0.2
ffprobe INPUT.mp4:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'INPUT.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: iso4avc1isom
creation_time : 2020-11-13T18:45:37.000000Z
com.apple.proapps.clipID: INPUT
com.blackmagic-design.camera.dateRecorded: 2020:11:13
com.apple.proapps.cameraName: 0
com.blackmagic-design.camera.uuid: BDB766E79E646CBB82E3EB986EA1EA-0
Duration: 02:01:38.00, start: 0.000000, bitrate: 6047 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 5909 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
encoder : H264/AVC
timecode : 19:45:35:04
Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
timecode : 19:45:35:04
Stream #0:2(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
timecode : 19:45:35:04
ffprobe OUTPUT.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'OUTPUT.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 01:34:48.02, start: -0.016000, bitrate: 6022 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 5889 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 25600 tbc (default)
Metadata:
handler_name : VideoHandler
timecode : 19:45:35:04
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
handler_name : TimeCodeHandler
timecode : 19:45:35:04
ffprobe the OUTPUT.mp4 that has audio re-encoded and works in Firefox:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 01:34:48.04, start: 0.000000, bitrate: 6160 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 5889 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 25600 tbc (default)
Metadata:
handler_name : VideoHandler
timecode : 19:45:35:04
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 265 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
handler_name : TimeCodeHandler
timecode : 19:45:35:04
EDIT:
I'm providing links to original files, but a bit of warning, they are 4-5GB big each:
original recording from blackmagic switcher/capture/recorder (this does not play in firefox at all, but does in Chromium)
cut version made with -codec copy (plays in firefox but no audio. plays in chromium ok)
cut version with re-encoded audio (plays ok in both firefox and chromium)

ffmpeg: concat and encode with one command

I have a script that automates encode and concat a series of input video files.
I'm trying to get encode and concat in a single command.
At the moment it does not work causing immense empty pauses in the final video output.
I would like to get the result with concat demux instead of concat protocol because it is much harder to automate in a script
Do you know if it is possible to archive this result with concat demux?
Thanks a lot!
Massimo
ENCODE / CONCAT 1080p
for f in ./*.mp4; do echo "file '$f'" >> list.txt; done
ffmpeg -f concat -safe 0 -y -i list.txt -i ../logo/logo.png -c:a aac -b:a 384k -ar 48000 -ac 2 -af aresample=async=1000 -c:v libx264 -x264opts keyint=50:min-keyint=50:no-scenecut -bf 0 -r 25 -b:v 4800k -maxrate 4800k -bufsize 3000k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" ../buffer/1080set.mp4
It seems to add long pause at low frame-rate:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb03f05e600] Auto-inserting h264_mp4toannexb bitstream filter
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:52.56 bitrate=1348.0kbits
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:56.57 bitrate=1343.3kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:00.65 bitrate=1338.5kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:02.29 bitrate=1336.5kbits/
More than 1000 frames duplicated
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2016-02-27T22:25:49.000000Z
encoder : HandBrake 0.10.5 2016021100
Duration: 00:06:29.87, start: 0.000000, bitrate: 3447 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 768x432, 3282 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2016-02-27T22:25:49.000000Z
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
Metadata:
creation_time : 2016-02-27T22:25:49.000000Z
handler_name : Stereo
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
creation_time : 2016-02-27T18:52:37.000000Z
Duration: 00:07:16.93, start: 0.000000, bitrate: 1184 kb/s
Stream #1:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 991 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2016-02-27T18:52:37.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2016-02-27T18:52:37.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-06-27T17:58:17.000000Z
Duration: 00:05:05.05, start: 0.000000, bitrate: 2622 kb/s
Stream #2:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2301 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-27T17:58:17.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2017-06-27T17:58:17.000000Z
handler_name : Alias Data Handler
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '4.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-06-27T17:53:32.000000Z
Duration: 00:06:47.36, start: 0.000000, bitrate: 3144 kb/s
Stream #3:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2819 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-27T17:53:32.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2017-06-27T17:53:32.000000Z
handler_name : Alias Data Handler
concat demxuer
The concat demuxer needs all inputs to have the same formats, number of streams, type of streams, order of streams (or use exact_stream_id), timebase, frame rate, audio sample rate, audio channel layout, and it is also recommended to have the same width and height.
In your case the timebase (tbn) of the first input is different than the rest. You can pre-process this input to conform it to the others:
ffmpeg -i 1.mp4 -c copy -video_track_timescale 25k 1_reset.mp4
Then run your command using the concat demuxer.
concat filter
Because you're re-encoding anyway it may be easier for you to use the concat filter. This allows you to conform each input using various filters then concate all in one command. There are several examples of such use on this site.

HTML5 mp4 embbed subtitles

It is possible to use buildin mov_text MP4 subtitles for HTML5 video player?
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.66.102
Duration: 01:28:55.00, start: 0.000000, bitrate: 908 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x400 [SAR 1:1 DAR 44:25], 772 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(rus): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
Stream #0:3(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
Metadata:
handler_name : SubtitleHandler
Extract subtitles as WebVTT:
ffmpeg -i input.mp4 -map 0:s:0 subs_rus.vtt -map 0:s:1 subs_eng.vtt
Add the subtitles to your HTML5 <video> element:
<track src="subs_rus.vtt" kind="subtitles" srclang="ru" label="русский">
<track src="subs_eng.vtt" kind="subtitles" srclang="en" label="English">

Embedding timed text metadata in MP4

Is it possible to manually embed timed text metadata into MP4 files?
I have a TTML / SRT file with the metadata. I just need to embed the text data without doing any encoding the video / audio.
EDIT:
We used to do the metadata injecting using on Wowza server which we use for live streaming. What I need to do is manually inject the metadata in to prerecorded MP4 files without running the video through Wowza.
Here is one such video file that was processed by Wowza:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'metadata-back.mp4':
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2015-04-16 11:12:39
Duration: 00:00:11.70, start: 0.000000, bitrate: 1373 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 1352 kb/s, 28.60 fps, 30 tbr, 90k tbn, 60 tbc (default)
Metadata:
creation_time : 2015-04-16 11:12:39
handler_name : WowzaStreamingEngine
encoder : WowzaStreamingEngine
Stream #0:1(eng): Audio: speex (spex / 0x78657073), 16000 Hz, mono, s16, 17 kb/s (default)
Metadata:
creation_time : 2015-04-16 11:12:39
handler_name : WowzaStreamingEngine
Stream #0:2(eng): Data: none (amf0 / 0x30666D61), 0 kb/s (default)
Metadata:
creation_time : 2015-04-16 11:12:39
handler_name : WowzaStreamingEngine
Now if I run the command ffmpeg -i new-meta.mp4 -i sub.srt -c copy -c:s mov_text -movflags +faststart out.mp4 and if I run ffmpeg -i out.mp4, I get this:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.4.101
Duration: 00:00:07.27, start: 0.000000, bitrate: 925 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1366x768 [SAR 1:1 DAR 683:384], 920 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
Now as you can see the text is embedded with a different codec (is this the right term?). Also I dont see an audio track as well.
Hope my question is clear enough. I need a way to embed metadata (from srt / ttml) into an MP4 video it should be embedded in amf format (again is this the right term?)
ffmpeg -i in.mp4 -i subs.srt -c copy -c:s mov_text -movflags +faststart out.mp4
Support for 3GPP TS 26.245 Timed Text ("mov_text") in MP4 may vary according to the player.

Resources