APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Error: Could not encode Video - Timebase not supported by mpeg 4 Standard post and replies

Return to the Error: Could not encode Video - Timebase not supported by mpeg 4 Standard thread
Login to post to this thread

Error while exporting video
Thomas Rufer
3 Posts

Hi!

First time poster here...

I made an analysis (Tracker-Zip @ https://www.dropbox.com/sh/jt814gp6mp4hc2h/AACuGhFOWyOGhgYW3ydtCmkMa?dl=0)
but when i try to export the Video with the lines and angles, in the end it throws an error:
"Could not encode video"
and a second error-Window
"Timebase not supported by mpeg 4 Standard thread"
See attachment

PC was Windows 8.1


I tested it on my Laptop as well (Win10) with the same problem.
The FPS is 29.6fps and straight from my phone... Should be a valid MPEG4 i think...

So... What can i do to export the video? What even is the problem, as 29.6fps is a valid fps for MPEG4, no?

also tried to save it to an USB-Stick in case of write-problems. Same.


Puzzled...


Edit:
Oh... The console throws this:


CONSOLE: 16:43:00.443 [AWT-EventQueue-0] ERROR org.ffmpeg - [mpeg4 @ 0x288fedb0] timebase not supported by mpeg 4 standard


CONSOLE: 16:43:00.443 [AWT-EventQueue-0] WARN  com.xuggle.xuggler - Error: could not open codec (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:686)


CONSOLE: 16:43:00.513 [AWT-EventQueue-0] WARN  com.xuggle.xuggler - Attempting to encode when not ready (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1194)


CONSOLE: 16:46:20.201 [AWT-EventQueue-0] WARN  com.xuggle.xuggler - writeTrailer() with no matching call to writeHeader() (../../../../../../../csrc/com/xuggle/xuggler/Container.cpp:734)


CONSOLE: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: could not write trailer to output file


    at org.opensourcephysics.media.xuggle.XuggleVideoRecorder.closeStream(Unknown Source)


    at org.opensourcephysics.media.xuggle.XuggleVideoRecorder.reset(Unknown Source)


    at org.opensourcephysics.cabrillo.tracker.ExportVideoDialog$5$1.run(Unknown Source)


    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)


    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)


    at java.desktop/java.awt.EventQueue.access$500(Unknown Source)


    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)


    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)


    at java.base/java.security.AccessController.doPrivileged(Native Method)


    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)


    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)


    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)



Edit:
weird... If i export only up to frame 35, all is OK... Only if i export up to 182, the error occurs...
up to frame 99: error
[unknown region]
up to frame 76: Success
up to frame 50: Success.



Edit: Hu? If i export to WMV, all works (except the quality of the video is shit after export... Blocky as hell...)
I added the WMV to the Dropbox link from above... Some idea on how to improve the video-quality?

Post edited November 14, 2018 at 11:19 AM EST.

Attached File: errortracker.jpg


Replies to Error while exporting video

Re: Error while exporting video -
Douglas Brown Avatar
Douglas Brown
339 Posts

29.6 fps is not a standard frame rate at all so it doesn't surprise me that the mp4 export fails. But why it works for some clip lengths and not others is a mystery. It may be that your phone skips a frame or 2 in the last part of the video, which is not uncommon. Have you looked at other videos from taken your phone?

If you don't care about the size of the exported video you might try exporting to JPG, which creates a series of still images. You could then use a separate program to combine the JPG files into a single video.

Unfortunately the quality of exported videos is never very good and there is little I can do about it since it depends on the Xuggle video engine presets :-(




> Re: Error while exporting video
>
> Hi!
>
> First time poster here...
>
> I made an analysis
> (Tracker-Zip @ https://www.dropbox.com/sh/jt814gp6mp4hc2h/AACuGhFOWyOGhgYW3ydtCmkMa?dl=0)
> but
> when i try to export the Video with the lines and
> angles, in the end it throws an error:
> "Could not
> encode video"
> and a second error-Window
> "Timebase
> not supported by mpeg 4 Standard thread"
> See attachmen
>
>
> PC was Windows 8.1
>
>
> I tested it on my Laptop as
> well (Win10) with the same problem.
> The FPS is 29.6fps
> and straight from my phone... Should be a valid MPEG4
> i think...
>
> So... What can i do to export the video?
> What even is the problem, as 29.6fps is a valid fps
> for MPEG4, no?
>
> also tried to save it to an USB-Stick
> in case of write-problems. Same.
>
>
> Puzzled...
>
>
> Edit
>
> Oh... The console throws this:
>
>
> CONSOLE: 16:43:00.443
> [AWT-EventQueue-0] ERROR org.ffmpeg - [mpeg4 @ 0x288fedb0]
> timebase not supported by mpeg 4 standard
>
>
> CONSOLE:
> 16:43:00.443 [AWT-EventQueue-0] WARN  com.xuggle.xuggler
> - Error: could not open codec (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:686)
>
>
> CONSOLE:
> 16:43:00.513 [AWT-EventQueue-0] WARN  com.xuggle.xuggler
> - Attempting to encode when not ready (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1194)
>
>
> CONSOLE:
> 16:46:20.201 [AWT-EventQueue-0] WARN  com.xuggle.xuggler
> - writeTrailer() with no matching call to writeHeader()
> (../../../../../../../csrc/com/xuggle/xuggler/Container.cpp:734)
>
>
> CONSOLE:
> Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
> could not write trailer to output file
>
>
>     at org.opensourcephysics.media.xuggle.XuggleVideoRecorder.closeStream(Unknown
> Source)
>
>
>     at org.opensourcephysics.media.xuggle.XuggleVideoRecorder.reset(Unknown
> Source)
>
>
>     at org.opensourcephysics.cabrillo.tracker.ExportVideoDialog$5$1.run(Unknown
> Source)
>
>
>     at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventQueue.access$500(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventQueue$3.run(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventQueue$3.run(Unknown
> Source)
>
>
>     at java.base/java.security.AccessController.doPrivileged(Native
> Method)
>
>
>     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown
> Source)
>
>
>     at java.desktop/java.awt.EventDispatchThread.run(Unknown
> Source)
>
>
>
> Edit:
> weird... If i export only up to frame
> 35, all is OK... Only if i export up to 182, the error
> occurs...
> up to frame 99: error
> [unknown region]
> up
> to frame 76: Success
> up to frame 50: Success.
>
>
>
> Edit:
> Hu? If i export to WMV, all works (except the quality
> of the video is shit after export... Blocky as hell...
>
> I added the WMV to the Dropbox link from above...
> Some idea on how to improve the video-quality?
>
> Post
> edited November 14, 2018 at 11:19 AM EST.



Re: Error while exporting video -
Thomas Rufer
3 Posts

Thanks Douglas for those inputs
If it would be true, that my phone drops a few frames in the end, it would help to NOT use the video till the end, which is exactly what i did: I used the first 182 frames out of 222. So there wouldnt be the cut-parts in the used data...


Weird... None the MP4 from my phone are 30fps...
all 640x480 are 29.6fps.
The 1280x720 are around 30, but none is exactly 30.00. Some are 30.01, 29.99 and so on...
See attached TXTs of a few test-videos i analysed with ffprobe
No other player has problems playing those files and working with them...
FFMPEG even can transcode them without a hitch...


Good idea with the JPGs... But that indeed would make a very large MPEG4 as all frames would be Keyframes... Hm... Isnt there options to teach Xuggle manners?



Edit:
OK... Managed to reencode the files to exactly 30fps with FFMPEG:
Thats the batch-file i use now to drop a MP4 from my phone onto it and tell him to re-encode to 30 fps and save as [filename]_[fps].[ext]
And low and behold!: Tracker can export then just fine. In a crappy quality, but at least it can export it...

BATCH-Contents:
@ECHO Off
SET /P _fps= Recode to what FPS? :

:: Get all the parts of the structure
set _full_filename=%~n1%~x1
set _drive=%~d1
set _path=%~p1
set _filename=%~n1
set _ext=%~x1

@ECHO On
echo %_drive%
echo %_path%
echo %filename%

:: lets do this!
ffmpeg -r %_fps% -i "%_full_filename%" -c:v libx264 -crf 18 -c:a aac -strict -2 "%_drive%%_path%%_filename%_%_fps%%_ext%"





Does it make sense to open a new thread for the quality-problems of Xuggle?

Post edited November 15, 2018 at 4:33 AM EST.

Attached File: Video-Infos.zip



Re: Error while exporting video -
Douglas Brown Avatar
Douglas Brown
339 Posts

I agree it is very odd that several of your videos are 29.60 fps, a number I have never seen before.

Exporting videos has never been a high priority with Tracker.  You could certainly open a new thread on this issue but unless another user (you?) wants to spend the time to dig into the Java code I don't foresee improvements in the Xuggle video exporting.

A bigger issue with Xuggle is that it is no longer actively supported by its developer. Xuggle itself uses FFMPEG, but it is an older version which is why some newer codecs are not supported. What Tracker needs is a new open source video engine and that is something I am working on.


> Weird... None the MP4 from my phone are 30fps..
>
> all 640x480 are 29.6fps.
> The 1280x720 are around
> 30, but none is exactly 30.00. Some are 30.01, 29.99
> and so on...
> See attached TXTs of a few test-videos
> i analysed with ffprobe
> No other player has problems
> playing those files and working with them...
> FFMPEG
> even can transcode them without a hitch...
>
>
> Good
> idea with the JPGs... But that indeed would make a
> very large MPEG4 as all frames would be Keyframes...
> Hm... Isnt there options to teach Xuggle manners
>
> Does
> it make sense to open a new thread for the quality-problems
> of Xuggle?
>



Re: Error while exporting video -
Thomas Rufer
3 Posts

Hi Douglas

Ah... Thanks for those insights.
I am a mere dabbler in the coding-arts. I am an athlete and "user" of the Software. Not really a developper.
I wonder if i can trick FFMPEG into screengrabbing directly somehow...
Or having FFMPEG to create a correct MPEG4 from the JPG-Outputs (with normal frames and only occasionally a keyframe)...

I will open a new thread and post my progress and findings and hints and ideas there.

Thanks!



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book