[FFmpeg-user] Use concat demuxer with input format

Hans Carlson forbyta at gmx.com
Sun Jul 16 05:10:57 EEST 2017


Is it possible to use the concat demuxer with an input format?

For example:

   $ ffmpeg -f s16le -ac 2 -f concat -i concat-raw.txt ...
or
   $ ffmpeg -f concat -f s16le -ac 2 -i concat-raw.txt ...

I've tried both and it doesn't work, so I assume it's either not supported 
or I'm doing something wrong.

To back up a little, I'm trying to concat parts of several PCM files. 
Since they're PCM files, I need to supply the format as an input arg. 
And because I only want parts from each file, I want to use the concat 
demuxer along with the inpoint, outpoint options.  For example, given the 
following:

   $ ffmpeg -f s16le -ac 2 -i file1.raw
   ffmpeg version N-86775-gd0ba0be Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 4.9.2 (GCC) 20150212 (Red Hat 4.9.2-6)
     configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
     libavutil      55. 67.100 / 55. 67.100
     libavcodec     57.100.104 / 57.100.104
     libavformat    57. 75.100 / 57. 75.100
     libavdevice    57.  7.100 / 57.  7.100
     libavfilter     6. 95.100 /  6. 95.100
     libswscale      4.  7.101 /  4.  7.101
     libswresample   2.  8.100 /  2.  8.100
     libpostproc    54.  6.100 / 54.  6.100
   [s16le @ 0x3d9a420] Estimating duration from bitrate, this may be inaccurate
   Guessed Channel Layout for Input Stream #0.0 : stereo
   Input #0, s16le, from 'file1.raw':
     Duration: 00:05:00.00, bitrate: 1411 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
   At least one output file must be specified

   $ ffmpeg -hide_banner -f s16le -ac 2 -i file2.raw
   [s16le @ 0x22ed440] Estimating duration from bitrate, this may be inaccurate
   Guessed Channel Layout for Input Stream #0.0 : stereo
   Input #0, s16le, from 'file2.raw':
     Duration: 00:03:00.00, bitrate: 1411 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
   At least one output file must be specified

   $ cat concat-raw.txt
   file file1.raw
   inpoint 30
   outpoint 270
   duration 300

   file file2.raw
   inpoint 10
   outpoint 160
   duration 180

And trying the 2 commands listed at the top:

   $ ffmpeg -hide_banner -f s16le -ac 2 -f concat -i concat-raw.txt -codec mp3 test-1.mp3
   [adp @ 0x226d7a0] Format adp detected only with low score of 25, misdetection possible!
   concat-raw.txt: Operation not permitted

   $ ffmpeg -hide_banner -f concat -f s16le -ac 2 -i concat-raw.txt -codec mp3 test-2.mp3
   [s16le @ 0x3ba2540] Estimating duration from bitrate, this may be inaccurate
   Guessed Channel Layout for Input Stream #0.0 : stereo
   Input #0, s16le, from 'concat-raw.txt':
     Duration: 00:00:00.00, bitrate: 1423 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
   Stream mapping:
     Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
   Press [q] to stop, [?] for help
   [pcm_s16le @ 0x3bac280] Multiple frames in a packet.
   [pcm_s16le @ 0x3bac280] Invalid PCM packet, data has size 1 but at least a size of 4 was expected
   Error while decoding stream #0:0: Invalid data found when processing input
   Output #0, mp3, to 'test-2.mp3':
     Metadata:
       TSSE            : Lavf57.75.100
       Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
       Metadata:
         encoder         : Lavc57.100.104 libmp3lame
   [libmp3lame @ 0x3bb0200] Trying to remove 1152 samples, but the queue is empty
   size=       1kB time=00:00:00.02 bitrate= 320.1kbits/s speed=6.76x
   video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 30.299400%

And... just to prove both files work fine on their own:

   $ ffmpeg -hide_banner -f s16le -ac 2 -i file1.raw -codec mp3 file1.mp3
   [s16le @ 0x3df9580] Estimating duration from bitrate, this may be inaccurate
   Guessed Channel Layout for Input Stream #0.0 : stereo
   Input #0, s16le, from 'file1.raw':
     Duration: 00:05:00.00, bitrate: 1411 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
   Stream mapping:
     Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
   Press [q] to stop, [?] for help
   Output #0, mp3, to 'file1.mp3':
     Metadata:
       TSSE            : Lavf57.75.100
       Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
       Metadata:
         encoder         : Lavc57.100.104 libmp3lame
   size=    4688kB time=00:05:00.01 bitrate= 128.0kbits/s speed=59.6x
   video:0kB audio:4688kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005270%

   $ ffmpeg -hide_banner -f s16le -ac 2 -i file2.raw -codec mp3 file2.mp3
   [s16le @ 0x2912580] Estimating duration from bitrate, this may be inaccurate
   Guessed Channel Layout for Input Stream #0.0 : stereo
   Input #0, s16le, from 'file2.raw':
     Duration: 00:03:00.00, bitrate: 1411 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
   Stream mapping:
     Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
   Press [q] to stop, [?] for help
   Output #0, mp3, to 'file2.mp3':
     Metadata:
       TSSE            : Lavf57.75.100
       Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
       Metadata:
         encoder         : Lavc57.100.104 libmp3lame
   size=    2813kB time=00:03:00.01 bitrate= 128.0kbits/s speed=57.9x
   video:0kB audio:2813kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.008783%

So, is it just not possible to use an INPUT format option (-f s16le) AND 
the concat demuxer?

If so, do I have to convert each file to mp3 first and then use concat or 
is there another way to do what I'm want without creating intermediate 
files?


More information about the ffmpeg-user mailing list