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-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th May 2017, 14:01   #201  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
It has to be in numerator and denominator (x:y) format. ie for 23.976fps it'd be:
-vbsf h264_changesps=fps=24000:1001
or for 25fps fps=25:1 etc

I'm also pretty sure it only changes the frame rate written to the video stream. To also change it at the container level you'd need to remux it again with an MP4 muxer while setting the same frame rate.

If you don't do that, you'll probably find MediaInfo will display two frames rates. Something like this after changing the frame rate from 25fps to 23.976fps:

Frame rate : 25.000 FPS
Original frame rate : 23.976 (24000/1001) FPS

I'm not sure if ffmpeg will change the frame rate with the -r option if it's only copying the video stream. I don't use it much and almost never work with MP4. Someone else will probably know.

Last edited by hello_hello; 29th May 2017 at 15:12.
hello_hello is offline   Reply With Quote
Old 29th May 2017, 15:15   #202  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by hello_hello View Post
I'm also pretty sure it only changes the frame rate written to the video stream. To also change it at the container level you'd need to remux it again with an MP4 muxer while setting the same frame rate.
I believe it is supposed to also manipulate the mp4 container but since this ffmpeg version is ancient I'd rather use something else for muxing.

For example:
mkvmerge.exe -o "temp.mkv" --default-duration 0:24000/1001p --fix-bitstream-timing-information 0:1 "input.mp4"
ffmpeg -i "temp.mkv" -map 0 -c copy "output.mp4"

(using latest ffmpeg and latest mkvtoolnix)


If you only want to manipulate H.264 elementary streams you can also try videofan3d's new "h264Modify" tool. (mux and demux using e.g. mp4box)

Last edited by sneaker_ger; 29th May 2017 at 15:17.
sneaker_ger is offline   Reply With Quote
Old 29th May 2017, 21:36   #203  |  Link
Luke M
Registered User
 
Join Date: Oct 2014
Posts: 5
Quote:
Originally Posted by sneaker_ger View Post
I believe it is supposed to also manipulate the mp4 container
It doesn't.

Quote:
Originally Posted by sneaker_ger View Post
but since this ffmpeg version is ancient I'd rather use something else for muxing.

For example:
mkvmerge.exe -o "temp.mkv" --default-duration 0:24000/1001p --fix-bitstream-timing-information 0:1 "input.mp4"
ffmpeg -i "temp.mkv" -map 0 -c copy "output.mp4"

(using latest ffmpeg and latest mkvtoolnix)
That works. Thanks!

Something strange I noticed, when I play the .mkv in VLC, it says the frame rate is 24.000384 (I used a frame rate of 24). When playing the .mp4, it says the frame rate is 24.
Luke M is offline   Reply With Quote
Old 30th May 2017, 03:04   #204  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by sneaker_ger View Post
For example:
mkvmerge.exe -o "temp.mkv" --default-duration 0:24000/1001p --fix-bitstream-timing-information 0:1 "input.mp4"
ffmpeg -i "temp.mkv" -map 0 -c copy "output.mp4"
I'd either forgotten about, or never knew about, the --fix-bitstream-timing-information option. Now I look, there's even a checkbox in the GUI. Doh!

Cheers.

Quote:
Originally Posted by Luke M View Post
Something strange I noticed, when I play the .mkv in VLC, it says the frame rate is 24.000384 (I used a frame rate of 24). When playing the .mp4, it says the frame rate is 24.
It's probably a jitter thing and the way the frame rate is interpreted.

The MKV timecodes are in milliseconds but for 24fps each frame would have a 41.6666667ms duration. If you extract the timecodes from a 24fps MKV they should look like this, with a pattern of 41ms and 42ms durations.

0
42
83
125
167
208
250
292
333
375

I don't know where VLC gets the frame rate from, but I tried the same thing myself and VLC reported 24.000384fps for the MKV, whereas MPC-HC says it's 24fps.
sneaker_ger probably understand the intricacies of it all far more than I do, but it wouldn't be anything to worry about.
hello_hello is offline   Reply With Quote
Old 30th May 2017, 08:01   #205  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Yes, that should be correct. But if ffmpeg reads/writes from mkv to mp4 there will probably also be jitter. If you want 100% perfect mp4 timestamps you need to remux differently, e.g for an mp4 file with 1 video and 1 audio track:
mkvmerge.exe -o "temp.mkv" --default-duration 0:24000/1001p --fix-bitstream-timing-information 0:1 --no-audio "input.mp4"
mkvextract tracks "temp.mkv" "0:temp.264"
mp4box -add "temp.264"#fps=24 -add "input.mp4"#audio -new "output.mp4"


But as you see it gets complicated quickly. Easiest would probably be to use the mkv.
sneaker_ger is offline   Reply With Quote
Old 3rd July 2017, 04:57   #206  |  Link
AVCHDfreak
Registered User
 
Join Date: Dec 2013
Posts: 30
Hi all,
is it possible to use this tool to modify the "videoFormat" and the "videoSignalTypePresentFlag" parameters in the VUI of the H264 bitstream? Thanks in advance.
AVCHDfreak is offline   Reply With Quote
Old 29th September 2019, 10:26   #207  |  Link
ScarAce1989
Banned
 
Join Date: Sep 2014
Location: https://t.me/pump_upp
Posts: 16
-vbsf h264_changesps=sar=0:0
I was wondering if this also is possible for x265?
ScarAce1989 is offline   Reply With Quote
Old 29th September 2019, 15:09   #208  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by ScarAce1989 View Post
-vbsf h264_changesps=sar=0:0
I was wondering if this also is possible for x265?

Probably not with roozhou's tool (old), but ffmpeg has bitstream filters now for HEVC and AVC

https://www.ffmpeg.org/ffmpeg-bitstr...c_005fmetadata

https://www.ffmpeg.org/ffmpeg-bitstr...4_005fmetadata
poisondeathray is offline   Reply With Quote
Old 3rd October 2020, 12:13   #209  |  Link
nbarzgar
Registered User
 
nbarzgar's Avatar
 
Join Date: Jul 2004
Location: Germany
Posts: 53
Usage in .bat files?

Hello,

highly appreciated tool! Have used it for quite some time now.

I am looking at demuxed .h624 files in a folder I want to change the AR for.
I use a .bat file with the following lines:
Code:
For %%a in (*.h246) do ffmpeg -i "%%a.h264" -vcodec copy -acodec copy -vbsf h264_changesps=sar=178:125 "new\%%~na.h264"
pause
ffmpeg.exe copied to that folder.
But when I start the .bat file, nothing happens. The result displays this only:
Code:
E:\path\test>For %%a in (*.h246) do ffmpeg -i "%%a.h264" -vcodec copy -acodec copy -vbsf h264_changesps=sar=178:125 "new\%%~na.h264"
%%a was unexpected at this time.

E:\path\test>pause
I may be missing out on something basic, am not that often into these batch scripts...
Would someone help, please?
Thank you!
__________________
"There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy." Shakespeare, Hamlet
nbarzgar is offline   Reply With Quote
Old 3rd October 2020, 14:44   #210  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by nbarzgar View Post
I am looking at demuxed .h624 files in a folder I want to change the AR for.
I use a .bat file with the following lines:
Code:
For %%a in (*.h246) do ffmpeg -i "%%a.h264" -vcodec copy -acodec copy -vbsf h264_changesps=sar=178:125 "new\%%~na.h264"
pause

Typos ? You have .h624, .h246, .h264

(*.h246) is probably supposed to be *.h264

Also, the -i entry shouldn't have the extension -i "%%a"


Code:
for %%a in (*.h264) do ffmpeg -i "%%a" -vcodec copy -acodec copy -vbsf h264_changesps=sar=178:125 "new\%%~na.h264"
pause
poisondeathray is offline   Reply With Quote
Old 15th July 2021, 10:49   #211  |  Link
maldon
Registered User
 
Join Date: Aug 2019
Posts: 63
Hi, everyone! I fed Handbrake with one H264 video (m2ts, 1920x1080) and this open-source transcoder automatically cropped the black bars:

Top: 130
Bottom: 132

How can I get a new m2ts file with identical black bars (132 top and bottom) without re-encoding? What arg should I use? I suppose I have to use "crop" to crop just 2 pixels. Or do I have to modify SAR, DAR or PAR?
maldon is offline   Reply With Quote
Old 16th July 2021, 11:19   #212  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
The 'black bars' are hard encoded and form part of the overall 1920x1080 [1.77:1] image.

If you want to remove them and create an 1920x818 (816 would be preferable [2.35:1]) 'image only' video file, or re-centre the image within the black bars, you will need to re-encode...
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |

Last edited by SeeMoreDigital; 16th July 2021 at 11:23.
SeeMoreDigital is offline   Reply With Quote
Old 17th July 2021, 17:46   #213  |  Link
maldon
Registered User
 
Join Date: Aug 2019
Posts: 63
Thanks, I want to create a 1920x1080 video, m2ts, but with a 132 pixel horizontal black bar to the top and bottom. But If I have to re-encode how can I keep same original settings? I've created a new thread for this:
maldon is offline   Reply With Quote
Old 7th September 2022, 05:40   #214  |  Link
zn
Registered User
 
Join Date: Jan 2009
Posts: 88
How to change profile flag from main to high in bitstream (without transcoding)

4d4028 (AVC Constrained Main Level 4.0)
or
4d0028 (AVC Main Level 4.0)
to
640028 (AVC High Level 4.0)

update: I have tried to do this with hex editor, and result file is not valid h264, it looks like this is not possible from specification stand point.

Last edited by zn; 7th September 2022 at 18:42.
zn is offline   Reply With Quote
Old 16th February 2023, 00:21   #215  |  Link
thrunk
Registered User
 
Join Date: Apr 2007
Posts: 4
Cropping from 1920,876,0,0 to Cropping from 1920,800,0,0

May I use the bitstream filters to crop my video from 1920x876 to 1920x800? If so what command line should I try? Thanks.
thrunk is offline   Reply With Quote
Old 16th February 2023, 09:54   #216  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally Posted by thrunk View Post
May I use the bitstream filters to crop my video from 1920x876 to 1920x800? If so what command line should I try? Thanks.
Nope... Cropping requires re-encoding!
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital 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 01:09.


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