Repository: ytdl-org/youtube-dl

Issue:
mtime is today's date on muxed video files
The mtime on the video file is correct when not muxing, but is today's date when muxing:

```
# PYTHONPATH=. python -m youtube_dl -f best "VuSNIbhzuAU"
[youtube] Confirming age
[youtube] VuSNIbhzuAU: Downloading webpage
[youtube] VuSNIbhzuAU: Downloading video info webpage
[youtube] VuSNIbhzuAU: Extracting video information
[youtube] VuSNIbhzuAU: Downloading DASH manifest
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.mp4
[download] 100% of 17.90MiB in 00:16

# ls -l Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4        
-rw-rw-r-- 1 at at 18,773,958 2014-02-16 18:55 Flood on Regent Street-VuSNIbhzuAU.mp4

# rm Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4 

# PYTHONPATH=. python -m youtube_dl -f bestvideo+bestaudio "VuSNIbhzuAU"       
[youtube] Confirming age
[youtube] VuSNIbhzuAU: Downloading webpage
[youtube] VuSNIbhzuAU: Downloading video info webpage
[youtube] VuSNIbhzuAU: Extracting video information
[youtube] VuSNIbhzuAU: Downloading DASH manifest
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.f137.mp4
[download] 100% of 23.13MiB in 00:28
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.f141.m4a
[download] 100% of 1.43MiB in 00:02
[ffmpeg] Merging formats into "Flood on Regent Street-VuSNIbhzuAU.mp4"

# ls -l Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4 
-rw-rw-r-- 1 at at 25,754,469 2014-11-20 04:33 Flood on Regent Street-VuSNIbhzuAU.mp4
```

Expected 2014-02-16, but got today's date 2014-11-20 instead.

```
# avconv 
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Hyper fast Audio and Video encoder
usage: avconv [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man avconv'
```

mtime is today's date on muxed video files
The mtime on the video file is correct when not muxing, but is today's date when muxing:

```
# PYTHONPATH=. python -m youtube_dl -f best "VuSNIbhzuAU"
[youtube] Confirming age
[youtube] VuSNIbhzuAU: Downloading webpage
[youtube] VuSNIbhzuAU: Downloading video info webpage
[youtube] VuSNIbhzuAU: Extracting video information
[youtube] VuSNIbhzuAU: Downloading DASH manifest
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.mp4
[download] 100% of 17.90MiB in 00:16

# ls -l Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4        
-rw-rw-r-- 1 at at 18,773,958 2014-02-16 18:55 Flood on Regent Street-VuSNIbhzuAU.mp4

# rm Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4 

# PYTHONPATH=. python -m youtube_dl -f bestvideo+bestaudio "VuSNIbhzuAU"       
[youtube] Confirming age
[youtube] VuSNIbhzuAU: Downloading webpage
[youtube] VuSNIbhzuAU: Downloading video info webpage
[youtube] VuSNIbhzuAU: Extracting video information
[youtube] VuSNIbhzuAU: Downloading DASH manifest
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.f137.mp4
[download] 100% of 23.13MiB in 00:28
[download] Destination: Flood on Regent Street-VuSNIbhzuAU.f141.m4a
[download] 100% of 1.43MiB in 00:02
[ffmpeg] Merging formats into "Flood on Regent Street-VuSNIbhzuAU.mp4"

# ls -l Flood\ on\ Regent\ Street-VuSNIbhzuAU.mp4 
-rw-rw-r-- 1 at at 25,754,469 2014-11-20 04:33 Flood on Regent Street-VuSNIbhzuAU.mp4
```

Expected 2014-02-16, but got today's date 2014-11-20 instead.

```
# avconv 
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Hyper fast Audio and Video encoder
usage: avconv [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man avconv'
```



Discussion:

Resolving patch:
diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py
--- a/youtube_dl/postprocessor/ffmpeg.py
+++ b/youtube_dl/postprocessor/ffmpeg.py
@@ -79,6 +79,7 @@ def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
         files_cmd = []
         for path in input_paths:
             files_cmd.extend(['-i', encodeFilename(path, True)])
+        oldest_mtime = min(os.stat(path).st_mtime for path in input_paths)
         cmd = ([self._executable, '-y'] + files_cmd
                + [encodeArgument(o) for o in opts] +
                [encodeFilename(self._ffmpeg_filename_argument(out_path), True)])
@@ -91,6 +92,7 @@ def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
             stderr = stderr.decode('utf-8', 'replace')
             msg = stderr.strip().split('\n')[-1]
             raise FFmpegPostProcessorError(msg)
+        os.utime(out_path, (oldest_mtime, oldest_mtime))
         if self._deletetempfiles:
             for ipath in input_paths:
                 os.remove(ipath)


Test patch: