Opened 5 years ago

Closed 4 years ago

#8106 closed defect (needs_more_info)

Unexpected audio truncation with `-c:a copy`

Reported by: gdgsdg123 Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Check this (the last part, "The original file (what I threw at YouTube)").

I believe similar behavior shall occur with different audio/video input.
(actually... happened to notice this when trying to spam some random stuff on YouTube)





Extra things I've tested:

1. Changing the container format to AVI and using the very audio track in WAV format.
No help.


2. Slightly increasing -vframes to make the video duration longer than the audio's.
No help.


3. Inversing the command's input argument positions, like this:

ffmpeg -i "1.flac" -loop 1 -i "Entrepreneurship.png" -c:a copy -c:v libx264 -r 15 -vframes 3548 -preset placebo -qp 0 -x264-params "level=5.1:keyint=infinite:no-deblock=1" -pix_fmt yuv420p -sws_flags spline+accurate_rnd+full_chroma_int -color_range 1 -colorspace 5 -color_primaries 5 -color_trc 6 "1.mkv"

No help.

Attachments (1)

1.webm (1.6 MB ) - added by gdgsdg123 4 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Carl Eugen Hoyos, 4 years ago

Resolution: needs_more_info
Status: newclosed
Version: 4.2unspecified

in reply to:  description ; comment:2 by gdgsdg123, 4 years ago

Replying to gdgsdg123:

Extra things I've tested:

...


4. Matching the input/output framerate by adding -framerate option:

ffmpeg -loop 1 -framerate 15 -i "Entrepreneurship.png" -i "1.flac" -c:a copy -c:v libx264 -r 15 -vframes 3548 -preset placebo -qp 0 -x264-params "level=5.1:keyint=infinite:no-deblock=1" -pix_fmt yuv420p -sws_flags spline+accurate_rnd+full_chroma_int -color_range 1 -colorspace 5 -color_primaries 5 -color_trc 6 "1.mkv"

No help.


5. Greatly increasing -vframes to make the video duration much longer than the audio's.
Helps, though there's another problem then...


6. Removing -vframes and -loop:

ffmpeg -i "Entrepreneurship.png" -i "1.flac" -c:a copy -c:v libx264 -r 15 -preset placebo -qp 0 -x264-params "level=5.1:keyint=infinite:no-deblock=1" -pix_fmt yuv420p -sws_flags spline+accurate_rnd+full_chroma_int -color_range 1 -colorspace 5 -color_primaries 5 -color_trc 6 "1.mkv"

The truncation no longer occurs, though again there's another problem... (1 frame video)





...The cause seems to be -vframes/-t/-to/etc. interfering on -c:a copy.

Last edited 4 years ago by gdgsdg123 (previous) (diff)

comment:3 by gdgsdg123, 4 years ago

Resolution: needs_more_info
Status: closedreopened
Version: unspecifiedgit-master

Minimal command to reproduce:

ffmpeg -loop 1 -i "random.png" -i "1.webm" -c:a copy -r 15 -vframes 3548 "1.mkv"


For the input audio you can grab it from YouTube:

youtube-dl -f 249 -o "1.webm" http://www.youtube.com/watch?v=8fyTbI4TIS0
Last edited 4 years ago by gdgsdg123 (previous) (diff)

comment:4 by Carl Eugen Hoyos, 4 years ago

Resolution: needs_more_info
Status: reopenedclosed

in reply to:  4 comment:5 by gdgsdg123, 4 years ago

Replying to cehoyos:
What info?..

comment:6 by Carl Eugen Hoyos, 4 years ago

Is "random.png" necessary to reproduce the issue or is it reproducible with testsrc?
To make this a valid ticket, please provide the command line you tested together with the complete, uncut console output (as you did in the first tickets you opened on this bug tracker).

Please attach an audio file that allows to reproduce.

Last edited 4 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  description ; comment:7 by gdgsdg123, 4 years ago

Resolution: needs_more_info
Status: closedreopened

Replying to cehoyos:

Is "random.png" necessary to reproduce the issue or is it reproducible with testsrc?

Likely not. No idea how to use testsrc nor do I have much interest in figuring it out...

gdgsdg123:

I believe similar behavior shall occur with different audio/video input.
(actually... happened to notice this when trying to spam some random stuff on YouTube)




Replying to cehoyos:

To make this a valid ticket, please provide the command line you tested together with the complete, uncut console output (as you did in the first tickets you opened on this bug tracker).

Please attach an audio file that allows to reproduce.

Alright...

C:\>ffmpeg -loop 1 -i "random.png" -i "1.webm" -c:a copy -r 15 -vframes 3548 "1.mkv"
ffmpeg version git-2020-01-02-81172b5 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.102 / 58. 65.102
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.102 / 58.  9.102
  libavfilter     7. 70.101 /  7. 70.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, png_pipe, from 'random.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 2x2 [SAR 2835:2835 DAR 1:1], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, matroska,webm, from '1.webm':
  Metadata:
    encoder         : google/video-file
  Duration: 00:03:56.56, start: -0.007000, bitrate: 57 kb/s
    Stream #1:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0000000000593f80] using SAR=1/1
[libx264 @ 0000000000593f80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000000593f80] profile High 4:4:4 Predictive, level 1.0, 4:4:4, 8-bit
[libx264 @ 0000000000593f80] 264 - core 158 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to '1.mkv':
  Metadata:
    encoder         : Lavf58.35.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 2x2 [SAR 1:1 DAR 1:1], q=-1--1, 15 fps, 1k tbn, 15 tbc
    Metadata:
      encoder         : Lavc58.65.102 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp (default)
frame= 3548 fps=0.0 q=27.0 Lsize=    1705kB time=00:03:56.33 bitrate=  59.1kbits/s dup=0 drop=2362 speed= 388x
video:49kB audio:1559kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.003599%
[libx264 @ 0000000000593f80] frame I:15    Avg QP: 4.20  size:    20
[libx264 @ 0000000000593f80] frame P:894   Avg QP: 7.09  size:    18
[libx264 @ 0000000000593f80] frame B:2639  Avg QP:11.33  size:    13
[libx264 @ 0000000000593f80] consecutive B-frames:  0.8%  0.0%  0.1% 99.1%
[libx264 @ 0000000000593f80] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0000000000593f80] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0000000000593f80] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%
[libx264 @ 0000000000593f80] 8x8 transform intra:0.0%
[libx264 @ 0000000000593f80] coded y,u,v intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0000000000593f80] i16 v,h,dc,p:  0%  0% 100%  0%
[libx264 @ 0000000000593f80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000000593f80] kb/s:1.68

C:\>ffprobe "1.mkv"
ffprobe version git-2020-01-02-81172b5 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.102 / 58. 65.102
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.102 / 58.  9.102
  libavfilter     7. 70.101 /  7. 70.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from '1.mkv':
  Metadata:
    ENCODER         : Lavf58.35.101
  Duration: 00:03:56.53, start: -0.007000, bitrate: 59 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p(progressive), 2x2 [SAR 1:1 DAR 1:1], 15 fps, 15 tbr, 1k tbn, 30 tbc
    Metadata:
      ENCODER         : Lavc58.65.102 libx264
      DURATION        : 00:03:56.534000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:03:53.561000000

by gdgsdg123, 4 years ago

Attachment: 1.webm added

in reply to:  7 ; comment:8 by Carl Eugen Hoyos, 4 years ago

Replying to gdgsdg123:

Replying to cehoyos:

Is "random.png" necessary to reproduce the issue or is it reproducible with testsrc?

Likely not. No idea how to use testsrc

$ ffmpeg -f lavfi -i testsrc

in reply to:  8 ; comment:9 by gdgsdg123, 4 years ago

Replying to cehoyos:

$ ffmpeg -f lavfi -i testsrc

Not applicable for this case... ("Option loop not found.")

in reply to:  9 comment:10 by Carl Eugen Hoyos, 4 years ago

Replying to gdgsdg123:

Replying to cehoyos:

$ ffmpeg -f lavfi -i testsrc

Not applicable for this case... ("Option loop not found.")

Did you try without loop?

comment:11 by pdr0, 4 years ago

use -r and -loop as input options for the image, and -shortest

eg.

ffmpeg -loop 1 -r 15 -i image.png -i 1.webm -c:v libx264 -crf 20 -preset:v faster -c:a copy -shortest out.mkv

ffprobe -i out.mkv

Input #0, matroska,webm, from 'out.mkv':
  Metadata:
    ENCODER         : Lavf58.35.101
  Duration: 00:03:56.87, start: -0.007000, bitrate: 79 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p(progressive), 720x
480 [SAR 1:1 DAR 3:2], 15 fps, 15 tbr, 1k tbn, 30 tbc
    Metadata:
      ENCODER         : Lavc58.65.100 libx264
      DURATION        : 00:03:56.867000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:03:56.561000000

in reply to:  2 comment:12 by gdgsdg123, 4 years ago

Replying to cehoyos:

Did you try without loop?

Similar result expected...

gdgsdg123:


6. Removing -vframes and -loop:

ffmpeg -i "Entrepreneurship.png" -i "1.flac" -c:a copy -c:v libx264 -r 15 -preset placebo -qp 0 -x264-params "level=5.1:keyint=infinite:no-deblock=1" -pix_fmt yuv420p -sws_flags spline+accurate_rnd+full_chroma_int -color_range 1 -colorspace 5 -color_primaries 5 -color_trc 6 "1.mkv"

The truncation no longer occurs, though again there's another problem... (1 frame video)




Replying to pdr0:

use -r and -loop as input options for the image, and -shortest...

Minimized command to reproduce (of similar effect):

ffmpeg -y -loop 1 -i "random.png" -i "1.webm" -c:a copy -shortest "1.mkv"

gdgsdg123:

...The cause seems to be -vframes/-t/-to/etc. interfering on -c:a copy.

comment:13 by Carl Eugen Hoyos, 4 years ago

Resolution: needs_more_info
Status: reopenedclosed
Note: See TracTickets for help on using tickets.