diff --git a/ffmpeg.c b/ffmpeg.c
index 48fea42b7aa410e1f6a952a331f8e8f8ef0a5741..dd0eeb885caa36abb63f38f0e089a503286e209a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -427,6 +427,7 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
 {
     int i, err;
     AVFormatContext *ic;
+    int nopts = 0;
 
     err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);
     if (err < 0)
@@ -442,8 +443,13 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
         st->codec = avcodec_alloc_context();
         memcpy(st->codec, ic->streams[i]->codec, sizeof(AVCodecContext));
         s->streams[i] = st;
+        if(st->codec->flags & CODEC_FLAG_BITEXACT)
+            nopts = 1;
     }
 
+    if (!nopts)
+        s->timestamp = av_gettime();
+
     av_close_input_file(ic);
     return 0;
 }
@@ -2177,8 +2183,6 @@ static void opt_format(const char *arg)
     }
 }
 
-extern int ffm_nopts;
-
 static int opt_default(const char *opt, const char *arg){
     int type;
     const AVOption *o= NULL;
@@ -2210,12 +2214,6 @@ static int opt_default(const char *opt, const char *arg){
     opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
     opt_names[opt_name_count++]= o->name;
 
-#ifdef CONFIG_FFM_MUXER
-    /* disable generate of real time pts in ffm (need to be supressed anyway) */
-    if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
-        ffm_nopts = 1;
-#endif
-
     if(avctx_opts[0]->debug)
         av_log_set_level(AV_LOG_DEBUG);
     return 0;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 181a17439272b6682471ef9a03ebd8bb7d0d7e9f..d279506839dfff27d3702470b1ff1416eef9c336 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -22,7 +22,7 @@
 #define FFMPEG_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 14
+#define LIBAVFORMAT_VERSION_MINOR 15
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavformat/ffm.h b/libavformat/ffm.h
index ebbf9924800049f6bc4ba3ccd9694e26f769690d..c758f9d81707444da6657f095f4bb2b962555a28 100644
--- a/libavformat/ffm.h
+++ b/libavformat/ffm.h
@@ -51,7 +51,6 @@ typedef struct FFMContext {
     int64_t pts;
     uint8_t *packet_ptr, *packet_end;
     uint8_t packet[FFM_PACKET_SIZE];
-    int64_t start_time;
 } FFMContext;
 
 #endif /* FFMPEG_FFM_H */
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index c07beb989dca1b20a847a0d481245e4f35698626..906152f97896f639439433055d401de7d5c05b8a 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -22,9 +22,6 @@
 #include "avformat.h"
 #include "ffm.h"
 
-/* disable pts hack for testing */
-int ffm_nopts = 0;
-
 static void flush_packet(AVFormatContext *s)
 {
     FFMContext *ffm = s->priv_data;
@@ -173,12 +170,6 @@ static int ffm_write_header(AVFormatContext *s)
         }
     }
 
-    /* hack to have real time */
-    if (ffm_nopts)
-        ffm->start_time = 0;
-    else
-        ffm->start_time = av_gettime();
-
     /* flush until end of block reached */
     while ((url_ftell(pb) % ffm->packet_size) != 0)
         put_byte(pb, 0);
@@ -203,7 +194,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t pts;
     uint8_t header[FRAME_HEADER_SIZE];
 
-    pts = ffm->start_time + pkt->pts;
+    pts = s->timestamp + pkt->pts;
     /* packet size & key_frame */
     header[0] = pkt->stream_index;
     header[1] = 0;