How to concatenate

Questions involving a Windows version of FFmpeg.
Post Reply
anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

How to concatenate

Post by anuswara » Sat May 04, 2019 3:01 pm

Hi, I downloaded these files (at max resolution), in this order (perhaps something is wrong with one file?):

https://vimeo.com/195782736
https://vimeo.com/196725716
https://vimeo.com/195776765
https://vimeo.com/196651176
https://vimeo.com/195781480

each video offers:

0:0 video
0:1 audio
0:2 "unknown to ffmpeg"

Foreword:
Notice that -safe 0 doesnt work: the empty spaces are not accepted:
that is strange because it worked fine with "complex" titles like
"Motion on TVs - Black Frame Insertion and PWM dimming (2_5) - Rtings.com-lGeM6S_m9pI.webm"
hmmmmmm

therefore I changed the titles into
a.mp4, b.mp4.......e.mp4
to avoid the error. Amen.

Question:
I want to simply concatenate them.

I tried:
ffmpeg -f concat -i lista.txt -c copy concatenated.mp4

ffmpeg -i a.mp4 -i b.mp4 -i c.mp4 d.mp4 e.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] [3:v] [3:a] [4:v] [4:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" concatenated.mp4
(to avoid the stream that ffmpeg does not recognize),
then I edited concat=n=5
due to the 5 videos instead of 2 only....
then I added -map 0 -c copy....,
then
ffmpeg -f concat -i files.txt -vcodec copy -acodec copy concatenated.mp4


and much other that I dont remember.
I always failed.

Addendum: obviously NO recode ;)
Only if I notice (like in the past!) that a simple "concatenate" let the Mbps to drop down drastically, then I could add something like
-map "[v]" -map "[a]" -b:v 95000k
(that worked fine).


thanks for a working string for the 5 videos :)
...warmly hoping that the output will be in sync.

best,

PS:
[mp4 @ 009ccfc0] Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

I doubt that a camera of 2017 is using a codec unknown to ffmpeg.

Reino
Posts: 59
Joined: Thu Aug 22, 2013 5:14 pm
Contact:

Re: How to concatenate

Post by Reino » Sun May 05, 2019 12:07 pm

anuswara wrote:
Sat May 04, 2019 3:01 pm
Notice that -safe 0 doesnt work: the empty spaces are not accepted
'vimeo_mux.txt':

Code: Select all

file 'D:\temp\Sony Cyber-shot RX100 V sample movie_ Daylight handheld _ 4k _ 24p.mp4'
file 'D:\temp\Sony Cyber-shot RX100 V sample movie_ indoor handheld _ 4k _ 24p _ 400 ISO.mp4'

Code: Select all

ffmpeg-N-93674-g1e01f66-win32-static_legacy.exe -hide_banner -f concat -safe 0 -i "vimeo_mux.txt"
[mov,mp4,m4a,3gp,3g2,mj2 @ 05358900] st: 0 edit list: 1 Missing key frame while searching for timestamp: 1001
[mov,mp4,m4a,3gp,3g2,mj2 @ 05358900] st: 0 edit list 1 Cannot find an index entry before timestamp: 1001.
[mov,mp4,m4a,3gp,3g2,mj2 @ 05358900] Auto-inserting h264_mp4toannexb bitstream filter
[concat @ 051e8dc0] Could not find codec parameters for stream 2 (Unknown: none): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, concat, from '..\vimeo_mux.txt':
  Duration: N/A, start: 0.000000, bitrate: 100221 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/iec61966-2-4), 3840x2160 [SAR 1:1 DAR 16:9], 98685 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2016-11-16T13:16:34.000000Z
      handler_name    : Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      creation_time   : 2016-11-16T13:16:34.000000Z
      handler_name    : Sound Media Handler
    Stream #0:2: Unknown: none
At least one output file must be specified
No problem.
anuswara wrote:
Sat May 04, 2019 3:01 pm
[mp4 @ 009ccfc0] Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
See https://en.wikipedia.org/wiki/Compariso ... er_formats.
You could try to mux to *.mov instead:

Code: Select all

ffmpeg -f concat -safe 0 -i "vimeo_mux.txt" -c copy vimeo_mux.mov
anuswara wrote:
Sat May 04, 2019 3:01 pm
(to avoid the stream that ffmpeg does not recognize)
FFmpeg should automatically ignore the unknown stream. If your (old?) binary doesn't, then you could try:

Code: Select all

ffmpeg -f concat -safe 0 -i "vimeo_mux.txt" -map 0:0 -map 0:1 -c copy vimeo_mux.mov

anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

Re: How to concatenate

Post by anuswara » Mon May 06, 2019 5:18 pm

Hi, thanks for your reply.

I am using your latest build April 2019.

with lista2.txt =

file 'a.mp4'
file 'b.mp4'
file 'c.mp4'
file 'd.mp4'
file 'e.mp4'

(I renamed each file to avoid syntax error with " , ' ' , ' )

I did as you said:

ffmpeg -hide_banner -f concat -safe 0 -i "lista2.txt" concatenated.mp4

I go:

x264 [error]: malloc of size 26200576 failedme=00:00:01.38 bitrate= 0.3kbits/s speed=0.094x
Video encoding failed
[aac @ 090ad980] Qavg: 174.307
[aac @ 090ad980] 2 frames left in the queue on closing
Conversion failed!

the strange:
1) I dont want to convert them, only concatenate ("concat").
2) only 0.3kbits ?

Then, with your command it seems all OK,
but my Tv Player doesnt accept mov.
My purposes is to leave the file untouched, just concatenate. But not bad, I will try to put the MOV into a usb into another TVset.

thanks.

PS: then,
with
ffmpeg version N-93674-g1e01f66-Reino Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.3.0 (GCC)


ffmpeg -f concat -safe 0 -i "lista.txt" -map 0:0 -map 0:1 -c copy concatenated.mp4

Stream #0:2: Unknown: none
[mp4 @ 094630c0] Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times

anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

Re: How to concatenate

Post by anuswara » Mon May 06, 2019 5:41 pm

PS2: the "appended" videos are out of sync.

Reino
Posts: 59
Joined: Thu Aug 22, 2013 5:14 pm
Contact:

Re: How to concatenate

Post by Reino » Mon May 06, 2019 11:05 pm

anuswara wrote:
Mon May 06, 2019 5:18 pm
I did as you said:

ffmpeg -hide_banner -f concat -safe 0 -i "lista2.txt" concatenated.mp4
That's not what I said...
Reino wrote:
Sun May 05, 2019 12:07 pm

Code: Select all

ffmpeg -f concat -safe 0 -i "vimeo_mux.txt" -c copy vimeo_mux.mov
Why are you trying to create a mp4-file again when FFmpeg already told you that it doesn't support pcm_s16be in mp4? That's why I suggested mov, but mkv would do as well.
And if you don't want to convert the video, why don't you include -c copy to perform a streamcopy?!

anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

Re: How to concatenate

Post by anuswara » Tue May 07, 2019 1:21 am

hmmmmmm

ffmpeg -hide_banner -f concat -safe 0 -i "lista2.txt" concatenated.mp4
you said it into your second quotation above:
https://postimg.cc/ct6xkYkt
the last line on the photo. Only it was compulsory to add an output.
what I did wrong, I dont know.
Since you wrote "No problem" I was sure that your concatenated the vidoes without errors and in sync, therefore I was happy to copy-paste your command, by changing the name into lista.txt.

then,
I simply do NOT trust that ffmpeg is unable in handling
an MP4 produced by the RX100M5 from 2016. Pure nonsense.
A bug?? but it is strange that Sony users did not compliant during 2,5 years.

I added the -c copy in my PS above. Before I tried your first command here:
https://postimg.cc/ct6xkYkt

With MKV is seems ok, because ffmpeg did something like:
Auto-inserting h264_mp4toannexb bitstream filter

If PCM is not supported in container MP4 (or at least, see log, ffmpeg is "unable to find the tag") I will ask to Sony why they are producing cameras with these specs and/or with Audio codec without the tag (expected by ffmpeg).

I will try to resolve the issue with async: it is not possible/not allowed that ffmpeg by simply "concatenating without recoding" is introducing these async. If the videos were 20 minutes long?

thanks.

Reino
Posts: 59
Joined: Thu Aug 22, 2013 5:14 pm
Contact:

Re: How to concatenate

Post by Reino » Tue May 07, 2019 11:32 pm

anuswara wrote:
Tue May 07, 2019 1:21 am
you said it into your second quotation above:
https://postimg.cc/ct6xkYkt
First of all, there's no need to take screenshots when you can just quote text.
Secondly, I guess you failed to see the reason for that codeblock. I quoted:
anuswara wrote:
Sat May 04, 2019 3:01 pm
Notice that -safe 0 doesnt work: the empty spaces are not accepted:
Next I show you evidence that -safe 0 does work, by showing the content of the file-list and the FFmpeg command and log to open this file-list. "No problem" to open this file-list with FFmpeg. That's all.
anuswara wrote:
Tue May 07, 2019 1:21 am
I simply do NOT trust that ffmpeg is unable in handling
an MP4 produced by the RX100M5 from 2016. Pure nonsense.
A bug?? but it is strange that Sony users did not compliant during 2,5 years.
You've seen for yourself that FFmpeg is perfectly capable of "handling" such a mp4-file. Decoding such a file is no problem. FFmpeg does not support muxing pcm_s16be into a mp4-container on the other hand. Search the internet. Official documents and specifications will tell you that the mp4-container does not support pcm audio. Other resources will tell you that Sony uses some hacks to create these mp4[h264+pcm] files.

anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

Re: How to concatenate

Post by anuswara » Tue May 07, 2019 11:44 pm

For me screenshots are easier. Are they not allowed??

Secondly, I guess you failed to see the reason for that codeblock: you said that you did not wrote the commad that I used, therefore I established to take a screen shot so the Readers will be able to see that you posted the command that I used.

So your white spaces work, mine dont. But the main point is the concatenate not the spaces between letters, as you seen I resolved this small problem a wonderful (at least for me/for my usage) way by simply changing the name of the files. The original names of the camera files do not contain spaces, but a 00010, 00011... only.That is not the reason of my topic.

oh my God...you wrote No problem after posting a shell code: I was sure that No Problem did mean "I was able via this code to obtain what you asked in this topic". That's all.
Reino wrote:
Tue May 07, 2019 11:32 pm

You've seen for yourself that FFmpeg is perfectly capable of "handling" such a mp4-file. Decoding such a file is no problem. FFmpeg does not support muxing pcm_s16be into a mp4-container on the other hand. Search the internet. Official documents and specifications will tell you that the mp4-container does not support pcm audio. Other resources will tell you that Sony uses some hacks to create these mp4[h264+pcm] files.
Oh I am furtunate because I still have not purchased this camera: a camera that is not fully supported by ffmpeg is a shame. I will write so Sony.

If someone want to tell me how to concatenate the 5 files above (but the files will be 95 too) without async, they are welcome.
Reino wrote:
Tue May 07, 2019 11:32 pm
You've seen for yourself that FFmpeg is perfectly capable of "handling" such a mp4-file.
where?
anuswara wrote:
Sat May 04, 2019 3:01 pm
I always failed.

Reino
Posts: 59
Joined: Thu Aug 22, 2013 5:14 pm
Contact:

Re: How to concatenate

Post by Reino » Tue May 07, 2019 11:59 pm

anuswara wrote:
Tue May 07, 2019 11:44 pm
For me screenshots are easier. Are they not allowed??
They are, but text is preferred.
anuswara wrote:
Tue May 07, 2019 11:44 pm
you said that you did not wrote the commad that I used, therefore I established to take a screen shot so the Readers will be able to see that you posted the command that I used.
You should read posts more carefully. Only here...
Reino wrote:
Sun May 05, 2019 12:07 pm
You could try to mux to *.mov instead:

Code: Select all

ffmpeg -f concat -safe 0 -i "vimeo_mux.txt" -c copy vimeo_mux.mov
...did I make a suggestion for a command to use.
anuswara wrote:
Tue May 07, 2019 11:44 pm
The original names of the camera files do not contain spaces, but a 00010, 00011... only.
Camera? You started this topic with a bunch of Vimeo videos that you were trying to concatenate...
anuswara wrote:
Tue May 07, 2019 11:44 pm
If someone want to tell me how to concatenate the 5 files above (but the files will be 95 too) without async, they are welcome.
Muxing to mov/mkv still fails?

anuswara
Posts: 18
Joined: Thu Aug 11, 2011 5:16 pm

Re: How to concatenate

Post by anuswara » Wed May 08, 2019 2:01 am

Did you follow my links at the beginning of the topic?
If you did it you know for sure that they are the *original* files from a Sony RX100.
Otherwise (no problem at all) you could had read:
anuswara wrote:
Tue May 07, 2019 1:21 am

an MP4 produced by the RX100M5 from 2016. Pure nonsense.
A bug?? but it is strange that Sony users did not compliant during 2,5 years.

thanks.
If muxing means "concatenate the files without recoding/transcoding them and by only selecting another container as output" the reply may be:
anuswara wrote:
Tue May 07, 2019 1:21 am


With MKV is seems ok, because ffmpeg did something like:
Auto-inserting h264_mp4toannexb bitstream filter
Reino wrote:
Tue May 07, 2019 11:59 pm

Muxing to mov/mkv still fails?
They dont fail (= error messages) but in some way they fail because, as written above, there arised a "little" problem I never experienced before:
anuswara wrote:
Mon May 06, 2019 5:41 pm
PS2: the "appended" videos are out of sync.
Now it is time to go to the end, without a lot of re-posts and re-replies:

=> if the problem (called "concatenate without async") cannot be resolved by none of the contributors here (due to Sony/due to ffmpeg/due to my ignorance/due to what the readers want: perhaps I am the first one that noticed this issue?) I guess that I have to search for another camera with the same specs (focal range, 4k stab and so on so on...) but with 4k into MP4 = H264/avc1 + AAC.
I dont see other concrete and rapid solutions.
[No problems at all with 1080p MTS camera's output, thanks the very old Ts_Splitter&Joiner.exe].
Thanks to all.

Post Reply