1

If I loop a video like below the audio is missing from test 1. If I omit the loop, it is there. What am I doing wrong?

E:\Videos\Loops>ffmpeg -re -f lavfi -i "movie=filename=ShortLoop.mpg:loop=0, set
pts=N/(FRAME_RATE*TB)" test1.mpg
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx -
-enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei
0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-li
bbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --en
able-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-li
bopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --e
nable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable
-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --e
nable-lzma --enable-decklink --enable-zlib
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, lavfi, from 'movie=filename=ShortLoop.mpg:loop=0, setpts=N/(FRAME_RATE
*TB)':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1
 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 90k tbc
[mpeg @ 00000000002df920] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'test1.mpg':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0: Video: mpeg1video, yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31
, 200 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 mpeg1video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg1video (native))
Press [q] to stop, [?] for help
[mpeg1video @ 0000000003786d40] [mpeg1video @ 0000000003786d40]

1 Answer 1

2

The loop option can't be used if you're ingesting multiple streams via the filter.

Use

ffmpeg -re -f lavfi -i "movie=filename=ShortLoop.mpg:loop=0"
       -re -f lavfi -i "amovie=filename=ShortLoop.mpg:loop=0"
       -vf setpts=N/FRAME_RATE/TB -af asetpts=N/SR/TB     test1.mpg
7
  • Thank you. That does add audio, but it is not in sync from the first loop onward. Could it be that video and audio are not of the exact same length? Unfortunately (and that is another issue), FFmpeg reports N/A for both so that's not very helpful. Commented Jun 22, 2017 at 14:55
  • 1
    Run ffprobe Shortloop.mpg -show_entries stream=duration -of compact -v 0 to check. You can then remux ffmpeg -i in.mpg -c copy -shortest out.mpg.
    – Gyan
    Commented Jun 22, 2017 at 15:31
  • There is a 14 ms difference, not enough to explain the sync issue I am seeing. Running your remux does not change anything either. Commented Jun 23, 2017 at 8:28
  • 1
    Post to the ffmpeg-devel mailing list and reference the ticket. You may get ignored, but maybe not :)
    – Gyan
    Commented Jun 23, 2017 at 8:33
  • 1
    Try with avconv. The code for this was grafted from there. It may have been fixed there since the time of borrowing. If so, great. If not, post to their devel list.
    – Gyan
    Commented Jun 24, 2017 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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