Okay, so a bit of background information on what I'm trying to do. I have a source video that is 720p that I've enhanced and upscaled. The goal is to be able to just plug the upscaled version of the video into any project that uses the original clip in an NLE without having to worry about said NLE throwing a fit that the file is "different" in some way. For various reasons I've had to work with the restored footage as still files, so I currently have a PNG image sequence that will become my output file.
Having said that, here's where things get dicey: The original file is over a decade old, I'm guessing whoever worked on it originally probably did so in Adobe Premiere Pro or After Effects based on data indicating that the Mainconcept Media Encoder was used. I'm currently creating the new file using FFMpeg as FFMpeg is the only app that I'm aware of that lets me control as many parameters of the video that I need to control for it to be as identical to the original as humanly possible. I'm also using MP4Box to make sure that FFMpeg and MediaInfo aren't lying to me, or that if there are discrepancies, I can determine if they're just metadata discrepancies or something more significant.
The first headache I run into is that the source file tells me that it's VFR when I use the following command:Code:./ffmpeg -i INPUT -vf vfrdet -an -f null -Specifically, if I'm reading the output above correctly, the file is telling me that eight frames are VFR, and the rest of the video is CFR. (Ugh, why!?) This is creating several subsequent headaches, as I cannot figure out how to get a VFR file out of the image sequence, and I'm not even sure that the file really is VFR to begin with.Code:[Parsed_vfrdet_0 @ 0x6000003e0000] VFR:0.002680 (8/2977) min: 999 max: 1000 avg: 999
My next attempt to figure out how the original file was encoded was to get metadata/frame information about the file using the code below:
That lead to me generating two sets of data to compare how each file was encoded. Frame 950 seems to be where things start to go sideways; the original file has PTS of 949999 while my test file has PTS of 950000. The original file's best effort timestamp is 39.583292 and the new file's best effort timestamp is 39.583333, after that the timestamps continue to vary slightly.Code:./ffprobe -show_frames -of compact=p=0 -select_streams v:0 -f lavfi "movie=INPUT" > Input_Data.txt
Additionally, MP4Box reports the original file of having a duration of "00:02:04.458 (recomputed to 00:02:04.416)" with the video track being "00:02:04.416 (recomputed to 00:02:04.416)" and the audio track being "00:02:04.458 (recomputed to 00:02:04.458)," and no, those aren't typos for the "recomputed" values. My test output when muxed with audio has a duration of 00:02:04.416 with nothing recomputed, a video track with a duration of "00:02:04.416 (recomputed to 00:02:04.500)" and an audio track with a duration of "00:02:04.416 (recomputed to 00:02:04.416)"
Oh, and just to add to this nightmare, the audio track has some differences despite being a stream copy. I'm including FFMpeg and MP4Box information below, as well as the commands I've used to get to this point. I tried to encode the image sequence as a second input and stream copy the original file as well at one point (thinking I could use -vsync passthrough -copyts and enc_time_base -1 on the first stream to get the second stream to copy its PTS/DTS,) but it resulted in the same output I got transcoding the image sequence by itself.
FFMpeg Input File Information
FFMpeg Output File InformationCode:Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'INPUT': Metadata: major_brand : M4V minor_version : 1 compatible_brands: M4V mp42isom creation_time : 2013-04-11T06:14:38.000000Z Duration: 00:02:04.42, start: 0.000000, bitrate: 6085 kb/s Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 5956 kb/s, 24 fps, 24 tbr, 24k tbn (default) Metadata: creation_time : 2013-04-11T06:14:38.000000Z handler_name : Mainconcept MP4 Video Media Handler vendor_id : [0][0][0][0] encoder : AVC Coding Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default) Metadata: creation_time : 2013-04-11T06:14:38.000000Z handler_name : Mainconcept MP4 Sound Media Handler vendor_id : [0][0][0][0]
FFMpeg Muxed Output File InformationCode:Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'OUTPUT': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.3.100 Duration: 00:02:04.42, start: 0.000000, bitrate: 153605 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt709/bt709, progressive), 5120x2880 [SAR 1:1 DAR 16:9], 153602 kb/s, 24 fps, 24 tbr, 24k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc60.3.100 libx264
MP4Box Input File InformationCode:Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MUX': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.3.100 Duration: 00:02:04.42, start: 0.000000, bitrate: 153733 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt709/bt709, progressive), 5120x2880 [SAR 1:1 DAR 16:9], 153602 kb/s, 24 fps, 24 tbr, 24k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc60.3.100 libx264 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default) Metadata: handler_name : Mainconcept MP4 Sound Media Handler vendor_id : [0][0][0][0]
MP4Box Output File InformationCode:user@MAC DIRECTORY % MP4Box -info INPUT # Movie Info - 2 tracks - TimeScale 90000 Duration 00:02:04.458 (recomputed 00:02:04.416) Fragmented: no Progressive (moov before mdat) Major Brand M4V - version 1 - compatible brands: M4V mp42 isom Created: GMT Thu Apr 11 06:14:38 2013 - Modified: GMT Thu Apr 11 06:14:41 2013 File has root IOD (56 bytes) Scene PL 0xff - Graphics PL 0xff - OD PL 0xff Visual PL: No visual capability required (0xff) Audio PL: No audio capability required (0xff) 3 UDTA types: A9TIM: A9TSC: A9TSZ: # Track 1 Info - ID 1 - TimeScale 24000 Media Duration 00:02:04.416 (recomputed 00:02:04.416) Track has 1 edits: track duration is 00:02:04.416 Track flags: Enabled In Movie In Preview Media Language: English (eng) Media Samples: 2986 Visual Track layout: x=0 y=0 width=1280 height=720 Media Type: vide:avc1 Visual Sample Entry Info: width=1280 height=720 (depth=24 bits) MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21 AVC/H264 Video - Visual Size 1280 x 720 AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3.2 NAL Unit length bits: 32 Pixel Aspect Ratio 1:1 - Indicated track size 1280 x 720 Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8 SPS#1 hash: AD1AAEB59ABE8581C2802B784803995EB48E3610 PPS#1 hash: 9FE41F73137FD50C444BB8D37D9F982FC8B8A2A0 Synchronized on stream 2 RFC6381 Codec Parameters: avc1.4D0020 Average GOP length: 69 samples Max sample duration: 1000 / 24000 # Track 2 Info - ID 2 - TimeScale 48000 Media Duration 00:02:04.458 (recomputed 00:02:04.458) Track has 1 edits: track duration is 00:02:04.416 Track is present in Root OD Track flags: Enabled In Movie In Preview Media Language: English (eng) Media Samples: 5834 Media Type: soun:mp4a MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40 MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 48000 Self-synchronized RFC6381 Codec Parameters: mp4a.40.2 All samples are sync Max sample duration: 1024 / 48000
MP4Box Muxed Output File InformationCode:user@MAC DIRECTORY % MP4Box -info OUTPUT # Movie Info - 1 track - TimeScale 90000 Duration 00:02:04.416 Fragmented: no Major Brand isom - version 512 - compatible brands: isom iso2 avc1 mp41 Created: UNKNOWN DATE Meta-Data Tags: tool: Lavf60.3.100 # Track 1 Info - ID 1 - TimeScale 24000 Media Duration 00:02:04.416 (recomputed 00:02:04.500) Track has 1 edits: track duration is 00:02:04.416 Track flags: Enabled In Movie Media Samples: 2986 - CFR 24/sec Visual Track layout: x=0 y=0 width=5120 height=2880 Media Type: vide:avc1 Visual Sample Entry Info: width=5120 height=2880 (depth=24 bits) AVC/H264 Video - Visual Size 5120 x 2880 AVC Info: 1 SPS - 1 PPS - Profile High @ Level 6 NAL Unit length bits: 32 Pixel Aspect Ratio 1:1 - Indicated track size 5120 x 2880 Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8 SPS#1 hash: 3A957F75F404DF1E0B56CD53FBB10F1F561FA4D9 PPS#1 hash: 627EB45004BDA8601EB779F459C1E8F05779D1BF RFC6381 Codec Parameters: avc1.64003C Average GOP length: 87 samples Max sample duration: 1000 / 24000
FFMpeg Encoding Command for image sequenceCode:user@MAC DIRECTORY % MP4Box -info MUX # Movie Info - 2 tracks - TimeScale 90000 Duration 00:02:04.416 Fragmented: no Major Brand isom - version 512 - compatible brands: isom iso2 avc1 mp41 Created: UNKNOWN DATE Meta-Data Tags: tool: Lavf60.3.100 # Track 1 Info - ID 1 - TimeScale 24000 Media Duration 00:02:04.416 (recomputed 00:02:04.500) Track has 1 edits: track duration is 00:02:04.416 Track flags: Enabled In Movie Media Samples: 2986 - CFR 24/sec Visual Track layout: x=0 y=0 width=5120 height=2880 Media Type: vide:avc1 Visual Sample Entry Info: width=5120 height=2880 (depth=24 bits) AVC/H264 Video - Visual Size 5120 x 2880 AVC Info: 1 SPS - 1 PPS - Profile High @ Level 6 NAL Unit length bits: 32 Pixel Aspect Ratio 1:1 - Indicated track size 5120 x 2880 Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8 SPS#1 hash: 3A957F75F404DF1E0B56CD53FBB10F1F561FA4D9 PPS#1 hash: 627EB45004BDA8601EB779F459C1E8F05779D1BF RFC6381 Codec Parameters: avc1.64003C Average GOP length: 87 samples Max sample duration: 1000 / 24000 # Track 2 Info - ID 2 - TimeScale 48000 Media Duration 00:02:04.416 Track has 1 edits: track duration is 00:02:04.416 Track flags: Enabled In Movie Media Language: English (eng) Media Samples: 5833 Alternate Group ID 1 Media Type: soun:mp4a MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 48000 RFC6381 Codec Parameters: mp4a.40.2 All samples are sync Max sample duration: 1024 / 48000
Note: I've tried the above with both -vsync passthrough and -vsync vfr, and both options yield the same CFR output. -enc_time_base -1 Isn't usable on an image sequence as it has no timebase. (I'm also aware that the color primaries/matrix/transfer curve metadata isn't really handled well with the above command; my plan was to tag those properly on the final file which would be h265 rather than h264; right now I'm just using h264 to try and figure out this duration insanity.)Code:./ffmpeg -framerate 24000/1000 -i /path/to/image/sequence/%06d.png -c:v libx264 -vf "scale=out_color_matrix=bt709:out_range=tv" -pix_fmt yuv420p -movie_timescale 90000 -video_track_timescale 24000 -vsync passthrough -enc_time_base 1:24 -copyts -copytb 0 -crf 17 OUTPUT
I'm going to attempt to attach the files with the frame data to this post. (Unfortunately the forums don't have spoiler tags and the frame data would make this already long post the size of the dictionary.)
Any help is greatly appreciated. If I don't figure this out by Wednesday the next time I pick it up will probably be either a week from Thursday or later so hopefully someone will see this before then and have a solution that I can try. One last thing I should note is that I did create MKV Timecode v2 text files (I had hoped to avoid MKV entirely but I was desperate enough to try that as well,) and the MKV timecodes from both files are identical, which I'm guessing is the result of MKV using a 1K timebase instead of the 90k timebase of the source MP4.
Finally, please ignore the specs in my signature, for the purpose of this project I'm running an Apple Silicon M1 Mac (not Pro/Max/Ultra, just the standard M1) with an 8-Core CPU, 8-Core GPU, and 16GB RAM.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 1 of 1
Thread
-
Specs: Mac Mini (Early 2006): 1.66 GHz Intel Core Duo CPU, 320GB HDD, 2GB DDR2 RAM, Intel GMA 950 integrated graphics card, Matshita UJ-846 Superdrive, Mac OS X 10.5.7 and various peripherals. System runs Final Cut Express 3.5 for editing.
Similar Threads
-
Do I need to keep the AC3 track if I am keeping a DTS, DTS-HD MA, TrueHD?
By MarioVideo in forum AudioReplies: 6Last Post: 14th Oct 2023, 04:43 -
How to change audio speed starting from DDP, DTS-MA, AC3 or DTS core?
By precipizio in forum AudioReplies: 0Last Post: 22nd May 2022, 09:28 -
Using FFMPEG to copy PTS from one video to another video, is this possible?
By Cyrax9 in forum MacReplies: 1Last Post: 11th Feb 2022, 17:37 -
Wrong PTS times after h264 conversion.
By Budman1 in forum Video ConversionReplies: 2Last Post: 15th Mar 2020, 13:34 -
How to apply a filter to only one part of a video.
By Fraugster in forum EditingReplies: 26Last Post: 13th Sep 2019, 13:14