I have two video (with audio) clips that I want to join. The first clip has the following format:
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 358 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
audio service type: main
And the second:
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240, 88 kb/s, 8 fps, 8 tbr, 16384 tbn, 16 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 11025 Hz, mono, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
audio service type: main
I want to join the two clips; the first followed by the latter while keeping the format options of the second clip.
Based on reading the documentation and other questions I have reached the following command:
ffmpeg -i secondClip.mp4 -i firstClip.mpg -filter_complex "[1:v:0][0:v:0]scale2ref=oh*mdar:ih[2nd][ref],[2nd][1:a:0][ref][0:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4
This gives the following errors:
Stream mapping:
Stream #0:0 (h264) -> scale2ref:ref
Stream #0:1 (ac3) -> concat:in1:a0
Stream #1:0 (mpeg2video) -> scale2ref:default
Stream #1:1 (mp2) -> concat:in0:a0
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_concat_1 # 0000017896b6f400] Input link in1:v0 parameters (size 320x240, SAR 0:1) do not match the corresponding output link in0:v0 parameters (426x240, SAR 640:639)
[Parsed_concat_1 # 0000017896b6f400] Failed to configure output pad on Parsed_concat_1
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
Related
Env: Windows7, ffmpeg 4.2.2
copy the first 10 seconds from long.mp4 to UNO.mp4
copy sec 120 to sec 130 from long.mp4 to DUE.mp4
create List.txt with
file 'C:\Users\Admin\Videos\UNO.mp4'
file 'C:\Users\Admin\Videos\DUE.mp4'
here the ffprobe output of the two files:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'UNO.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:10.04, start: 0.000000, bitrate: 671 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360 [SAR 1:1 DAR 16:9], 536 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 09/18/2020.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 09/18/2020.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'DUE.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:11.96, start: 0.000000, bitrate: 657 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360 [SAR 1:1 DAR 16:9], 524 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 09/18/2020.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 09/18/2020.
use the two files as input to
ffmpeg -f concat -safe 0 -i "C:\Users\Admin\Videos\List.txt" -c copy "C:\Users\Admin\Videos\mergedVideo.mp4"
it outputs:
mov,mp4,m4a,3gp,3g2,mj2 # 00be7f80] Auto-inserting h264_mp4toannexb bitstream filter
nput #0, concat, from 'C:\Users\Admin\Videos\List.txt':
Duration: N/A, start: 0.000000, bitrate: 825 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 697 kb/s, 25 fps, 25
tbr, 90k tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
handler_name : SoundHandler
utput #0, mp4, to 'C:\Users\Admin\Videos\mergedVideo.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 624x352 [SAR 1:1 DAR 39:22], q=2-31, 697 kb/s, 25
fps, 25 tbr, 90k tbn, 90k tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
handler_name : SoundHandler
tream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
then a long series of :
mp4 # 00c43c40] Non-monotonous DTS in output stream 0:0; previous: 899370, current: 720000; changing to 899371. This may result in incorrect timestamps in the output file.
at end as last messages :
rame= 552 fps=528 q=-1.0 Lsize= 2220kB time=00:00:20.01 bitrate= 908.4kbits/s speed=19.2x
ideo:1873kB audio:329kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.827539%
When i play the output mergedVideo.mp4 with ffplay, it does not gove errors
it is only a time stamp problem, or some frames or some audio are lost ?
in the latter case, is there a parameter to correct the problem, or i have to re-encode ?
(to further test, i tried with avidemux an it concats UNO.mp4 and DUE.mp4 without re-encoding)
Thanks in advance to all for the support
Maurizio
First of all, unless you call FFmpeg with the -xerror option (which you didn't) "Non-monotonous DTS..." message is not an error. It's just a warning. It is just informing what it's doing for you, and thankfully its automatic adjustment indeed worked for your case base on your description.
It is making the adjustment because you are concatenate-and-copying streams, of which data frame carries timestamp (unlike WAV or MPEG streams). The concat demuxer likely cannot adjust the timestamp in the stream data on the fly (to avoid the warnings/corrections from the main ffmpeg program).
The bottom line. If the warning messages must go, change the log level to ignore warning: -loglevel error.
Reference ffmpeg.c Lines 817-834
Somebody can help me for this error please :
"D:\Enregistrements>"D:\ffmpeg-full_build\bin\ffmpeg.exe" -hide_banner
-i "D:\Enregistrements\Test.mp4"
-vf "select='between(t,0.00,39.37)+between(t,66.32,159.05)',setpts=N/FRAME_RATE/TB"
-af "select='between(t,0.00,39.37)+between(t,66.32,159.05)',asetpts=N/SAMPLE_RATE/TB"
"D:\Enregistrements\Test_Coupe0 (1).mp4"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Enregistrements\Test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.4.101
Duration: 00:05:00.20, start: 0.000000, bitrate: 2215 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 (SAR 1:1 DAR 16:9), 2099 kb/s, 25 fps, 25 tbr, 25k tbn (default)
Metadata:
handler_name : Mainconcept MP4 Video Media Handler
vendor_id : [0][0][0][0]
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
(Parsed_select_0 # 0000017d2feac700) Media type mismatch between the 'Parsed_select_0' filter output pad 0 (video) and the 'Parsed_asetpts_1' filter input pad 0 (audio)
(AVFilterGraph # 0000017d2feac680) Cannot create the link select:0 -> asetpts:0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:1
Conversion failed!*
Thank you
While converting avi video to ogv, there is a color problem in output file.
How can I solve this issue ?
normal colors altered colors
Actually a part of the problem is from the player - so weak question
Command using ffmpeg-3.3.2-1.mga6.tainted :
ffmpeg -i dscn0146.avi -pix_fmt yuv422p -s 640x480 dscn0146_hq.ogv -y
And input metadata:
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'dscn0146.avi':
Metadata:
encoder :
maker : NIKON
model : COOLPIX S3500
creation_time : 2017-07-22 12:09:06
Duration: 00:00:07.33, start: 0.000000, bitrate: 11091 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 10770 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> vorbis (libvorbis))
Processes normaly, but fires a warning:
[swscaler # 0xd3c3a0] deprecated pixel format used, make sure you did set range correctly
Output metadata:
Output #0, ogv, to 'dscn0146_hq.ogv':
Metadata:
model : COOLPIX S3500
maker : NIKON
encoder : Lavf57.71.100
Stream #0:0: Video: theora (libtheora), yuv422p(progressive), 640x480, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libtheora
model : COOLPIX S3500
maker : NIKON
Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp
Metadata:
encoder : Lavc57.89.100 libvorbis
model : COOLPIX S3500
maker : NIKON
this working code
ffmpeg -i totoa.avi -c:v libtheora -q:v 10 -c:a libvorbis -q:a 5 -s 640x480 -y toto.ogv
Am converting a DVD extraction from an MKV container to an MPEG2 file. This is the command I am using:
ffmpeg -i title04.mkv -c:v copy -c:a copy title04.m2v
It creates the file but with no audio. Am not sure what I am missing as it isn't throwing any error (and usually if a stream isn't compatible with a container it complains).
Here is the output. Any ideas?
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, matroska,webm, from 'title04.mkv':
Metadata:
encoder : libmakemkv v1.8.12 (1.3.0/1.4.1) darwin(x86-release)
creation_time : 2014-08-28 19:36:24
Duration: 00:00:11.34, start: 0.000000, bitrate: 4979 kb/s
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv), 720x480 [SAR 8:9 DAR 4:3], max. 7500 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s (default)
Metadata:
title : Stereo
Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480 (default)
Output #0, mpeg2video, to 'title04.m2v':
Metadata:
encoder : Lavf55.48.100
Stream #0:0(eng): Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, max. 7500 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 340 fps=0.0 q=-1.0 Lsize= 4738kB time=00:00:11.31 bitrate=3431.4kbits/s
video:4738kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
m2v (mpeg 2 video) is a video only container. The audio stream is not included.
You should use .mpg or .mpeg as container format.
I am trying to stream video from my webcam to AkamaiHD service using ffmpeg (like it is implemented in Flash Media Live Encoder)
ffmpeg -f dshow -i video="Webcam C110" -s 640x360 -aspect 16:9 -profile:v baseline - pix_fmt yuv420p -vcodec libx264 -f flv "rtmp://..."
...
Input #0, dshow, from 'video=Webcam C110':
Duration: N/A, start: 31296.194000, bitrate: N/A
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 tbr, 10000k tbn, 30 tbc
Output #0
Metadata:
encoder : Lavf55.8.102
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 1k tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
....
The video is sreamed, but when I try to view it at http://mediapm.edgesuite.net/edgeflash/public/zeri/debug/Main.html?url=myplayback_url/manifest.f4m
it is not displayed.
I've found out that if the video is recorded using FMLE and restreamed to akamai, then HLS stream is played.
ffmpeg -re -i sample.f4v -c copy -f flv "rtmp://..."
....
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.f4v':
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2018-10-06 09:23:33
Duration: 00:01:01.77, start: 0.460000, bitrate: 718 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 624 kb/s, 30 tbr, 1k tbn, 48 tbc
Metadata:
creation_time : 2018-10-06 09:23:33
handler_name : MainConcept
Output #0
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
encoder : Lavf55.8.102
Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 624 kb/s, 1k tbn, 1k tbc
Metadata:
creation_time : 2018-10-06 09:23:33
handler_name : MainConcept
Stream mapping:
Stream #0:0 -> #0:0 (copy)
....
It seems that the problem is with h.264 codec configuration, but I have found no solution yet.
Could you please advice, how can I implement streaming like FMLE using ffmpeg?
I think for Akamai you need authentication for the RTMP entrypoint which I don't believe is supported in the librtmp used by ffmpeg.
Have a look at this thread over at Wowza for more information.
If you think it is a codec issue then instead of copy the codec you could try encoding it using -c:v libx264 as the video codec and -c:a libfaac for audio