[FFmpeg-user] apple-friendly timestamps with -c copy

Claudiu Rad jazzman at misalpina.net
Fri Dec 18 19:41:06 CET 2015



On 11/25/2015 10:10 PM, Claudiu Rad wrote:
>
>
> On 11/24/2015 3:21 PM, Claudiu Rad wrote:
>> hello warriors,
>>
>> so maybe this is obvious for some but not for me.
>>
>> i have some recordings produced by adobe's flash media server 
>> technologies, encoding originally done by their flash media live 
>> encoder in h264 + mp3/aac.
>> only some of them exhibit a bad playback behavior when trying to -c 
>> copy them to mp4/HLS.

it seems that issues only exist with recordings made with h264 main 
profile. baseline works properly.

>> bad playback means stuttering in some players like the fps went down, 
>> but on apple playing runtimes i really don't know the term or how to 
>> describe it, it's like the image jumps forward/backward a few frames 
>> a couple of times per second while the audio runs fine.
>
> after searching a bit, i think what i am seeing is somewhat the same 
> as described here: https://trac.ffmpeg.org/ticket/502 - jumping 
> frames, frames not played in the right order
>
>> apple playing runtimes means: quicktime or safari on os x or iOS 
>> playing MP4 or HLS generated with ffmpeg.
>>
>> from my initial investigations, the difference between a well 
>> behaving adobe recording and a badly behaving one is related to 
>> PTS/DTS values, visually i guess its like apple plays back based on 
>> DTS not PTS, please observe how the frames are constantly interlaced:
>> frame,pkt_pts_time,best_effort_timestamp_time,pkt_dts_time,pict_type
>> *frame,0.000000,0.040000,0.000000,I*
>> frame,0.080000,0.080000,0.080000,B
>> frame,0.120000,0.120000,0.120000,B
>> frame,0.160000,0.160000,0.160000,B
>> *frame,0.040000,0.200000,0.200000,P*
>> frame,0.240000,0.240000,0.240000,B
>> frame,0.280000,0.280000,0.280000,B
>> frame,0.320000,0.320000,0.320000,B
>> *frame,0.200000,0.360000,0.360000,P*
>> frame,0.400000,0.400000,0.400000,B
>> ...
>
> BTW, what does 'best_effort_timestamp_time' mean?
>
>>
>> VLC plays both the original recording and ffmpeg outputs just fine.
>> if i reencode with ffmpeg everything is then perfect, PTS/DTS are 
>> aligned, but i want to avoid that.
>>
>> what ideas do you have? how can i work on timestamps with ffmpeg and 
>> correct them via -c copy?
>> basically a reorganizing / re-timestamping so that we have 
>> monotonically increasing PTS i assume should be enough. is this 
>> possible?

anyone? i really need to find a solution without re-encoding the whole 
data. please, we are speaking about TB..
why is this correctly played by flash player or VLC?

>
> to put it in another way: can ffmpeg reorder frames in the video 
> stream based on some criteria, in my case based on PTS?
> or does anybody know other tools that could do that? i would really 
> try this to see if anything changes or re-timestamping is really 
> necessary.
>
>>
>> a bad recording sample is here: http://www.datafilehost.com/d/6a22a099

i realized that even i don't know how to download that. re-posted the 
sample input here:
http://88.198.6.138/tsissue/in.f4f
and the output of running the below command here:
http://88.198.6.138/tsissue/out.mp4

>>
>> ffmpeg output:
>>
>> ffmpeg -y -i in.f4f -c copy out.mp4
>> ffmpeg version N-76816-g188a1a1-static Copyright (c) 2000-2015 the 
>> FFmpeg developers
>>   built with gcc 4.7 (Debian 4.7.2-5)
>>   configuration: --prefix=/root/ffmpeg_build 
>> --extra-cflags='-I/root/ffmpeg_build/include -static' 
>> --extra-ldflags='-L/root/ffmpeg_build/lib -lm -static' 
>> --pkg-config-flags=--static --bindir=/root/bin --enable-gpl 
>> --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame 
>> --enable-libopus --enable-libtheora --enable-libvorbis 
>> --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid 
>> --enable-nonfree --extra-version=static --disable-debug 
>> --disable-shared --enable-static --extra-cflags=--static 
>> --disable-doc --enable-pthreads --enable-postproc 
>> --enable-runtime-cpudetect --enable-version3 --disable-devices
>>   libavutil      55.  9.100 / 55.  9.100
>>   libavcodec     57. 16.100 / 57. 16.100
>>   libavformat    57. 19.100 / 57. 19.100
>>   libavdevice    57.  0.100 / 57.  0.100
>>   libavfilter     6. 15.100 /  6. 15.100
>>   libswscale      4.  0.100 /  4.  0.100
>>   libswresample   2.  0.101 /  2.  0.101
>>   libpostproc    54.  0.100 / 54.  0.100
>> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x335fa40] multiple edit list entries, a/v 
>> desync might occur, patch welcome
>>     Last message repeated 3 times
>> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.f4f':
>>   Metadata:
>>     major_brand     : f4v
>>     minor_version   : 1
>>     compatible_brands: isommp42m4v
>>     creation_time   : 2015-01-04 18:02:32
>>   Duration: 00:05:24.98, start: 0.000000, bitrate: 368 kb/s
>>     Stream #0:0(eng): Data: none (amf0 / 0x30666D61), 0 kb/s (default)
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : MainConcept
>>     Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), 
>> yuv420p(tv), 426x240 [SAR 1:1 DAR 71:40], 200 kb/s, 25 fps, 25 tbr, 
>> 1k tbn, 50 tbc (default)
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : MainConcept
>>       encoder         : AVC Coding
>>     Stream #0:2(eng): Audio: mp3 (.mp3 / 0x33706D2E), 44100 Hz, 
>> stereo, s16p, 127 kb/s (default)
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : MainConcept
>>     Stream #0:3(eng): Data: none (rtmp / 0x706D7472), 338 kb/s
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : Adobe Systems Inc. Hint Handler
>> [mp4 @ 0x34103e0] Codec for stream 0 does not use global headers but 
>> container format requires global headers
>> [mp4 @ 0x34103e0] Codec for stream 1 does not use global headers but 
>> container format requires global headers
>> Output #0, mp4, to 'out.mp4':
>>   Metadata:
>>     major_brand     : f4v
>>     minor_version   : 1
>>     compatible_brands: isommp42m4v
>>     encoder         : Lavf57.19.100
>>     Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 
>> 426x240 [SAR 1:1 DAR 71:40], q=2-31, 200 kb/s, 25 fps, 25 tbr, 16k 
>> tbn, 1k tbc (default)
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : MainConcept
>>       encoder         : AVC Coding
>>     Stream #0:1(eng): Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, 
>> stereo, 127 kb/s (default)
>>     Metadata:
>>       creation_time   : 2015-01-04 18:02:32
>>       handler_name    : MainConcept
>> Stream mapping:
>>   Stream #0:1 -> #0:0 (copy)
>>   Stream #0:2 -> #0:1 (copy)
>> Press [q] to stop, [?] for help
>> frame= 8125 fps=0.0 q=-1.0 Lsize=   13238kB time=00:05:25.00 bitrate= 
>> 333.7kbits/s
>> video:7972kB audio:5067kB subtitle:0kB other streams:0kB global 
>> headers:0kB muxing overhead: 1.525306%
>>
>> thank you.
>>
>>
>> -- 
>> Claudiu
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> -- 
> Claudiu


More information about the ffmpeg-user mailing list