View Full Version : Using FFMPEG to transcode a/v without changing containers?
keylimesoda
11th September 2015, 22:34
I've got a Windows Media Center that records all my content in MPEG2, using the WTV container.
I know from the documentation that FFMPEG inputs and outputs WTV format (https://www.ffmpeg.org/general.html#File-Formats). And there's lots of examples of how to change containers without transcoding content. And I know (from talking with the Microsoft WMC folks) that the WTV container can carry h264, MPEG2 or VC-1 content.
What I'm looking to do is transcode my MPEG2 WTV files into MPEG4 (h264) WTV files. The idea is to save disk space and make network playback easier (Kodi and VLC both natively support WTV playback), while maintaining high compatibility and metadata integration with my main WMC system.
foxyshadis
12th September 2015, 02:33
You can use any current guide to transcoding. An example, keeping audio as-is: ffmpeg -i input.wtv -c:v libx264 -preset slow -crf 22 -c:a copy -f wtv output.wtv
-crf is the size/quality parameter, lowering it gives you bigger, better files. 18-22 is suggested to start with. On modern computers even -preset veryslow is often fast enough, and will make it files a little smaller.
Your presets and tunings are: ultrafast superfast veryfast faster fast medium slow slower veryslow placebo; film animation grain stillimage psnr ssim fastdecode zerolatency
raffriff42
12th September 2015, 02:53
That's not a very good idea at all. FFMpeg >> WTV should be considered bleeding edge - at best. Wait until (a) it becomes stable, which might take several years (faster if you send a very large cash donation (https://www.ffmpeg.org/donations.html)to FFMpeg), (b) a vendor like Adobe supports it, or (c) Microsoft comes out with its own utility, similar to the old Expression Encoder.
Do these (https://www.google.com/search?q=ffmpeg+wtv+encode)sound like problems you want to deal with? How about these (https://www.google.com/search?q=ffmpeg+wtv+support+tickets)?
If you insist on trying it, here is a command line to get you started. There's nothing special about it: it's a standard x264 + ac3 command line with a wtv file extension on the output. You can tune it as foxyshadis mentions. It encodes without error messages, and the video plays* - that I will stand behind. But I can't give you support for any playback issues that you will (definitely) encounter. ffmpeg.exe -i "input.wtv" -c:a ac3 -b:a 192k -r 30 -c:v libx264 -profile baseline -preset medium -b:v 5000k -x264opts "colorprim=bt709:transfer=bt709:colormatrix=bt709" -pix_fmt yuv420p "output.wtv"
(EDIT I didn't even get into subtitles and metadata...)
(* played OK on MPC-HC but always skipped 1st 4-5 seconds on Win8 / Windows Media Player)
keylimesoda
14th September 2015, 18:35
Yeah, introducing issues into the WTV container during re-encoding would kind of defeat the point.
The whole goal is to change the video content without touching the container.
Is there some way to bypass re-encoding of the container?
EDIT: Looks like most of the bugs you listed have been closed/resolved? With the key one being: https://trac.ffmpeg.org/ticket/536
raffriff42
15th September 2015, 03:51
Is there some way to bypass re-encoding of the container?It's not a simple container in the way a cardboard box is; it's the structure of the file, and a set of indexes that allows the file to be read. New contents require rebuilding of the indexes.Multimedia container formats - Wikipedia (https://en.wikipedia.org/wiki/Digital_container_format#Multimedia_container_formats)
The container file is used to identify and interleave different data types. Simpler container formats can contain different types of audio formats, while more advanced container formats can support multiple audio and video streams, subtitles, chapter-information, and meta-data (tags) — along with the synchronization information needed to play back the various streams together. In most cases, the file header, most of the metadata and the synchro chunks are specified by the container format...
Container format parts have various names: "chunks" as in RIFF and PNG, "atoms" in QuickTime/MP4, "packets" in MPEG-TS (from the communications term), and "segments" in JPEG. The main content of a chunk is called the "data" or "payload". Most container formats have chunks in sequence, each with a header...
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.