Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3638 closed defect (fixed)

ffmpeg converting mp4 with h.264 to avi - no video in WMP

Reported by: ramitb Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: avi h264
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: If ffmpeg is used to remux a mp4 h264 file to avi file, the resulting avi file does not play back (video) in WMP. However if ffmepg creates the avi file directly instead of remuxing mp4 to avi, it plays back fine.

Is there some wrong in the command or is it a bug?

How to reproduce:

ffmpeg -i "HD Leeber_UK_Call the Midwi
fe_BBC One HD_2012_02_19_20_25_00.mp4" -vcodec copy -acodec copy -f avi test.avi -y
ffmpeg version N-62897-g0f9f24c Copyright (c) 2000-2014 the FFmpeg developers
  built on May  1 2014 23:29:04 with gcc 4.8.0 (GCC)
  configuration: --arch=x86 --target-os=mingw32 --cross-prefix=/home/mcebuddy/Software/ffmpeg/sandbox/mingw-w64-i686/bin
/i686-w64-mingw32- --pkg-config=pkg-config --enable-hwaccels --enable-dxva2 --enable-gpl --enable-libx264 --enable-avisy
nth --enable-libxvid --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-li
btheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-libopus --d
isable-w32threads --enable-frei0r --enable-filter=frei0r --enable-libvo-aacenc --enable-bzlib --enable-libxavs --extra-c
flags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschro
edinger --enable-libvpx --enable-libilbc --prefix=/home/mcebuddy/Software/ffmpeg/sandbox/mingw-w64-i686/i686-w64-mingw32
 --enable-static --disable-shared --enable-libsoxr --enable-fontconfig --enable-libass --enable-libutvideo --enable-libb
luray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_STATIC --enable-libzvbi --enable-libcaca --enable-l
ibmodplug --extra-libs=-lstdc++ --extra-libs=-lpng --enable-libvidstab --extra-cflags= --extra-cflags= --enable-nonfree
--enable-libfdk-aac --enable-libfaac --enable-runtime-cpudetect
  libavutil      52. 80.100 / 52. 80.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  5.100 /  4.  5.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'HD Leeber_UK_Call the Midwife_BBC One HD_2012_02_19_20_25_00.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : MCEBuddy
    title           : Call the Midwife
    show            : Call the Midwife
    media_type      : 10
    network         : BBC One HD
    genre           : Drama
    date            : 2012-02-18T19:00:00Z
    description     : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
    synopsis        : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
    comment         : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
  Duration: 00:00:16.08, start: 0.074000, bitrate: 3702 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x544 [SAR 24446:18225 DAR 719:405],
 3336 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 384 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, avi, to 'test.avi':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    ICMT            : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
    INAM            : Call the Midwife
    show            : Call the Midwife
    media_type      : 10
    network         : BBC One HD
    IGNR            : Drama
    ICRD            : 2012-02-18T19:00:00Z
    description     : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
    synopsis        : Drama set in 1950s London. Sister Monica Joan is accused of theft, and the Nonnatus House communit
y fear she could end up in jail. Meanwhile, Chummy's mother visits.
    ISFT            : Lavf55.37.102
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 720x544 [SAR 24446:18225 DAR 719:405], q=2-31, 3336 kb/s
, 25 fps, 50 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 384 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  402 fps=0.0 q=-1.0 Lsize=    7297kB time=00:00:15.98 bitrate=3740.9kbits/s
video:6549kB audio:708kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.553938%}}}

Not attaching a file, since it is replicable with any mp4 file.

Attachments (1)

test.avi (680.2 KB ) - added by ramitb 10 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 by ramitb, 10 years ago

Anyways upload the file #3638.mp4 for your reference.

comment:2 by ramitb, 10 years ago

this file was created by handbrake

in reply to:  description comment:3 by Carl Eugen Hoyos, 10 years ago

Replying to ramitbhalla:

if ffmpeg creates the avi file directly instead of remuxing mp4 to avi, it plays back fine.

Could you provide such a sample?

comment:4 by Carl Eugen Hoyos, 10 years ago

WMP 12 does not play video here for the file #3638.avi that you uploaded. Which version did you test?

comment:5 by ramitb, 10 years ago

That's the point, this was the avi created by the above ffmpeg command using the uploaded mp4 file. The video does not playback.

comment:6 by Carl Eugen Hoyos, 10 years ago

Please upload a sample that plays back fine after creating the avi file directly with ffmpeg.

comment:7 by ramitb, 10 years ago

I don't understand, any video encoded with ffmpeg (using libxvid or mpeg4 or libx264) works just fine, just when I stream copy it doesn't playback.

Infact the mp4 sample I uploaded if you convert that using vcodec libx264 works fine.

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

Replying to ramitbhalla:

I don't understand, any video encoded with ffmpeg (using libxvid or mpeg4 or libx264) works just fine, just when I stream copy it doesn't playback.

It does not work fine for me, so please upload any video (not encoded with libxvid or mpeg4).

comment:9 by ramitb, 10 years ago

attaching the output test.avi

here is the command line:

ffmpeg -i ee.ts -vcodec libx264 -acodec copy -crf 26 -sn -t 2 test.avi
ffmpeg version N-62897-g0f9f24c Copyright (c) 2000-2014 the FFmpeg developers
  built on May  1 2014 23:29:04 with gcc 4.8.0 (GCC)
  configuration: --arch=x86 --target-os=mingw32 --cross-prefix=/home/mcebuddy/Software/ffmpeg/sandbox/mingw-w64-i686/bin
/i686-w64-mingw32- --pkg-config=pkg-config --enable-hwaccels --enable-dxva2 --enable-gpl --enable-libx264 --enable-avisy
nth --enable-libxvid --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-li
btheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-libopus --d
isable-w32threads --enable-frei0r --enable-filter=frei0r --enable-libvo-aacenc --enable-bzlib --enable-libxavs --extra-c
flags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschro
edinger --enable-libvpx --enable-libilbc --prefix=/home/mcebuddy/Software/ffmpeg/sandbox/mingw-w64-i686/i686-w64-mingw32
 --enable-static --disable-shared --enable-libsoxr --enable-fontconfig --enable-libass --enable-libutvideo --enable-libb
luray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_STATIC --enable-libzvbi --enable-libcaca --enable-l
ibmodplug --extra-libs=-lstdc++ --extra-libs=-lpng --enable-libvidstab --extra-cflags= --extra-cflags= --enable-nonfree
--enable-libfdk-aac --enable-libfaac --enable-runtime-cpudetect
  libavutil      52. 80.100 / 52. 80.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  5.100 /  4.  5.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpegts, from 'ee.ts':
  Duration: 00:00:26.35, start: 1.424000, bitrate: 12059 kb/s
  Program 1
    Metadata:
      service_name    : WMORDT (WMOR-DT)
      service_provider: WMORDT
    Stream #0:0[0x100]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 384 kb/s
    Stream #0:1[0x101]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], max
. 65000 kb/s, 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
[libx264 @ 0407f9e0] using SAR=1/1
[libx264 @ 0407f9e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0407f9e0] profile High, level 4.0
Output #0, avi, to 'test.avi':
  Metadata:
    ISFT            : Lavf55.37.102
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 tbn, 2
9.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 384 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (mpeg2video -> libx264)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   46 fps=6.4 q=-1.0 Lsize=     680kB time=00:00:02.01 bitrate=2763.9kbits/s
video:573kB audio:94kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.885727%
[libx264 @ 0407f9e0] frame I:1     Avg QP:25.72  size:110237
[libx264 @ 0407f9e0] frame P:12    Avg QP:26.29  size: 26791
[libx264 @ 0407f9e0] frame B:33    Avg QP:29.47  size:  4700
[libx264 @ 0407f9e0] consecutive B-frames:  4.3%  0.0%  0.0% 95.7%
[libx264 @ 0407f9e0] mb I  I16..4:  8.4% 90.6%  0.9%
[libx264 @ 0407f9e0] mb P  I16..4:  0.4%  0.8%  0.0%  P16..4: 55.2% 10.9%  6.7%  0.0%  0.0%    skip:26.1%
[libx264 @ 0407f9e0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 36.4%  0.3%  0.0%  direct: 0.2%  skip:63.0%  L0:45.6% L1:5
3.0% BI: 1.4%
[libx264 @ 0407f9e0] 8x8 transform intra:87.5% inter:89.4%
[libx264 @ 0407f9e0] coded y,uvDC,uvAC intra: 77.9% 79.4% 20.8% inter: 10.3% 11.5% 0.1%
[libx264 @ 0407f9e0] i16 v,h,dc,p: 29% 27%  8% 36%
[libx264 @ 0407f9e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 29%  4%  5%  5%  5%  6%  7%
[libx264 @ 0407f9e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 35% 14%  3%  5%  5%  5%  4%  3%
[libx264 @ 0407f9e0] i8c dc,h,v,p: 44% 23% 23% 10%
[libx264 @ 0407f9e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0407f9e0] ref P L0: 47.9% 14.5% 29.0%  8.6%
[libx264 @ 0407f9e0] ref B L0: 84.0% 13.4%  2.7%
[libx264 @ 0407f9e0] ref B L1: 93.8%  6.2%
[libx264 @ 0407f9e0] kb/s:2654.74

by ramitb, 10 years ago

Attachment: test.avi added

comment:10 by ramitb, 10 years ago

this test.avi plays back fine in wmp (audio and video)

comment:11 by Carl Eugen Hoyos, 10 years ago

Component: undeterminedavformat
Keywords: avi added
Version: unspecifiedgit-master

The following works fine here:

$ ffmpeg -i #3638.mp4 -c copy -vbsf h264_mp4toannexb -vtag H264 out.avi

comment:12 by ramitb, 10 years ago

How did you know to add -vbsf h264_mp4toannexb. This was an issue with a recent WTV h.264 ticket also. Should this automaticlaly be taken care by the muxer here also?

comment:13 by Carl Eugen Hoyos, 10 years ago

No because we believe the original output file (as you produced it) is perfectly valid, just not as expected by WMP. I will send a new patch today that will refuse to mux a video stream with fourcc H264 into avi if no start code is present.

comment:14 by ramitb, 10 years ago

Instead of refusing to mux wouldn't it better to automatically add the flag to fix it?

comment:15 by Carl Eugen Hoyos, 10 years ago

Which flag do you mean?

comment:16 by ramitb, 10 years ago

if I understood your comment correctly, because of the missing -vbsf h264_mp4toannexb it failed to create a format recognized by WMP.

comment:17 by Carl Eugen Hoyos, 10 years ago

Keywords: h264 added
Resolution: fixed
Status: newclosed

No, I had not completely understood the issue myself originally, sorry.
H.264 can be muxed in different ways. WMP supports H.264 in avi only with fourcc H264 which indicates a H.264 elementary stream with startcodes (while fourcc avc1 indicates a stream without startcodes). So only if you choose fourcc H264 startcodes have to be present. This will be enforced in a commit later today.

If you use another fourcc than H264 for H.264 video, WMP will not play the resulting file. So far, we believe that other fourccs are also valid and that there is nothing about this that can be fixed within FFmpeg.

comment:18 by ramitb, 10 years ago

okay so essentially it's definiing the h264 fourcc that was missing. What's the vbsf flag for since I didn't see any warning from ffmpeg about it. Is that necessary? I had tried with the vbsf flag and it didn't work (h264 fourcc was set). Is that an issue with ffmpeg not displaying that the vbsf flag is rqeuied?

comment:19 by ramitb, 10 years ago

also from what you said if I had used -vtag avc1 it should work right? It didn't though.

in reply to:  19 comment:20 by Carl Eugen Hoyos, 10 years ago

Replying to ramitbhalla:

also from what you said if I had used -vtag avc1 it should work right? It didn't though.

It is superfluous for your input sample (that already uses avc1 as shown by the console output you posted) and it does work fine to the best of my knowledge.

comment:21 by Carl Eugen Hoyos, 10 years ago

I cannot comment on your other questions, I am not a native speaker, sorry.

Note: See TracTickets for help on using tickets.