I have an MP4 which contains an H264/AVC stream, which contains multiple resolutions.
Below is the output of mediainfo
on this file:
General
Complete name : known.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 661 KiB
Duration : 15s 960ms
Overall bit rate : 340 Kbps
Writing application : Lavf54.49.102
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 15s 960ms
Bit rate : 338 Kbps
Width : 176 pixels
Original width : 352 pixels
Height : 144 pixels
Original height : 288 pixels
Display aspect ratio : 1.222
Frame rate mode : Constant
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.534
Stream size : 659 KiB (100%)
After some research, the value Lavf54.49.102
appears to indicate that ffmpeg was used to encode this file.
Below is the output of ffplay
on this file:
ffplay known.mp4
ffplay version 2.4.3 Copyright (c) 2003-2014 the FFmpeg developers
built on Nov 9 2014 17:21:35 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-x11grab --enable-libpulse --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'known.mp4':= 0B f=0/0
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.49.102
Duration: 00:00:15.96, start: 0.000000, bitrate: 339 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 176x144, 338 kb/s, 25 fps, 25 tbr, 1200k tbn, 2400k tbc (default)
Metadata:
handler_name : VideoHandler
[h264 @ 0x7f756800b540] Reinit context to 352x288, pix_fmt: yuv420p
Note the last line [h264 @ 0x7f756800b540] Reinit context to 352x288, pix_fmt: yuv420p
; at this point ffplay
changes size to match this new resoltuion.
I am currently trying to reproduce this "multiple resolution" effect, firstly on the same video by decoding and then reencoding it, and once that is working I plan to encode another video in the same way to (hopefully) achieve the same. Once that works I shall try to achieve the same with other codecs that support this.
My efforts so far, even reencoding the same video using ffmpeg
, have yielded a video where one resolution is simply scaled to be the same size as the other, rather than actually encoding the stream with two different resolutions.
I've tried everything I can think of, ranging from a simple reencode to piping the output of ffmpeg
back into ffmpeg
, forcing the profile to baseline, converting the stream to mpg
, and so on. Nothing appears to be working.
My question is, how can I preserve a resoltuion change within ffmpeg
*, rather than it being scaled?
Thank you for any help in advance!
* although if the same result can be achieved with another encoder, that's good too!