Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#536 closed enhancement (fixed)

Mux H264 and AAC into WTV

Reported by: Ian Kennedy Owned by: Michael Niedermayer
Priority: wish Component: avformat
Version: git-master Keywords: wtv
Cc: ramitbhalla@gmail.com Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

H.264 and AAC are supported in WTV. One of the main reasons MSFT moved to WTV was to support these formats (required for ISDB-T).

Change History (12)

comment:1 by Carl Eugen Hoyos, 13 years ago

Component: FFmpegavformat
Keywords: mux h.264 aac removed
Priority: normalwish
Reproduced by developer: set
Status: newopen
Summary: WTV MUX - Cannot consume AAC audio or H.264 video...Mux H264 and AAC into WTV
Version: unspecifiedgit-master

Demuxing works fine.

For future reports:
Please always provide a failing command line including complete, uncut output

$ ./ffmpeg -i fate-suite/h264-conformance/AUD_MW_E.264 -vcodec copy out.wtv
ffmpeg version N-33344-g86602d1, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct  7 2011 10:23:52 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc --enable-libmp3lame
  libavutil    51. 20. 0 / 51. 20. 0
  libavcodec   53. 19. 1 / 53. 19. 1
  libavformat  53. 14. 0 / 53. 14. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
[h264 @ 0x12d3780] Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 25.00 (50/2)
Input #0, h264, from 'fate-suite/h264-conformance/AUD_MW_E.264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 176x144, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[wtv @ 0x12d40e0] can't get video codec_id (0x1c) guid.
[wtv @ 0x12d40e0] write stream codec info failed codec_type(0x0)
[wtv @ 0x12d40e0] write stream codec failed codec_type(0x0)
Output #0, wtv, to 'out.wtv':
  Metadata:
    encoder         : Lavf53.14.0
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 176x144, q=2-31, 90k tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?)
$ ./ffmpeg -i fate-suite/aac/al04_44.mp4 -acodec copy out.wtv
ffmpeg version N-33344-g86602d1, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct  7 2011 10:23:52 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc --enable-libmp3lame
  libavutil    51. 20. 0 / 51. 20. 0
  libavcodec   53. 19. 1 / 53. 19. 1
  libavformat  53. 14. 0 / 53. 14. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fate-suite/aac/al04_44.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2004-02-19 14:38:56
  Duration: 00:00:08.24, start: 0.000000, bitrate: 67 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 1 channels, s16, 63 kb/s
    Metadata:
      creation_time   : 2004-02-19 14:38:56
[wtv @ 0x12e40a0] can't get video codec_id (0x15002) guid.
[wtv @ 0x12e40a0] write stream codec info failed codec_type(0x1)
[wtv @ 0x12e40a0] write stream codec failed codec_type(0x1)
Output #0, wtv, to 'out.wtv':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2004-02-19 14:38:56
    encoder         : Lavf53.14.0
    Stream #0:0(und): Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, 1 channels, 63 kb/s
    Metadata:
      creation_time   : 2004-02-19 14:38:56
Stream mapping:
  Stream #0.0 -> #0.0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?)

comment:2 by ramitb, 12 years ago

Refer to Ticket #1945 for sample files.

Anyone have any thoughts on how this can be fixed. Pending for a long time...so close to getting WTV to work perfectly, yet so far :)

comment:3 by ramitb, 12 years ago

Okay here is FUNNY part, I can stream copy a H264 video file into a WTV file and also recode it to H264 (using the libx264 codec - mpeg4 codec doesnt seem to play back in WMP) but only if I specify -f mpegts in the command line.

If I don't specify -f mpegts in the command line it won't work, but if I do it works.

ie:

ffmpeg -i h264.wtv -vcodec copy -acodec copy test.wtv

will fail
but

ffmpeg -i h264.wtv -vcodec copy -acodec copy -f mpegts test.wtv

will work

ffmpeg -i h264.wtv -vcodec libx264 -acodec copy -f mpegts test.wtv

also works

Am I missing something?

comment:4 by ramitb, 12 years ago

It also works with a MP4 or any other input file. Though I can't figure out why the mpeg4 codec doesn't play back when libxvid does

This is with build ffmpeg version N-48065-g6375318

comment:5 by Ian Kennedy, 12 years ago

When you use "-f mpegts" you do not get a valid WTV file. You get a transport stream.

It will not show in Media Center and things like run-time will not show in the windows shell and DShow will choke on it (will not open in graph studio). So the file extension may be .wtv, but that ain't what you get.

You get an MPEG transport stream. If you rename it to a ".ts" file you'll get it to load in graphedt or any other DShow app (as long as you have filters).

comment:6 by ramitb, 12 years ago

That's true, but I can see it plays in WMC and WMP. However that leads me to another question, what is the native WTV format?

Also, if I try to stream copy MPEG2 video into the WTV file it doesn't work without the -f mpegts flag. So the question is what parameters should one use to create a WTV file and trying to stream copy a video?

Here's the other thing I noticed:
ffmpeg -i h264.wtv -vcodec libx264 -acodec copy -f mpegts test.wtv - WORKS and plan on WMP/MCE!

ffmpeg -i h264.ts -vcodec libx264 -acodec copy -f mpegts test.wtv - DOES NOT WORK and plan on WMP/MCE!

Any idea why?

comment:7 by Ian Kennedy, 12 years ago

It plays because you've got the right filters on the machine and the player stack is smart enough to see beyond the file name extension.

WTV is a propriety format. Support in ffmpeg is reverse engineered.

comment:8 by ramitb, 12 years ago

Yep you're correct sorry about that, it's only working on WMP thanks to the filters, MCE won't play with them

comment:9 by ramitb, 12 years ago

Cc: ramitbhalla@gmail.com added

in reply to:  8 comment:10 by Ian Kennedy, 12 years ago

Replying to ramitbhalla:

Yep you're correct sorry about that, it's only working on WMP thanks to the filters, MCE won't play with them

That's because MC thinks it's a WTV file that is corrupted. The playback pipeline for TV is totally different than for other video.

Way OT here but: Media Center uses WMP under the hood to play anything NOT TV. And if you are on 64bit windows it uses 64bit WMP while 32bit WMP is the default player when access from the Windows desktop.

So there are tons of permutations where a file can play in WMP but not in MC, in addition to this scenario where the WTV file is bogus and MC refuses to allow it to be played or even visible from the TV gallery.

Back OT: it sure would be swell if this got fixed. One-stop trans-code to H.264 with preserved metadata would be super cool.

comment:11 by Carl Eugen Hoyos, 11 years ago

Resolution: fixed
Status: openclosed

Implemented by Peter Ross in e4be0765

comment:12 by ramitb, 11 years ago

Thank you very much PETER ROSS and team.

While this works at the outset (i.e. with a direct encode like -vcodec mpeg4), I noticed that the sample file in ticket #1945 csi.mp4 when copied using -vcodec copy it does not play back in WMP or WMC.

Note: See TracTickets for help on using tickets.