Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-2 Encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd July 2024, 16:23   #1  |  Link
Trixter
Registered User
 
Join Date: Oct 2003
Posts: 215
Change field-order flag in MPEG-2 program stream?

I have hundreds of MPEG-2 program stream files where, for reasons unknown, the field order flag in the program stream is wrong. This obviously leads to incorrect decoding on software players, showing the fields out of order which results in jittery playback.

Is there a utility or batch process I can use to simply set the field order flag in an MPEG-2 program stream to a specific field order? Linux or Windows is preferred. The goal is to avoid anything interactive, since I'm not going to do hundreds of these interactively.

I'd like to do this without demuxing/remuxing because I'm worried about sync. I have FFMPEG installed, but wasn't able to figure out how to do it with FFMPEG without remuxing.
Trixter is offline   Reply With Quote
Old 5th August 2024, 00:05   #2  |  Link
Trixter
Registered User
 
Join Date: Oct 2003
Posts: 215
A kind random internet stranger helped me with this, so I thought I'd pay it forward by putting the final solution here for others to find. Their reply follows:

It's not possible in ffmpeg, because the mpeg-2 bitstream filter's limited. Trusty old Restream could do it, but AFAIK there's no batch option:
https://www.videohelp.com/software/Restream

There's a Linux version of DGPulldown that added the option to change the TFF flag.
https://github.com/jaystevens/dgpull...pulldown_linux
Clone the repo, and run the make file.

From the README:
To flag an interlaced m2v file as top field first use the command
Code:
dgpulldown input.m2v -interlaced -o output.m2v
to flag an interlaced m2v file as bottom field first use the command
Code:
dgpulldown input.m2v -interlaced -bff -o output.m2v
The workflow outlined below works for my test files, which come from my recent experiments with BD-to-DVD conversion on Linux (without using Wine). My concern is that it might not be as successful with the quirks of "real world" files (captures, old recordings, etc) that are not fresh out of the encoder. The new option for dgpulldown caught my eye when building it from source in order to apply soft telecine to some m2v files; it was simply chance that your post on Doom9 caught my eye when researching some MPEG-2 settings.

Demux (to m2v and m2a)
Code:
for file in *.mpg; do ffmpeg -i "$file" -map 0:v:0 -c:v copy "${file%.mpg}.m2v" -map 0:a:0 -c:a copy "${file%.mpg}.m2a" ; done
Reflag (each m2v in turn)
Code:
# BFF
for file in *.m2v; do dgpulldown "$file" -interlaced -bff -o "${file%.m2v}.mpv"; done
# TFF
for file in *.m2v; do dgpulldown "$file" -interlaced -o "${file%.m2v}.mpv"; done
Remux
Option 1: ffmpeg
Code:
for file in *.mpv; do ffmpeg -fflags +genpts -i "${file}" -i "${file//.mpv/.m2a}" -c copy "${file//.mpv/_remux.mpg}"; done
Option2: mplex, which is part of mjpegtools
Code:
for file in *.mpv; do mplex -f 8 -o "${file//.mpv/_remux.mpg}" "${file}" "${file//.mpv/.m2a}"; done
Again, this is all in bash. The assumption is that the filename of each input remains constant throughout the process, allowing bash to make a series of substitutions of the file extension (as well as leave the input file in place):
whatever.mpg -> whatever.m2v (& whatever.m2a) -> whatever.mpv -> whatever_remux.mpg
But please back up your files beforehand. :-)
Trixter is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.