0

I have a series of short (<3sec) mp4 videos (some with audio, some with no audio) that play fine in all clients. 15 fps, AAC audio. When I use ffmpeg concat, the resulting file plays fine in vlc, however in winmedia it ignores any silence in the audio track. In quicktime it plays all the video, only plays the first audio. I feel it has something to do with syncing video and audio but am new with ffmpeg. If I take the output and recode it with handbrake, it builds a file that works.

exec ("ffmpeg -f concat -i files.txt -c  copy finalvideo.mp4");

and then I do this:

exec ("ffmpeg -i finalvideo.mp4 -c:v copy -c:a libfaac -r 24 output.mp4");

Revised with new outputs after ensuring that both source audios have the same encoding (I think)

Info from New Pause File

/home/fresh/public_html/ffmpeg/output$ ffmpeg -i /home/fresh/public_html/ffmpeg/output/ENP22122.mp4
ffmpeg version N-61053-gab5d46d-syslint Copyright (c) 2000-2014 the FFmpeg developers
built on Mar  3 2014 13:27:18 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-  libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-  libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil      52. 66.100 / 52. 66.100
libavcodec     55. 52.102 / 55. 52.102
libavformat    55. 33.100 / 55. 33.100
libavdevice    55. 10.100 / 55. 10.100
libavfilter     4.  2.100 /  4.  2.100
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 18.100 /  0. 18.100
libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/fresh/public_html/ffmpeg/output/ENP22122.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf55.33.100
Duration: 00:00:04.07, start: 0.000000, bitrate: 63 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1   DAR 4:3], 5 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc (default)
Metadata:
  handler_name    : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 96 kb/s (default)
Metadata:
  handler_name    : SoundHandler

Info from new Audio File

/home/fresh/public_html/ffmpeg/output$ ffmpeg -i /home/fresh/public_html/ffmpeg/output/ENT22122.mp4
ffmpeg version N-61053-gab5d46d-syslint Copyright (c) 2000-2014 the FFmpeg developers
built on Mar  3 2014 13:27:18 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-  libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil      52. 66.100 / 52. 66.100
libavcodec     55. 52.102 / 55. 52.102
libavformat    55. 33.100 / 55. 33.100
libavdevice    55. 10.100 / 55. 10.100
libavfilter     4.  2.100 /  4.  2.100
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 18.100 /  0. 18.100
libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/fresh/public_html/ffmpeg/output/ENT22122.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf55.33.100
Duration: 00:00:03.07, start: 0.000000, bitrate: 56 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 6 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc (default)
Metadata:
  handler_name    : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 96 kb/s (default)
Metadata:
  handler_name    : SoundHandler

Output from concat command

/home/fresh/public_html/ffmpeg/output$ ffmpeg -f concat -i /home/fresh/public_html   /ffmpeg/filesnotime.txt -c  copy /home/fresh/public_html/ffmpeg/finalvideo.mp4
ffmpeg version N-61053-gab5d46d-syslint Copyright (c) 2000-2014 the FFmpeg developers
built on Mar  3 2014 13:27:18 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil      52. 66.100 / 52. 66.100
libavcodec     55. 52.102 / 55. 52.102
libavformat    55. 33.100 / 55. 33.100
libavdevice    55. 10.100 / 55. 10.100
libavfilter     4.  2.100 /  4.  2.100
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 18.100 /  0. 18.100
libpostproc    52.  3.100 / 52.  3.100
[concat @ 0x14a2900] Estimating duration from bitrate, this may be inaccurate
Input #0, concat, from '/home/fresh/public_html/ffmpeg/filesnotime.txt':
Duration: 00:00:00.08, start: 0.000000, bitrate: 102 kb/s
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 6 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc
Stream #0:1: Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 96 kb/s
Output #0, mp4, to '/home/fresh/public_html/ffmpeg/finalvideo.mp4':
Metadata:
encoder         : Lavf55.33.100
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 480x360 [SAR 1:1 DAR 4:3], q=2-31, 6 kb/s, 15 fps, 15360 tbn, 15360 tbc
Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, mono, 96 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)

frame=  828 fps=0.0 q=-1.0 Lsize=     392kB time=00:00:55.00 bitrate=  58.4kbits/s    
video:81kB audio:289kB subtitle:0 data:0 global headers:0kB muxing overhead 6.031527%
  • 2
    Sorry, but your question is not very clear. ("Ignores any silence"?) What are the input files like? Can you give the output of simply ffmpeg -i <inputfile> for each? Also, please provide the command and console output of ffmpeg when you run the command. – Rajib Mar 16 '14 at 13:11
  • Thank for the quick reply. I am not too familiar with ffmpeg but added the console outputs above. Ignore any silence, I just mean when it joins the files it ignores video clips that have no audio, so if there is no audio, the entire clip seems to be ignored. – user2271364 Mar 17 '14 at 0:35
  • I have updated the console outputs with the new ones after it seems like my source files have the same codec. I don't understand how to run the concat filter, where the file list comes in. Thank you for your help. – user2271364 Mar 18 '14 at 2:39
  • 1. You have some whitespace between public_html and /ffmpeg. 2. What is the problem with the output now, since both files do have audio? And your duartion (final) indicates you are adding more files. – Rajib Mar 18 '14 at 8:28
  • Example: freshlingo.com/ffmpeg/finalvideo.mp4 I have 3 second audio, 4 second pause for each item. It plays 3 second audios on top of each other, you can see at the 7 sec mark where the next slide starts, the audio should line up with this. For some reason it is ignoring the pauses. thanks When I run the concat filter, how to I do it for a bunch of file, or do I need to write a script? – user2271364 Mar 18 '14 at 14:35
2

The concat demuxer you are using works only if the files have same number of streams each. Read this documentation.

In other words you will need to mux in (silent) audio into the files which have no audio. Try this:

 ffmpeg -f lavfi -i aevalsrc=0 -i ENP22122.mp4 -shortest \
 -c:v copy -c:a aac -strict -2 newmuxedfile.mp4    

You can then concatenate the newmuxedfile.mp4 provided the codecs are the same. The demuxer will not work if codecs differ. So here i used aac as in your other file. If the concat fails for codecs differing, use the concat filter instead.

ffmpeg -i ENA22122.mp4 -i newmuxedfile.mp4 -filter_complex \
'[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' \
-map '[v]' -map '[a]' -c:v libx264 -c:a aac -strict -2 output.mp4   

Note that you can use -c:v copy if the video codecs are the same.

To see all concatenation methods see this documentation.

  • Thank you. I have now got my source files in exactly the same format and still have output problems with concat. Rather than post another bunch of outputs, is there someway I contact you? and perhaps see if you want to consult on this? – user2271364 Mar 18 '14 at 0:26
  • Have you tried the concat filter? Please do edit your question to add the new console outputs and your command. There are many experts here who are all happy to "consult" for free. – Rajib Mar 18 '14 at 2:23
  • Update: 1. Using concat/filter on my source files and output works perfect all platforms. 2. Using concat/filter, join two files in batches, then use concat on those files output fails. 3. Concat on other source files works. Leads me back to my source files as the problem but they all seem the same codec. Question: Do you know what the limit is with concat/filter? I seem to hit an error 'too many inputs' above 3 files. – user2271364 Mar 19 '14 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.