Error splitting the argument list option not found

Ответили на вопрос 1 человек. Оцените лучшие ответы! И подпишитесь на вопрос, чтобы узнавать о появлении новых ответов.

Что за ошибка и как ее исправить? Использую библиотеку https://github.com/aminyazdanpanah/PHP-FFmpeg-vide… И установил FFmpeg на сервер.

Fatal error: Uncaught AlchemyBinaryDriverExceptionExecutionFailureException: ffmpeg failed to execute command ‘/usr/bin/ffmpeg’ ‘-y’ ‘-i’ ‘/var/www/www-root/data/www/site.ru/converter/input/video.mp4’ ‘-c:v’ ‘libx264’ ‘-c:a’ ‘aac’ ‘-bf’ ‘1’ ‘-keyint_min’ ’25’ ‘-g’ ‘250’ ‘-sc_threshold’ ’40’ ‘-use_timeline’ ‘1’ ‘-use_template’ ‘1’ ‘-init_seg_name’ ‘video_init_$RepresentationID$.$ext$’ ‘-media_seg_name’ ‘video_chunk_$RepresentationID$_$Number%05d$.$ext$’ ‘-seg_duration’ ’10’ ‘-hls_playlist’ ‘0’ ‘-f’ ‘dash’ ‘-map’ ‘0’ ‘-s:v:0’ ‘256×144’ ‘-b:v:0’ ‘6852k’ ‘-map’ ‘0’ ‘-s:v:1’ ‘426×240’ ‘-b:v:1’ ‘7994k’ ‘-map’ ‘0’ ‘-s:v:2’ ‘640×360’ ‘-b:v:2’ ‘9593k’ ‘-map’ ‘0’ ‘-s:v:3’ ‘854×480’ ‘-b:v:3’ ‘11992k’ ‘-map’ ‘0’ ‘-s:v:4’ ‘1280×720’ ‘-b:v:4’ ‘15989k’ ‘-map’ ‘0’ ‘-s:v:5’ ‘1920×1080’ ‘-b:v:5’ ‘23984k’ ‘-strict’ ‘-2’ ‘-threads’ ‘3’ ‘/var/www/www-root/data/www/site.ru/converter/input/video.mpd’: Error Output: ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubu in /var/www/www-root/data/www/site.ru/converter/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php on line 95

Код PHP:

require_once __DIR__ . '/vendor/autoload.php';

use StreamingRepresentation;

$config = [
    'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/bin/ffprobe',
    'timeout'          => 3600,
    'ffmpeg.threads'   => 3,
];

$ffmpeg = StreamingFFMpeg::create($config);

$video = $ffmpeg->open(__DIR__ . '/input/video.mp4');

$format = new StreamingFormatX264();
$format->on('progress', function ($video, $format, $percentage){
    // You can update a field in your database or can log it to a file
    // You can also create a socket connection and show a progress bar to users
    echo sprintf("rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage)));
});

$video->dash()
    ->setFormat($format)
    ->autoGenerateRepresentations()
    ->save();

  1. Hello everyone,

    I change from installing FFMPEG using apt-get install ffmpeg to download it from a website referring to this link, using the compile method not the apt-get install Item, I faced this problem:

    Code:

    ffmpeg -y -i INPUT.mp4 -ss 00:01:23 -t 00:00:10 -strict experimental -vf drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSansBold.ttf':text='text':x=10:y=10:fontsize=18:fontcolor=white -vcodec libx264 -preset medium -crf 24 -acodec copy OUTPUT.mp4
    
    
    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Unrecognized option 'preset'.
    Error splitting the argument list: Option not found

    Thank you for your support

    EDIT:

    I changed it to:

    Code:

     -c:v libx264 -pre medium -crf 24 -acodec copy

    Then I’ve got this:

    Code:

    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Unrecognized option 'crf'.
    Error splitting the argument list: Option not found

    Last edited by alfirdaous; August 16th, 2016 at 06:34 AM.


  2. Re: FFMPEG compiling

    Open a terminal, just run command of ffmpeg & post output to see your configuration.


  3. Re: FFMPEG compiling

    The ffmpeg output is:

    Code:

    # ffmpeg
    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    
    Use -h to get full help or, even better, run 'man ffmpeg'

    and the ffmpeg version is:

    Code:

    # ffmpeg -version
    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
    built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
    configuration: 
    libavutil      55. 28.100 / 55. 28.100
    libavcodec     57. 51.102 / 57. 51.102
    libavformat    57. 46.101 / 57. 46.101
    libavdevice    57.  0.102 / 57.  0.102
    libavfilter     6. 51.100 /  6. 51.100
    libswscale      4.  1.100 /  4.  1.100
    libswresample   2.  1.100 /  2.  1.100

    and the full ffmpeg command is:

    Code:

    # ffmpeg -y -i INPUT.mp4 -ss 00:01:23 -t 00:00:10 -strict experimental -vf drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSansBold.ttf':text='www.site.com':x=10:y=10:fontsize=18:fontcolor=white -c:v libx264 -pre medium -crf 24 -acodec copy OUTPUT.mp4
    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Unrecognized option 'crf'.
    Error splitting the argument list: Option not found


  4. Re: FFMPEG compiling

    If you were following that link you need to do it from top to bottom of the page. Your current build is practically un-configured & of little value.
    So you should start again.
    Ex. here on personal build
    $ ffmpeg2
    ffmpeg version N-80950-g3cdd5f4 Copyright (c) 2000-2016 the FFmpeg developers
    built with gcc 5.3.1 (Ubuntu 5.3.1-14ubuntu2.1) 20160413
    configuration: —extra-libs=-ldl —prefix=/opt/ffmpeg —enable-avresample —disable-debug —enable-nonfree —enable-gpl —enable-version3 —enable-libopencore-amrnb —enable-libopencore-amrwb —disable-decoder=amrnb —disable-decoder=amrwb —enable-libpulse —enable-libfreetype —enable-gnutls —enable-libx264 —enable-libx265 —enable-libfdk-aac —enable-libvorbis —enable-libmp3lame —enable-libopus —enable-libvpx —enable-libspeex —enable-libass —enable-avisynth —enable-libsoxr —enable-libxvid —enable-libvidstab —enable-libtheora —enable-libwavpack —enable-libopenjpeg —enable-libgsm

    The configure that link uses is this so that’s what you should be seeing

    Code:

    ./configure 
      --prefix="$HOME/ffmpeg_build" 
      --pkg-config-flags="--static" 
      --extra-cflags="-I$HOME/ffmpeg_build/include" 
      --extra-ldflags="-L$HOME/ffmpeg_build/lib" 
      --bindir="$HOME/bin" 
      --enable-gpl 
      --enable-libass 
      --enable-libfdk-aac 
      --enable-libfreetype 
      --enable-libmp3lame 
      --enable-libopus 
      --enable-libtheora 
      --enable-libvorbis 
      --enable-libvpx 
      --enable-libx264 
      --enable-libx265 
      --enable-nonfree

    Note that recent releases & the current master no longer needs -strict experimental


  5. Re: FFMPEG compiling

    So how can I delete all these files and restart from the beginning?


  6. Re: FFMPEG compiling

    At the very bottom of your linked page

    Updating FFmpeg

    Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First you need to delete (or move) the old files:

    rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,y asm,ytasm}

    Now just follow the guide from the beginning
    .

    Reverting Changes Made by This Guide

    rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,y asm,ytasm}
    sudo apt-get autoremove autoconf automake build-essential cmake libass-dev libfreetype6-dev
    libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev
    libvorbis-dev libvpx-dev libx264-dev libxcb1-dev libxcb-shm0-dev ibxcb-xfixes0-dev mercurial texinfo zlib1g-dev
    sed -i ‘/ffmpeg_build/c’ ~/.manpath
    hash -r

    Either one will do the deed.


  7. Re: FFMPEG compiling

    I still get the same error:

    Code:

    # ffmpeg -y -i INPUT.mp4 -ss 00:01:23 -t 00:00:10 -strict experimental -vf drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSansBold.ttf':text='www.site.com':x=10:y=10:fontsize=18:fontcolor=white -c:v libx264 -pre medium -crf 24 -acodec copy OUTPUT.mp4
    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Unrecognized option 'crf'.
    Error splitting the argument list: Option not found

    if I remove that option, I get this error:

    Code:

    ffmpeg version N-81342-gb93e223 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 51.102 / 57. 51.102
      libavformat    57. 46.101 / 57. 46.101
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 51.100 /  6. 51.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Original/alfirdaous.com_MohamadAssayed_SawaedAlEkhae4_001-Original.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: isommp42
        creation_time   : 2016-06-07 11:34:53
      Duration: 00:27:37.09, start: 0.000000, bitrate: 575 kb/s
        Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 476 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)
        Metadata:
          creation_time   : 2016-06-07 11:35:10
          handler_name    : IsoMedia File Produced by Google, 5-11-2011
    Unknown encoder 'libx264'

    however, I already compiled the libx264


  8. Re: FFMPEG compiling

    Your configuration: is still empty, all of those code boxes in your link, each are 1 complete command. I think you may be breaking them up??
    Maybe just remove all & just go —

    Code:

    sudo apt install ffmpeg


  9. Re: FFMPEG compiling

    Well, everything was messed up, I reinstall the server (test server), and I’ve got this error while trying to encode a video

    Code:

    [mp4 @ 0x28a8320] Codec for stream 1 does not use global headers but container format requires global headers


  10. Re: FFMPEG compiling

    You should show your command and the complete console output.


#2127

closed


defect


(fixed)

Reported by: Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

To convert the file -dash.mp4 to -dash.mp3, ffmpeg 0.11 allowed

% ffmpeg -i -dash.mp3 -- -dash.mp4

In ffmpeg 1.1 (and git 4765f635387cef3efb01e52e59d4f3add126a0e2 ), this fails:

% ffmpeg -i -dash.mp3 -- -dash.mp4
ffmpeg version 1.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan  8 2013 10:32:41 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --disable-decoder=libdirac --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libdc1394 --disable-altive  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 86.100 / 54. 86.100
  libavformat    54. 59.106 / 54. 59.106
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Unrecognized option '-'.
Error splitting the argument list: Option not found

While it is possible to escape file names by prepending ./, doing is nontrivial in a script, since one has to consider absolute filenames as well. The — convention is widely supported, not only by ffmpeg-0.11, but also GNU coreutils, bash, gcc, etc.

This is my code:

# Import everything needed to edit/save/watch video clips
from moviepy.editor import VideoFileClip
from IPython.display import HTML

new_clip_output = 'test_output.mp4'
test_clip = VideoFileClip("test.mp4")
new_clip = test_clip.fl_image(lambda x: cv2.cvtColor(x, cv2.COLOR_RGB2YUV)) #NOTE: this function expects color images!!
new_clip.write_videofile(new_clip_output, audio=False)

Error
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file test_output.mp4:

 b"Unrecognized option 'preset'.nError splitting the argument list: Option not foundn"


Full error details are here:
`[MoviePy] >>>> Building video test_output.mp4
[MoviePy] Writing video test_output.mp4
  0%|          | 0/251 [00:00<?, ?it/s]
---------------------------------------------------------------------------
BrokenPipeError                           Traceback (most recent call last)
~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    133             if PY3:
--> 134                self.proc.stdin.write(img_array.tobytes())
    135             else:

BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-30-7a601a4eaaf5> in <module>()
----> 1 new_clip.write_videofile(new_clip_output, audio=False)

<decorator-gen-175> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in requires_duration(f, clip, *a, **k)
     52         raise ValueError("Attribute 'duration' not set")
     53     else:
---> 54         return f(clip, *a, **k)
     55 
     56 

<decorator-gen-174> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in use_clip_fps_by_default(f, clip, *a, **k)
    135              for (k,v) in k.items()}
    136 
--> 137     return f(clip, *new_a, **new_kw)

<decorator-gen-173> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in convert_masks_to_RGB(f, clip, *a, **k)
     20     if clip.ismask:
     21         clip = clip.to_RGB()
---> 22     return f(clip, *a, **k)
     23 
     24 @decorator.decorator

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/VideoClip.py in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)
    347                            verbose=verbose, threads=threads,
    348                            ffmpeg_params=ffmpeg_params,
--> 349                            progress_bar=progress_bar)
    350 
    351         if remove_temp and make_audio:

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in ffmpeg_write_video(clip, filename, fps, codec, bitrate, preset, withmask, write_logfile, audiofile, verbose, threads, ffmpeg_params, progress_bar)
    214             frame = np.dstack([frame,mask])
    215 
--> 216         writer.write_frame(frame)
    217 
    218     writer.close()

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    176 
    177 
--> 178             raise IOError(error)
    179 
    180     def close(self):

OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file test_output.mp4:

 b"Unrecognized option 'preset'.nError splitting the argument list: Option not foundn"

The ffmpeg developers and their libav antipodes are engaged in a healthy battle. Ever since there was a fall-out and the ffmpeg developer community split in two (forking ffmpeg into “libav”), ffmpeg itself has seen many releases which tend to incorporate the good stuff from the other team as well as their own advancements.

Last in series is ffmpeg-0.9 for which I built Slackware packages (if you want to be able to create mp3 or aac sound, get the packages with MP3 and AAC encoding enabled instead.

The package will come in handy if you want to try what I am going to describe next.

Re-sync your movie’s audio.

You probably have seen the issue yourself too: for instance, I have a file “original.avi” which has an audio track (or “stream“) which is slightly out of sync with the video… just enough to annoy the hell out of me. I need to delay the audio by 0.2 seconds to make the movie playback in sync. Luckily, ffmpeg can fix this for you very easily.

Let’s analyze the available streams in the original video (remember, UNIX starts counting at zero):

$ ffmpeg -i original.avi

Input #0, avi, from ‘original.avi’:

Stream #0.0: Video: mpeg4, yuv420p, 672×272 [PAR 1:1 DAR 42:17], 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s

You see that ffmpeg reports a “stream #0.0” which is the first stream in the first input file (right now we have only one input file but that will change later on) – the video. The second stream, called “stream #0.1“, is the audio track.

What I need is to give ffmpeg the video and audio as separate inputs, instruct it to delay our audio and re-assemble the two streams into one resultant movie file. The parameters which define two inputs where the second input will be delayed for N seconds, goes like this:

$ ffmpeg -i inputfile1 -itsoffset N -i inputfile2

However, we do not have a separate audio and video tracks, we just have the single original AVI file. Luckily, the “inputfile1” and “inputfile2” can be the same file! We just need to find a way to tell ffmpeg what stream to use from which input. Look at how ffmpeg reports the content of input files if you list the same file twice:

$ ffmpeg -i original.avi -i original.avi

Input #0, avi, from ‘original.avi’:

Stream #0.0: Video: mpeg4, yuv420p, 672×272 [PAR 1:1 DAR 42:17], 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s

Input #1, avi, from ‘original.avi’:

Stream #1.0: Video: mpeg4, yuv420p, 672×272 [PAR 1:1 DAR 42:17], 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #1.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s

You see that the different streams in multiple input files are all numbered uniquely. We will need this defining quality. I colored the numbers with red & purple – these colors will show up in my example commands below.

Our remaining issue is that ffmpeg must be told that it has to use only the video stream of the first inputfile, and only the audio stream of the second inputfile. Ffmpeg will then have to do its magic and finally re-assemble the two streams into a resulting movie file. That resulting AVI file also expects video as the first stream, and audio as the second stream, just like our original AVI is laid out. Movie players will get confused otherwise.

Ffmpeg has the “map” parameter to specify this. I have looked long and hard at this parameter and its use… it is not easy for me to follow the logic. A bit like the git version control system, which does not fit into my brain conceptually, either. But perhaps I can finally explain it properly, to myself as well as to you, the reader.

Actually, we need two “map” parameters, one to map the input to the output video and another to map the input to the output audio. Map parameters are specified in the order the streams are going to be added to the output file. Remember, we want to delay the audio, so inherently the audio track must be taken from the second inputfile.

In the example below, the first “-map 0:0” parameter specifies how to create the first stream in the output. We need the first stream in the output to be video. The “0:0” value means “first_inputfile:first_stream“.

The second “-map 1:1” parameter specifies where ffmpeg should find the audio (which is going to be the second stream in the output). The value “1:1” specifies “second_inputfile:seccond_stream.

$ ffmpeg -i original.avi -itsoffset 0.2 -i original.avi -map 0:0 -map 1:1

There is one more thing (even though it looks like ffmpeg is smart enough to do this without explicitly telling so). I do not want any re-encoding of the audio or video to happen, so I instruct ffmpeg to “copy” the audio and video stream without intermediate decoding and re-encoding. The “‘-acodec copy” and “-vcodec copy” parameters take care of this.

We now have the information to write a ffmpeg commandline which takes audio and video streams from the same file and re-assembles the movie with the audio stream delayed by 0.2 seconds. The resulting synchronized movie is called “synced.avi” and the conversion takes seconds, rather than minutes:

$ ffmpeg -i original.avi -itsoffset 0.2 -i original.avi -map 0:0 -map 1:1  -acodec copy -vcodec copy synced.avi

Cheers, Eric

Понравилась статья? Поделить с друзьями:
  • Error setting parameters from dcb com port toolkit
  • Error spell not found enable eldencounter esp
  • Error setting new values common errors
  • Error setting mtrr invalid argument 22
  • Error setting monitor mode on wlan0