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 14th July 2010, 00:51   #1  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
how do I get ffmpeg to copy timecodes?

Hi,

I am having trouble getting ffmpeg to preserve the timecode when changing video from an mkv to a flv. The mkv is h.264 and I am using -vcodec copy. I am doing this because I need to play the files over adobe flash player using the new 10.1 api appendBytes method that require the flv fileformat.

Here is the command line:
Quote:
"ffmpeg.exe -i '400-001.mkv' -vcodec copy -acodec libmp3lame -ab 64k -ar 44100 -copyts '400-001.flv'"
I thought this was what the -copyts flag was for but I get the same file with or without it.

I am using one of the ffmpeg autobuilds:
Quote:
FFmpeg version SVN-r24228, Copyright (c) 2000-2010 the FFmpeg developers
built on Jul 13 2010 04:18:07 with gcc 4.4.2
configuration: --enable-gpl --enable-version3 --enable-libgsm --enable-pthread
s --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libmp3lame --
enable-libopenjpeg --enable-libschroedinger --enable-libopencore_amrwb --enable-
libopencore_amrnb --enable-libvpx --arch=x86 --enable-runtime-cpudetect --enable
-libxvid --enable-libx264 --extra-libs='-lx264 -lpthread' --enable-librtmp --ext
ra-libs='-lrtmp -lpolarssl -lws2_32 -lwinmm' --target-os=mingw32 --enable-avisyn
th --cross-prefix=i686-mingw32- --cc='ccache i686-mingw32-gcc' --enable-memalign
-hack
libavutil 50.22. 0 / 50.22. 0
libavcodec 52.83. 0 / 52.83. 0
libavformat 52.73. 0 / 52.73. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.22. 0 / 1.22. 0
libswscale 0.11. 0 / 0.11. 0
I have attached two small clips so you can see what I am talking about. If you open the mkv file in vlc you can see that the timecode starts at 00:00:12 and goes to 00:00:13 give or take. The flv however says it starts at 00:00:00 and goes until 00:00:13, but runs out of video after 1 second.

Sorry for the small files but I have a 300kb upload limit.

Here is the ffmpeg -i for the file:
Quote:
FFmpeg version SVN-r24228, Copyright (c) 2000-2010 the FFmpeg developers
built on Jul 13 2010 04:18:07 with gcc 4.4.2
configuration: --enable-gpl --enable-version3 --enable-libgsm --enable-pthread
s --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libmp3lame --
enable-libopenjpeg --enable-libschroedinger --enable-libopencore_amrwb --enable-
libopencore_amrnb --enable-libvpx --arch=x86 --enable-runtime-cpudetect --enable
-libxvid --enable-libx264 --extra-libs='-lx264 -lpthread' --enable-librtmp --ext
ra-libs='-lrtmp -lpolarssl -lws2_32 -lwinmm' --target-os=mingw32 --enable-avisyn
th --cross-prefix=i686-mingw32- --cc='ccache i686-mingw32-gcc' --enable-memalign
-hack
libavutil 50.22. 0 / 50.22. 0
libavcodec 52.83. 0 / 52.83. 0
libavformat 52.73. 0 / 52.73. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.22. 0 / 1.22. 0
libswscale 0.11. 0 / 0.11. 0
[flv @ 002fc220] Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/
1001) -> 23.98 (48000/2002)
Input #0, flv, from 'C:\...\400-003.flv':
Metadata:
duration : 14
width : 320
height : 176
videodatarate : 0
framerate : 24
videocodecid : 7
filesize : 85589
Duration: 00:00:13.97, start: 12.429000, bitrate: N/A
Stream #0.0: Video: h264, yuv420p, 320x176, 23.98 tbr, 1k tbn, 47.95 tbc
At least one output file must be specified
Attached Files
File Type: zip 400-003.zip (167.2 KB, 49 views)

Last edited by mynewusername; 14th July 2010 at 01:30.
mynewusername is offline   Reply With Quote
Old 16th July 2010, 00:27   #2  |  Link
ifb
Registered User
 
Join Date: Dec 2009
Posts: 68
You could try Baptiste's ffmpeg fork, ffmbc, that has some extra features useful for broadcast/production.
ifb is offline   Reply With Quote
Old 16th July 2010, 01:29   #3  |  Link
kieranrk
Registered User
 
Join Date: Jun 2009
Location: London, United Kingdom
Posts: 713
FLV timestamps must start from zero.
kieranrk is offline   Reply With Quote
Old 16th July 2010, 04:38   #4  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
BIG FAT WARNING:
Official ffmpeg does NOT support -vcodec copy from mkv when b-frame is used. And this is not to be fixed in the near future.

If you need frame copy from mkv to flv or anything else, use ffmpeg build from here.
roozhou is offline   Reply With Quote
Old 16th July 2010, 04:42   #5  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by roozhou View Post
BIG FAT WARNING:
Official ffmpeg does NOT support -vcodec copy from mkv when b-frame is used. And this is not to be fixed in the near future.
I'm pretty sure this was fixed a month or two ago. I've been using -vcodec copy with bframes just fine. I just tested it on an MKV and it works quite perfectly.

Furthermore, if this was the issue, he would be getting a very specific error message. Which he isn't getting.

As kierank said, FLV requires that the first timestamp be zero.
Dark Shikari is offline   Reply With Quote
Old 16th July 2010, 07:30   #6  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by Dark Shikari View Post
I'm pretty sure this was fixed a month or two ago. I've been using -vcodec copy with bframes just fine. I just tested it on an MKV and it works quite perfectly.
Have you tried mkv -> mp4/flv? FFmpeg won't popup error, but the target file is unplayable.

MKV contains only PTS while MP4/FLV require both PTS and DTS. FFmpeg currently lacks the ability to generate DTS based on PTS. I have done some hack on the MKV demuxer so my ffmpeg generates correct DTS from MKV. That's why only my ffmpeg works on MKV.

Last edited by roozhou; 16th July 2010 at 07:32.
roozhou is offline   Reply With Quote
Old 16th July 2010, 07:53   #7  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by roozhou View Post
Have you tried mkv -> mp4/flv? FFmpeg won't popup error, but the target file is unplayable.
FLV plays fine here. Didn't test mp4.
Dark Shikari is offline   Reply With Quote
Old 16th July 2010, 09:05   #8  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by Dark Shikari View Post
FLV plays fine here. Didn't test mp4.
It is not a surprise that some players accept such files (e.g. MPC-HC), but the PTS of the first frame will always be non-zero.
roozhou is offline   Reply With Quote
Old 16th July 2010, 18:10   #9  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,560
I never had success with remuxing mkv->mp4 (tried it every now and then, should be ffmpeg issue 807) using ffmpeg but it seems to be working in the latest build. The files seem to play fine. Could you test if the newest version creates mp4 files correctly, roozhou?
sneaker_ger is offline   Reply With Quote
Old 17th July 2010, 17:30   #10  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by sneaker_ger View Post
I never had success with remuxing mkv->mp4 (tried it every now and then, should be ffmpeg issue 807) using ffmpeg but it seems to be working in the latest build. The files seem to play fine. Could you test if the newest version creates mp4 files correctly, roozhou?
No, I checked out build from http://ffmpeg.arrozcru.org/autobuilds/ and it still fails. The file plays in MPC-HC, but fails in mplayer and PSP.

I have looked into ffmpeg's auto DTS generation code, and unfortunately it cannot be handling mkv correctly.

If you are using windows, try my build here.
roozhou is offline   Reply With Quote
Old 17th July 2010, 17:46   #11  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by roozhou View Post
No, I checked out build from http://ffmpeg.arrozcru.org/autobuilds/ and it still fails. The file plays in MPC-HC, but fails in mplayer and PSP.
Works just fine in mplayer here.
Dark Shikari is offline   Reply With Quote
Old 17th July 2010, 18:24   #12  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,560
Thanks for testing, both of you. For me playing works fine in Lord_Mulder's mplayer build, but not in kovensky chan's. So I'm tempted to believe in roozhou and will stay away from it for now, at least for archival purposes. Extracting the tracks and muxing using mp4box plays fine in both builds (as expected).

roozhou's version works fine.

Last edited by sneaker_ger; 17th July 2010 at 18:28.
sneaker_ger is offline   Reply With Quote
Old 17th July 2010, 18:52   #13  |  Link
Ritsuka
Registered User
 
Join Date: Mar 2007
Posts: 59
I guess mplayer is not a good app to test, it used to play even mp4 without pts informations.
Ritsuka is offline   Reply With Quote
Old 17th July 2010, 18:59   #14  |  Link
b66pak
Registered User
 
b66pak's Avatar
 
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
ps3 only plays mp4 remuxed with roozhou's build of ffmpeg...
_
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note...
Visit The Land Of Dracula (Romania - EU)!
b66pak is offline   Reply With Quote
Old 17th July 2010, 21:28   #15  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
Quote:
Originally Posted by kieranrk View Post
FLV timestamps must start from zero.
Thanks for all the responses. I ended up keeping track of the starting time inside of my player code to get around this.
mynewusername is offline   Reply With Quote
Reply

Tags
ffmpeg, flv, h264, mkv to flv, mux

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:05.


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