Opened 11 years ago

Closed 10 years ago

#3062 closed defect (worksforme)

Concatenating ends with corrupted mp4 file.

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

Description

I convert 2 images to 2 different mp4 files with the command below.

cat 0258_11.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 proje_11_1.mp4
cat 0259_11.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 proje_11_2.mp4

This works without issue and i get 2 mp4 files working fine.But when i try to concat them

  ffmpeg -f concat -i <(for f in *.mp4; do echo "file '$f'"; done) -r 1 -c copy output.mp4

output.mp4 is corrupted.[ffmpeg version N-56333-g7129935]

What i am trying to achive is ;appending jpg to the end of my mp4 video.

Change History (3)

comment:1 by Carl Eugen Hoyos, 11 years ago

Component: FFmpegundetermined

Please test current git head and please post your actual command line together with the complete uncut console output to make this a valid ticket.

comment:2 by Ali, 10 years ago

ffmpeg -f concat -i <(for f in /var/www/ss/52437f69d8e8c/1/201013/*.mp4; do echo "file '$f'"; done) -r 1 -c copy /var/www/ss/52437f69d8e8c/1/201013/output.mp4 -y
ffmpeg version N-56333-g7129935 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 17 2013 05:27:06 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.103 / 55. 16.103
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 85.100 /  3. 85.100
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, concat, from '/dev/fd/63':
  Duration: N/A, start: 0.000000, bitrate: 959 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1366x768 [SAR 1:1 DAR 683:384], 959 kb/s, 1 fps, 1 tbr, 16384 tbn, 2 tbc
Output #0, mp4, to '/var/www/ss/52437f69d8e8c/1/201013/output.mp4':
  Metadata:
    encoder         : Lavf55.16.103
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 1366x768 [SAR 1:1 DAR 683:384], q=2-31, 959 kb/s, 1 fps, 16384 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    2 fps=0.0 q=-1.0 Lsize=     220kB time=00:00:02.00 bitrate= 899.1kbits/s    
video:219kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.361198%

comment:3 by Carl Eugen Hoyos, 10 years ago

Resolution: worksforme
Status: newclosed
Version: 2.0.1git-master

I tested the following:

$ ./ffmpeg -i tests/lena.pnm -pix_fmt yuvj420p out.jpg
ffmpeg version N-57290-g87eae03 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 21 2013 14:17:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      52. 47.101 / 52. 47.101
  libavcodec     55. 37.102 / 55. 37.102
  libavformat    55. 19.103 / 55. 19.103
  libavdevice    55.  4.100 / 55.  4.100
  libavfilter     3. 88.102 /  3. 88.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, image2, from 'tests/lena.pnm':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0x2254380] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'out.jpg':
  Metadata:
    encoder         : Lavf55.19.103
    Stream #0:0: Video: mjpeg, yuvj420p, 256x256, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (ppm -> mjpeg)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:12kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.177334%
$ cat out.jpg | ./ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 /out1.mp4 /out2.mp4
ffmpeg version N-57290-g87eae03 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 21 2013 14:17:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      52. 47.101 / 52. 47.101
  libavcodec     55. 37.102 / 55. 37.102
  libavformat    55. 19.103 / 55. 19.103
  libavdevice    55.  4.100 / 55.  4.100
  libavfilter     3. 88.102 /  3. 88.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, image2pipe, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 256x256, 1 tbr, 1 tbn, 1 tbc
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
    Last message repeated 1 times
[libx264 @ 0x2c5c640] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x2c5c640] profile High, level 1.2
[libx264 @ 0x2c5c640] 264 - core 128 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=-2 threads=12 lookahead_threads=2 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=1 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
[libx264 @ 0x2c5de60] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x2c5de60] profile High, level 1.2
[libx264 @ 0x2c5de60] 264 - core 128 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=-2 threads=12 lookahead_threads=2 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=1 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, mp4, to '/out1.mp4':
  Metadata:
    encoder         : Lavf55.19.103
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p, 256x256, q=-1--1, 16384 tbn, 1 tbc
Output #1, mp4, to '/out2.mp4':
  Metadata:
    encoder         : Lavf55.19.103
    Stream #1:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p, 256x256, q=-1--1, 16384 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> libx264)
  Stream #0:0 -> #1:0 (mjpeg -> libx264)
pipe:: Input/output error
frame=    1 fps=0.0 q=17.0 Lq=17.0 size=      15kB time=00:00:01.00 bitrate= 119.5kbits/s
video:28kB audio:0kB subtitle:0 global headers:0kB muxing overhead -47.316075%
[libx264 @ 0x2c5c640] frame I:1     Avg QP:19.09  size: 13463
[libx264 @ 0x2c5c640] mb I  I16..4:  2.3% 96.1%  1.6%
[libx264 @ 0x2c5c640] 8x8 transform intra:96.1%
[libx264 @ 0x2c5c640] coded y,uvDC,uvAC intra: 98.6% 99.2% 89.5%
[libx264 @ 0x2c5c640] i16 v,h,dc,p: 33%  0%  0% 67%
[libx264 @ 0x2c5c640] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33%  7% 18%  9%  5%  7%  3% 12%  6%
[libx264 @ 0x2c5c640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48%  6%  5% 11%  3%  8%  2% 12%  5%
[libx264 @ 0x2c5c640] i8c dc,h,v,p: 41%  7% 37% 16%
[libx264 @ 0x2c5c640] kb/s:107.70
[libx264 @ 0x2c5de60] frame I:1     Avg QP:19.09  size: 13463
[libx264 @ 0x2c5de60] mb I  I16..4:  2.3% 96.1%  1.6%
[libx264 @ 0x2c5de60] 8x8 transform intra:96.1%
[libx264 @ 0x2c5de60] coded y,uvDC,uvAC intra: 98.6% 99.2% 89.5%
[libx264 @ 0x2c5de60] i16 v,h,dc,p: 33%  0%  0% 67%
[libx264 @ 0x2c5de60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33%  7% 18%  9%  5%  7%  3% 12%  6%
[libx264 @ 0x2c5de60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48%  6%  5% 11%  3%  8%  2% 12%  5%
[libx264 @ 0x2c5de60] i8c dc,h,v,p: 41%  7% 37% 16%
[libx264 @ 0x2c5de60] kb/s:107.70
$ ./ffmpeg -f concat -i <(for f in /out*.mp4; do echo "file '$f'"; done) -r 1 -c copy out.mp4
ffmpeg version N-57290-g87eae03 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 21 2013 14:17:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      52. 47.101 / 52. 47.101
  libavcodec     55. 37.102 / 55. 37.102
  libavformat    55. 19.103 / 55. 19.103
  libavdevice    55.  4.100 / 55.  4.100
  libavfilter     3. 88.102 /  3. 88.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, concat, from '/dev/fd/63':
  Duration: N/A, start: 0.000000, bitrate: 113 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 256x256, 113 kb/s, 1 fps, 1 tbr, 16384 tbn, 2 tbc
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf55.19.103
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 256x256, q=2-31, 113 kb/s, 1 fps, 16384 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    2 fps=0.0 q=-1.0 Lsize=      28kB time=00:00:02.00 bitrate= 116.3kbits/s
video:28kB audio:0kB subtitle:0 global headers:0kB muxing overhead 2.825518%

The output file plays fine here with ffplay and can be decoded with ffmpeg:

$ ./ffmpeg -i out.mp4 -f framecrc -
ffmpeg version N-57290-g87eae03 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 21 2013 14:17:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      52. 47.101 / 52. 47.101
  libavcodec     55. 37.102 / 55. 37.102
  libavformat    55. 19.103 / 55. 19.103
  libavdevice    55.  4.100 / 55.  4.100
  libavfilter     3. 88.102 /  3. 88.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.19.103
  Duration: 00:00:02.00, start: 0.000000, bitrate: 116 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 256x256, 113 kb/s, 1 fps, 1 tbr, 16384 tbn, 2 tbc (default)
    Metadata:
      handler_name    : VideoHandler
#tb 0: 1/1
Output #0, framecrc, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.19.103
    Stream #0:0(und): Video: rawvideo (I420 / 0x30323449), yuvj420p, 256x256, q=2-31, 200 kb/s, 1 tbn, 1 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
0,          0,          0,        1,    98304, 0x985374d7
0,          1,          1,        1,    98304, 0x985374d7
frame=    2 fps=0.0 q=0.0 Lsize=       0kB time=00:00:02.00 bitrate=   0.5kbits/s
video:192kB audio:0kB subtitle:0 global headers:0kB muxing overhead -99.935404%

If you want to reopen this ticket, please test with -vcodec mpeg4 instead of h264, this makes reproducing the issue much easier and please also test with tests/lena.pnm (part of FFmpeg source distribution).

Note: See TracTickets for help on using tickets.