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 > Capturing and Editing Video > New and alternative a/v containers

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st January 2016, 23:32   #1  |  Link
MikeBell
Registered User
 
Join Date: Jan 2004
Posts: 7
How to change the framerate of an MP4 file without re-encoding video?

Hi all,

I have a poorly encoded video of a webcast (I presume it came from a WebEx screencast) and the main issue is that the framerate of the mp4 file is double than it should be. If I play it with VLC and slow down the playback speed to 0.5x, everything's normal and I can understand the audio. If I play it at 1x, I can't understand anything and everything's too fast.

Mediainfo says this about the file:

Code:
General
Complete name                            : source.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 181 MiB
Duration                                 : 33mn 53s
Overall bit rate mode                    : Constant
Overall bit rate                         : 748 Kbps
Writing application                      : Lavf56.19.100

Video
ID                                       : 1
Format                                   : MPEG-4 Visual
Format profile                           : Simple@L1
Format settings, BVOP                    : No
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : 20
Duration                                 : 33mn 53s
Bit rate mode                            : Constant
Bit rate                                 : 674 Kbps
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Frame rate                               : 10.000 fps
Minimum frame rate                       : 9.990 fps
Maximum frame rate                       : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.220
Stream size                              : 163 MiB (90%)
Writing library                          : Lavc52.108.0

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 33mn 53s
Duration_LastFrame                       : -19ms
Bit rate mode                            : Constant
Bit rate                                 : 70.2 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 17.0 MiB (9%)
My first stab at this problem was to use mp4box to change the framerate to 5fps. I actually succeeded at "slowing" down the video but I failed at slowing down the audio. Here's what I tried:

Code:
$ mp4box -add source.mp4\#video -raw 1 -new video
this created "video_track1.cmp" file.

Code:
$ mp4box -add source.mp4\#audio -raw 2 -new audio
this created "audio_track2.aac" file.

I then tried combining them with:

Code:
$ mp4box -add video_track1.cmp:fps=5 -add audio_track2.aac:fps=5 -new dest.mp4
This actually partially worked and produced a dest.mp4 that had video portion correct and it played at the right speed but the audio was still playing too fast:

Code:
 General
Complete name                            : dest.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 181 MiB
Duration                                 : 1h 7mn
Overall bit rate mode                    : Variable
Overall bit rate                         : 373 Kbps
Encoded date                             : UTC 2016-01-21 22:24:30
Tagged date                              : UTC 2016-01-21 22:24:30

Video
ID                                       : 1
Format                                   : MPEG-4 Visual
Format profile                           : Simple@L1
Format settings, BVOP                    : No
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : 20
Duration                                 : 1h 7mn
Bit rate mode                            : Variable
Bit rate                                 : 337 Kbps
Maximum bit rate                         : 929 Kbps
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 5.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.220
Stream size                              : 163 MiB (90%)
Title                                    : cmp:fps=5@GPAC0.5.1-DEV-rev5375
Writing library                          : Lavc52.108.0
Encoded date                             : UTC 2016-01-21 22:24:30
Tagged date                              : UTC 2016-01-21 22:24:55

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 33mn 53s
Bit rate mode                            : Variable
Bit rate                                 : 70.2 Kbps
Maximum bit rate                         : 87.8 Kbps
Channel(s)                               : 2 channels
Channel(s)_Original                      : 3 channels
Channel positions                        : Front: L C R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 17.0 MiB (9%)
Title                                    : aac:fps=5@GPAC0.5.1-DEV-rev5375
Encoded date                             : UTC 2016-01-21 22:24:52
Tagged date                              : UTC 2016-01-21 22:24:55
You can see above that Audio track's duration is wrong.

How do I fix the audio track? I don't mind re-encoding it with ffmpeg if that's the only option. I don't know how to do it however. Also, can mp4box do this on its own? What am I doing wrong?
MikeBell is offline   Reply With Quote
Old 22nd January 2016, 00:19   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
FFMpeg: How to speed up / slow down a video
Quote:
Using a complex filtergraph, you can speed up [or slow down] video and audio at the same time:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv
Avisynth is another option, handy for fixing all sorts of things like this, on the fly (you play the script directly, without re-encoding)
Code:
DirectShowSource("input.mkv")
AssumeFPS(5, sync_audio=true)
raffriff42 is offline   Reply With Quote
Old 22nd January 2016, 00:34   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Nice one Raff, Archiving your post.

Yesterday, encoded MP4 @ Aspect Ratio 240:1, was a bit of a struggle to re-AR @ 2.40:1

Is there a standard ffmpeg fix for that (there is a special ffmpeg version that re-does AR, somewhere on site).
(I used YAMB + MeGUI, about 6 tries to get correct).

EDIT: Some links on changing AR

http://forum.doom9.org/showthread.php?t=152419
http://forum.videohelp.com/threads/3...out-reencoding
http://forum.videohelp.com/threads/3...ut-re-encoding
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd January 2016 at 00:44. Reason: Add links
StainlessS is offline   Reply With Quote
Old 22nd January 2016, 01:11   #4  |  Link
MikeBell
Registered User
 
Join Date: Jan 2004
Posts: 7
Quote:
Originally Posted by raffriff42 View Post
FFMpeg: How to speed up / slow down a video

Avisynth is another option, handy for fixing all sorts of things like this, on the fly (you play the script directly, without re-encoding)
Code:
DirectShowSource("input.mkv")
AssumeFPS(5, sync_audio=true)
I tried this:

Code:
ffmpeg -i source.mp4 -filter_complex "[0:a]atempo=0.5[a]" -map "[a]" outputaudio.m4a

and this... which is a simplified, audio-only, option:

ffmpeg -i out.m4a -filter:a "atempo=0.5" -vn outputaudio.aac
Note: I used 0.5 because 2.0 speeds it up 2x and I want to slow it down 2x.

Result: audio sounds horrible It has that weird metallic sounding echo all over the track. It sounds nothing like what you hear when you slow down to 0.5x with VLC.

I'm still unsure how to proceed...

Quote:
Originally Posted by StainlessS View Post
Nice one Raff, Archiving your post.

Yesterday, encoded MP4 @ Aspect Ratio 240:1, was a bit of a struggle to re-AR @ 2.40:1

Is there a standard ffmpeg fix for that (there is a special ffmpeg version that re-does AR, somewhere on site).
(I used YAMB + MeGUI, about 6 tries to get correct).

EDIT: Some links on changing AR

http://forum.doom9.org/showthread.php?t=152419
http://forum.videohelp.com/threads/3...out-reencoding
http://forum.videohelp.com/threads/3...ut-re-encoding

Several times I managed to change aspect ratio without re-encoding by doing this:

Code:
ffmpeg -i in.mp4 -vcodec copy -acodec copy -aspect 16:9 output.mp4
MikeBell is offline   Reply With Quote
Old 22nd January 2016, 01:21   #5  |  Link
MikeBell
Registered User
 
Join Date: Jan 2004
Posts: 7
My previous post ended up in moderation queue because I quoted StainlessS's post with lots of links

Anyway, abreviation:

raffriff42: I tried this:

Code:
ffmpeg -i out.m4a -filter:a "atempo=0.5" -vn outputaudio.aac
same as:
ffmpeg -i source.mp4 -filter_complex "[0:a]atempo=0.5[a]" -map "[a]" outputaud.m4a
and it sounded horrible. While the speed sounded correct, it had that metallic echo all over it. Couldn't understand anything. It sounded nothing like VLC's 0.5x slowdown. Note: I used 0.5 and not 2.0 like in your example because I wanted it to slow down, not speed up by 2x.

StainlessS: I always try changing AR like this... without re-encoding. Most of the time it works great:

Code:
 ffmpeg -i in.mp4 -vcodec copy -acodec copy -aspect 16:9 output.mp4
MikeBell is offline   Reply With Quote
Reply

Tags
ffmpeg, mp4box

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 20:15.


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